Search in sources :

Example 1 with JettyServletWebServerFactory

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

the class DefaultServletWebServerFactoryCustomizerTests method deduceUseForwardHeadersJetty.

@Test
public void deduceUseForwardHeadersJetty() throws Exception {
    this.customizer.setEnvironment(new MockEnvironment().withProperty("DYNO", "-"));
    JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
    this.customizer.customize(factory);
    verify(factory).setUseForwardHeaders(true);
}
Also used : MockEnvironment(org.springframework.mock.env.MockEnvironment) JettyServletWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory) Test(org.junit.Test)

Example 2 with JettyServletWebServerFactory

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

the class DefaultServletWebServerFactoryCustomizerTests method setUseForwardHeadersJetty.

@Test
public void setUseForwardHeadersJetty() throws Exception {
    this.properties.setUseForwardHeaders(true);
    JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
    this.customizer.customize(factory);
    verify(factory).setUseForwardHeaders(true);
}
Also used : JettyServletWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory) Test(org.junit.Test)

Example 3 with JettyServletWebServerFactory

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

the class DefaultServletWebServerFactoryCustomizerTests method defaultUseForwardHeadersJetty.

@Test
public void defaultUseForwardHeadersJetty() throws Exception {
    JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
    this.customizer.customize(factory);
    verify(factory).setUseForwardHeaders(false);
}
Also used : JettyServletWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory) Test(org.junit.Test)

Example 4 with JettyServletWebServerFactory

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

the class DefaultServletWebServerFactoryCustomizerTests method sessionStoreDir.

@Test
public void sessionStoreDir() throws Exception {
    Map<String, String> map = new HashMap<>();
    map.put("server.session.store-dir", "myfolder");
    bindProperties(map);
    JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
    this.customizer.customize(factory);
    verify(factory).setSessionStoreDir(new File("myfolder"));
}
Also used : HashMap(java.util.HashMap) JettyServletWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory) File(java.io.File) Test(org.junit.Test)

Example 5 with JettyServletWebServerFactory

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

the class DefaultServletWebServerFactoryCustomizer method customize.

@Override
public void customize(ConfigurableServletWebServerFactory factory) {
    if (this.serverProperties.getPort() != null) {
        factory.setPort(this.serverProperties.getPort());
    }
    if (this.serverProperties.getAddress() != null) {
        factory.setAddress(this.serverProperties.getAddress());
    }
    if (this.serverProperties.getServlet().getContextPath() != null) {
        factory.setContextPath(this.serverProperties.getServlet().getContextPath());
    }
    if (this.serverProperties.getDisplayName() != null) {
        factory.setDisplayName(this.serverProperties.getDisplayName());
    }
    if (this.serverProperties.getSession().getTimeout() != null) {
        factory.setSessionTimeout(this.serverProperties.getSession().getTimeout());
    }
    factory.setPersistSession(this.serverProperties.getSession().isPersistent());
    factory.setSessionStoreDir(this.serverProperties.getSession().getStoreDir());
    if (this.serverProperties.getSsl() != null) {
        factory.setSsl(this.serverProperties.getSsl());
    }
    if (this.serverProperties.getServlet() != null) {
        factory.setJsp(this.serverProperties.getServlet().getJsp());
    }
    if (this.serverProperties.getCompression() != null) {
        factory.setCompression(this.serverProperties.getCompression());
    }
    factory.setServerHeader(this.serverProperties.getServerHeader());
    if (factory instanceof TomcatServletWebServerFactory) {
        TomcatCustomizer.customizeTomcat(this.serverProperties, this.environment, (TomcatServletWebServerFactory) factory);
    }
    if (factory instanceof JettyServletWebServerFactory) {
        JettyCustomizer.customizeJetty(this.serverProperties, this.environment, (JettyServletWebServerFactory) factory);
    }
    if (factory instanceof UndertowServletWebServerFactory) {
        UndertowCustomizer.customizeUndertow(this.serverProperties, this.environment, (UndertowServletWebServerFactory) factory);
    }
    factory.addInitializers(new SessionConfiguringInitializer(this.serverProperties.getSession()));
    factory.addInitializers(new InitParameterConfiguringServletContextInitializer(this.serverProperties.getServlet().getContextParameters()));
}
Also used : TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) JettyServletWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory) UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) InitParameterConfiguringServletContextInitializer(org.springframework.boot.web.servlet.server.InitParameterConfiguringServletContextInitializer)

Aggregations

JettyServletWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory)5 Test (org.junit.Test)4 File (java.io.File)1 HashMap (java.util.HashMap)1 TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory)1 UndertowServletWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory)1 InitParameterConfiguringServletContextInitializer (org.springframework.boot.web.servlet.server.InitParameterConfiguringServletContextInitializer)1 MockEnvironment (org.springframework.mock.env.MockEnvironment)1