Search in sources :

Example 1 with TomcatWebServer

use of org.springframework.boot.web.embedded.tomcat.TomcatWebServer in project spring-boot by spring-projects.

the class LocalDevToolsAutoConfigurationTests method devToolsSwitchesJspServletToDevelopmentMode.

@Test
public void devToolsSwitchesJspServletToDevelopmentMode() {
    this.context = initializeAndRun(Config.class);
    TomcatWebServer tomcatContainer = (TomcatWebServer) ((ServletWebServerApplicationContext) this.context).getWebServer();
    Container context = tomcatContainer.getTomcat().getHost().findChildren()[0];
    StandardWrapper jspServletWrapper = (StandardWrapper) context.findChild("jsp");
    EmbeddedServletOptions options = (EmbeddedServletOptions) ReflectionTestUtils.getField(jspServletWrapper.getServlet(), "options");
    assertThat(options.getDevelopment()).isEqualTo(true);
}
Also used : Container(org.apache.catalina.Container) TomcatWebServer(org.springframework.boot.web.embedded.tomcat.TomcatWebServer) EmbeddedServletOptions(org.apache.jasper.EmbeddedServletOptions) StandardWrapper(org.apache.catalina.core.StandardWrapper) Test(org.junit.Test)

Example 2 with TomcatWebServer

use of org.springframework.boot.web.embedded.tomcat.TomcatWebServer in project spring-boot by spring-projects.

the class TomcatLegacyCookieProcessorExampleTests method cookieProcessorIsCustomized.

@Test
public void cookieProcessorIsCustomized() {
    ServletWebServerApplicationContext applicationContext = (ServletWebServerApplicationContext) new SpringApplication(TestConfiguration.class, LegacyCookieProcessorConfiguration.class).run();
    Context context = (Context) ((TomcatWebServer) applicationContext.getWebServer()).getTomcat().getHost().findChildren()[0];
    assertThat(context.getCookieProcessor()).isInstanceOf(LegacyCookieProcessor.class);
}
Also used : Context(org.apache.catalina.Context) ServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext) TomcatWebServer(org.springframework.boot.web.embedded.tomcat.TomcatWebServer) ServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext) SpringApplication(org.springframework.boot.SpringApplication) Test(org.junit.Test)

Example 3 with TomcatWebServer

use of org.springframework.boot.web.embedded.tomcat.TomcatWebServer in project spring-boot by spring-projects.

the class DefaultServletWebServerFactoryCustomizerTests method customTomcatBackgroundProcessorDelay.

@Test
public void customTomcatBackgroundProcessorDelay() throws Exception {
    Map<String, String> map = new HashMap<>();
    map.put("server.tomcat.background-processor-delay", "5");
    bindProperties(map);
    TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
    this.customizer.customize(factory);
    assertThat(((TomcatWebServer) factory.getWebServer()).getTomcat().getEngine().getBackgroundProcessorDelay()).isEqualTo(5);
}
Also used : TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) TomcatWebServer(org.springframework.boot.web.embedded.tomcat.TomcatWebServer) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 4 with TomcatWebServer

use of org.springframework.boot.web.embedded.tomcat.TomcatWebServer in project spring-boot by spring-projects.

the class DefaultServletWebServerFactoryCustomizerTests method defaultTomcatBackgroundProcessorDelay.

@Test
public void defaultTomcatBackgroundProcessorDelay() throws Exception {
    TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
    this.customizer.customize(factory);
    assertThat(((TomcatWebServer) factory.getWebServer()).getTomcat().getEngine().getBackgroundProcessorDelay()).isEqualTo(30);
}
Also used : TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) TomcatWebServer(org.springframework.boot.web.embedded.tomcat.TomcatWebServer) Test(org.junit.Test)

Example 5 with TomcatWebServer

use of org.springframework.boot.web.embedded.tomcat.TomcatWebServer in project spring-boot by spring-projects.

the class SampleTomcatApplicationTests method testTimeout.

@Test
public void testTimeout() throws Exception {
    ServletWebServerApplicationContext context = (ServletWebServerApplicationContext) this.applicationContext;
    TomcatWebServer embeddedServletContainer = (TomcatWebServer) context.getWebServer();
    ProtocolHandler protocolHandler = embeddedServletContainer.getTomcat().getConnector().getProtocolHandler();
    int timeout = ((AbstractProtocol<?>) protocolHandler).getConnectionTimeout();
    assertThat(timeout).isEqualTo(5000);
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) AbstractProtocol(org.apache.coyote.AbstractProtocol) TomcatWebServer(org.springframework.boot.web.embedded.tomcat.TomcatWebServer) ServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Test (org.junit.Test)8 TomcatWebServer (org.springframework.boot.web.embedded.tomcat.TomcatWebServer)8 TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory)5 HashMap (java.util.HashMap)4 AbstractProtocol (org.apache.coyote.AbstractProtocol)3 ServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext)2 Container (org.apache.catalina.Container)1 Context (org.apache.catalina.Context)1 StandardWrapper (org.apache.catalina.core.StandardWrapper)1 ProtocolHandler (org.apache.coyote.ProtocolHandler)1 EmbeddedServletOptions (org.apache.jasper.EmbeddedServletOptions)1 SpringApplication (org.springframework.boot.SpringApplication)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1