use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project spring-boot by spring-projects.
the class ServletWebServerFactoryCustomizerTests method whenShutdownPropertyIsSetThenShutdownIsCustomized.
@Test
void whenShutdownPropertyIsSetThenShutdownIsCustomized() {
Map<String, String> map = new HashMap<>();
map.put("server.shutdown", "graceful");
bindProperties(map);
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
this.customizer.customize(factory);
ArgumentCaptor<Shutdown> shutdownCaptor = ArgumentCaptor.forClass(Shutdown.class);
then(factory).should().setShutdown(shutdownCaptor.capture());
assertThat(shutdownCaptor.getValue()).isEqualTo(Shutdown.GRACEFUL);
}
use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project jhipster-registry by jhipster.
the class WebConfigurer method setLocationForStaticAssets.
private void setLocationForStaticAssets(WebServerFactory server) {
if (server instanceof ConfigurableServletWebServerFactory) {
ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server;
File root;
String prefixPath = resolvePathPrefix();
root = new File(prefixPath + "target/classes/static/");
if (root.exists() && root.isDirectory()) {
servletWebServer.setDocumentRoot(root);
}
}
}
use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method testDefaultDisplayName.
@Test
public void testDefaultDisplayName() throws Exception {
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
this.customizer.customize(factory);
verify(factory).setDisplayName("application");
}
use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method testCustomizeTomcatPort.
@Test
public void testCustomizeTomcatPort() throws Exception {
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
this.properties.setPort(8080);
this.customizer.customize(factory);
verify(factory).setPort(8080);
}
use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method customizeSessionProperties.
@Test
public void customizeSessionProperties() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("server.session.timeout", "123");
map.put("server.session.tracking-modes", "cookie,url");
map.put("server.session.cookie.name", "testname");
map.put("server.session.cookie.domain", "testdomain");
map.put("server.session.cookie.path", "/testpath");
map.put("server.session.cookie.comment", "testcomment");
map.put("server.session.cookie.http-only", "true");
map.put("server.session.cookie.secure", "true");
map.put("server.session.cookie.max-age", "60");
bindProperties(map);
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
ServletContext servletContext = mock(ServletContext.class);
SessionCookieConfig sessionCookieConfig = mock(SessionCookieConfig.class);
given(servletContext.getSessionCookieConfig()).willReturn(sessionCookieConfig);
this.customizer.customize(factory);
triggerInitializers(factory, servletContext);
verify(factory).setSessionTimeout(123);
verify(servletContext).setSessionTrackingModes(EnumSet.of(SessionTrackingMode.COOKIE, SessionTrackingMode.URL));
verify(sessionCookieConfig).setName("testname");
verify(sessionCookieConfig).setDomain("testdomain");
verify(sessionCookieConfig).setPath("/testpath");
verify(sessionCookieConfig).setComment("testcomment");
verify(sessionCookieConfig).setHttpOnly(true);
verify(sessionCookieConfig).setSecure(true);
verify(sessionCookieConfig).setMaxAge(60);
}
Aggregations