Search in sources :

Example 1 with AbstractProtocol

use of org.apache.coyote.AbstractProtocol 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)

Example 2 with AbstractProtocol

use of org.apache.coyote.AbstractProtocol in project spring-boot by spring-projects.

the class DefaultServletWebServerFactoryCustomizerTests method customTomcatAcceptCount.

@Test
public void customTomcatAcceptCount() {
    Map<String, String> map = new HashMap<>();
    map.put("server.tomcat.accept-count", "10");
    bindProperties(map);
    TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
    this.customizer.customize(factory);
    TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
    embeddedFactory.start();
    try {
        assertThat(((AbstractProtocol<?>) embeddedFactory.getTomcat().getConnector().getProtocolHandler()).getBacklog()).isEqualTo(10);
    } finally {
        embeddedFactory.stop();
    }
}
Also used : TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) AbstractProtocol(org.apache.coyote.AbstractProtocol) TomcatWebServer(org.springframework.boot.web.embedded.tomcat.TomcatWebServer) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 3 with AbstractProtocol

use of org.apache.coyote.AbstractProtocol in project spring-boot by spring-projects.

the class DefaultServletWebServerFactoryCustomizerTests method customTomcatMaxConnections.

@Test
public void customTomcatMaxConnections() {
    Map<String, String> map = new HashMap<>();
    map.put("server.tomcat.max-connections", "5");
    bindProperties(map);
    TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
    this.customizer.customize(factory);
    TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
    embeddedFactory.start();
    try {
        assertThat(((AbstractProtocol<?>) embeddedFactory.getTomcat().getConnector().getProtocolHandler()).getMaxConnections()).isEqualTo(5);
    } finally {
        embeddedFactory.stop();
    }
}
Also used : TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) AbstractProtocol(org.apache.coyote.AbstractProtocol) TomcatWebServer(org.springframework.boot.web.embedded.tomcat.TomcatWebServer) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

AbstractProtocol (org.apache.coyote.AbstractProtocol)3 Test (org.junit.Test)3 TomcatWebServer (org.springframework.boot.web.embedded.tomcat.TomcatWebServer)3 HashMap (java.util.HashMap)2 TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory)2 ProtocolHandler (org.apache.coyote.ProtocolHandler)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 ServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext)1