@Test public void redirectContextRootCanBeConfigured() throws Exception { Map<String, String> map = new HashMap<String, String>(); map.put("server.tomcat.redirect-context-root", "false"); bindProperties(map); ServerProperties.Tomcat tomcat = this.properties.getTomcat(); assertThat(tomcat.getRedirectContextRoot()).isEqualTo(false); TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); this.properties.customize(container); Context context = mock(Context.class); for (TomcatContextCustomizer customizer : container.getTomcatContextCustomizers()) { customizer.customize(context); } verify(context).setMapperContextRootRedirectEnabled(false); }
@Test public void testTomcatBinding() throws Exception { Map<String, String> map = new HashMap<String, String>(); map.put("server.tomcat.accesslog.pattern", "%h %t '%r' %s %b"); map.put("server.tomcat.accesslog.prefix", "foo"); map.put("server.tomcat.accesslog.rename-on-rotate", "true"); map.put("server.tomcat.accesslog.suffix", "-bar.log"); map.put("server.tomcat.protocol_header", "X-Forwarded-Protocol"); map.put("server.tomcat.remote_ip_header", "Remote-Ip"); map.put("server.tomcat.internal_proxies", "10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"); map.put("server.tomcat.background_processor_delay", "10"); bindProperties(map); ServerProperties.Tomcat tomcat = this.properties.getTomcat(); assertThat(tomcat.getAccesslog().getPattern()).isEqualTo("%h %t '%r' %s %b"); assertThat(tomcat.getAccesslog().getPrefix()).isEqualTo("foo"); assertThat(tomcat.getAccesslog().isRenameOnRotate()).isTrue(); assertThat(tomcat.getAccesslog().getSuffix()).isEqualTo("-bar.log"); assertThat(tomcat.getRemoteIpHeader()).isEqualTo("Remote-Ip"); assertThat(tomcat.getProtocolHeader()).isEqualTo("X-Forwarded-Protocol"); assertThat(tomcat.getInternalProxies()).isEqualTo("10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"); assertThat(tomcat.getBackgroundProcessorDelay()).isEqualTo(10); }
@Test public void redirectContextRootIsNotConfiguredByDefault() throws Exception { bindProperties(new HashMap<String, String>()); ServerProperties.Tomcat tomcat = this.properties.getTomcat(); assertThat(tomcat.getRedirectContextRoot()).isNull(); }