Search in sources :

Example 11 with JettyWebServer

use of org.springframework.boot.web.embedded.jetty.JettyWebServer in project spring-boot by spring-projects.

the class JettyWebServerFactoryCustomizerTests method threadPoolMinThreadsCanBeCustomized.

@Test
void threadPoolMinThreadsCanBeCustomized() {
    bind("server.jetty.threads.min=100");
    JettyWebServer server = customizeAndGetServer();
    QueuedThreadPool threadPool = (QueuedThreadPool) server.getServer().getThreadPool();
    assertThat(threadPool.getMinThreads()).isEqualTo(100);
}
Also used : QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) JettyWebServer(org.springframework.boot.web.embedded.jetty.JettyWebServer) Test(org.junit.jupiter.api.Test)

Example 12 with JettyWebServer

use of org.springframework.boot.web.embedded.jetty.JettyWebServer in project spring-boot by spring-projects.

the class JettyWebServerFactoryCustomizerTests method getRequestHeaderSizes.

private List<Integer> getRequestHeaderSizes(JettyWebServer server) {
    List<Integer> requestHeaderSizes = new ArrayList<>();
    // Start (and directly stop) server to have connectors available
    server.start();
    server.stop();
    Connector[] connectors = server.getServer().getConnectors();
    for (Connector connector : connectors) {
        connector.getConnectionFactories().stream().filter((factory) -> factory instanceof ConnectionFactory).forEach((cf) -> {
            ConnectionFactory factory = (ConnectionFactory) cf;
            HttpConfiguration configuration = factory.getHttpConfiguration();
            requestHeaderSizes.add(configuration.getRequestHeaderSize());
        });
    }
    return requestHeaderSizes;
}
Also used : AbstractConnector(org.eclipse.jetty.server.AbstractConnector) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JettyWebServer(org.springframework.boot.web.embedded.jetty.JettyWebServer) ArrayList(java.util.ArrayList) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) Duration(java.time.Duration) ConfigurationPropertySources(org.springframework.boot.context.properties.source.ConfigurationPropertySources) JettyServletWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory) ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties) Server(org.eclipse.jetty.server.Server) BlockingArrayQueue(org.eclipse.jetty.util.BlockingArrayQueue) ConnectionFactory(org.eclipse.jetty.server.HttpConfiguration.ConnectionFactory) Bindable(org.springframework.boot.context.properties.bind.Bindable) RequestLog(org.eclipse.jetty.server.RequestLog) SynchronousQueue(java.util.concurrent.SynchronousQueue) RequestLogWriter(org.eclipse.jetty.server.RequestLogWriter) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) BDDMockito.then(org.mockito.BDDMockito.then) IOException(java.io.IOException) BlockingQueue(java.util.concurrent.BlockingQueue) ForwardHeadersStrategy(org.springframework.boot.autoconfigure.web.ServerProperties.ForwardHeadersStrategy) Collectors(java.util.stream.Collectors) File(java.io.File) ThreadPool(org.eclipse.jetty.util.thread.ThreadPool) Test(org.junit.jupiter.api.Test) List(java.util.List) ConfigurableJettyWebServerFactory(org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory) TestPropertySourceUtils(org.springframework.test.context.support.TestPropertySourceUtils) CustomRequestLog(org.eclipse.jetty.server.CustomRequestLog) Binder(org.springframework.boot.context.properties.bind.Binder) Connector(org.eclipse.jetty.server.Connector) Jetty(org.springframework.boot.autoconfigure.web.ServerProperties.Jetty) MockEnvironment(org.springframework.mock.env.MockEnvironment) Mockito.mock(org.mockito.Mockito.mock) AbstractConnector(org.eclipse.jetty.server.AbstractConnector) Connector(org.eclipse.jetty.server.Connector) ConnectionFactory(org.eclipse.jetty.server.HttpConfiguration.ConnectionFactory) ArrayList(java.util.ArrayList) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Example 13 with JettyWebServer

use of org.springframework.boot.web.embedded.jetty.JettyWebServer in project spring-boot by spring-projects.

the class JettyWebServerFactoryCustomizerTests method customIdleTimeout.

@Test
void customIdleTimeout() {
    bind("server.jetty.connection-idle-timeout=60s");
    JettyWebServer server = customizeAndGetServer();
    List<Long> timeouts = connectorsIdleTimeouts(server);
    assertThat(timeouts).containsOnly(60000L);
}
Also used : JettyWebServer(org.springframework.boot.web.embedded.jetty.JettyWebServer) Test(org.junit.jupiter.api.Test)

Example 14 with JettyWebServer

use of org.springframework.boot.web.embedded.jetty.JettyWebServer in project spring-boot by spring-projects.

the class JettyWebServerFactoryCustomizerTests method accessLogCanBeEnabled.

@Test
void accessLogCanBeEnabled() {
    bind("server.jetty.accesslog.enabled=true");
    JettyWebServer server = customizeAndGetServer();
    CustomRequestLog requestLog = getRequestLog(server);
    assertThat(requestLog.getFormatString()).isEqualTo(CustomRequestLog.NCSA_FORMAT);
    assertThat(requestLog.getIgnorePaths()).isNull();
    RequestLogWriter logWriter = getLogWriter(requestLog);
    assertThat(logWriter.getFileName()).isNull();
    assertThat(logWriter.isAppend()).isFalse();
}
Also used : CustomRequestLog(org.eclipse.jetty.server.CustomRequestLog) RequestLogWriter(org.eclipse.jetty.server.RequestLogWriter) JettyWebServer(org.springframework.boot.web.embedded.jetty.JettyWebServer) Test(org.junit.jupiter.api.Test)

Example 15 with JettyWebServer

use of org.springframework.boot.web.embedded.jetty.JettyWebServer in project spring-boot by spring-projects.

the class JettyWebServerFactoryCustomizerTests method threadPoolMaxThreadsCanBeCustomized.

@Test
void threadPoolMaxThreadsCanBeCustomized() {
    bind("server.jetty.threads.max=100");
    JettyWebServer server = customizeAndGetServer();
    QueuedThreadPool threadPool = (QueuedThreadPool) server.getServer().getThreadPool();
    assertThat(threadPool.getMaxThreads()).isEqualTo(100);
}
Also used : QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) JettyWebServer(org.springframework.boot.web.embedded.jetty.JettyWebServer) Test(org.junit.jupiter.api.Test)

Aggregations

JettyWebServer (org.springframework.boot.web.embedded.jetty.JettyWebServer)17 Test (org.junit.jupiter.api.Test)16 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)9 JettyServletWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory)4 CustomRequestLog (org.eclipse.jetty.server.CustomRequestLog)3 RequestLogWriter (org.eclipse.jetty.server.RequestLogWriter)3 Server (org.eclipse.jetty.server.Server)3 ThreadPool (org.eclipse.jetty.util.thread.ThreadPool)3 File (java.io.File)2 IOException (java.io.IOException)2 AbstractEndpoint (org.apache.tomcat.util.net.AbstractEndpoint)2 BlockingArrayQueue (org.eclipse.jetty.util.BlockingArrayQueue)2 ServletException (jakarta.servlet.ServletException)1 HttpServlet (jakarta.servlet.http.HttpServlet)1 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1