Search in sources :

Example 1 with ServletWebServerApplicationContext

use of org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext 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 2 with ServletWebServerApplicationContext

use of org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext in project spring-boot by spring-projects.

the class EmbeddedServerPortFileWriterTests method mockEvent.

private ServletWebServerInitializedEvent mockEvent(String name, int port) {
    ServletWebServerApplicationContext applicationContext = mock(ServletWebServerApplicationContext.class);
    WebServer source = mock(WebServer.class);
    given(applicationContext.getNamespace()).willReturn(name);
    given(source.getPort()).willReturn(port);
    ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent(applicationContext, source);
    return event;
}
Also used : WebServer(org.springframework.boot.web.server.WebServer) ServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext) ServletWebServerInitializedEvent(org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent)

Example 3 with ServletWebServerApplicationContext

use of org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext 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

ServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext)3 Test (org.junit.Test)2 TomcatWebServer (org.springframework.boot.web.embedded.tomcat.TomcatWebServer)2 Context (org.apache.catalina.Context)1 AbstractProtocol (org.apache.coyote.AbstractProtocol)1 ProtocolHandler (org.apache.coyote.ProtocolHandler)1 SpringApplication (org.springframework.boot.SpringApplication)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 WebServer (org.springframework.boot.web.server.WebServer)1 ServletWebServerInitializedEvent (org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent)1