@ -41,6 +41,7 @@ import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletCont
import org.springframework.boot.context.embedded.ServletContextInitializer ;
import org.springframework.boot.context.embedded.ServletContextInitializer ;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory ;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory ;
import static org.hamcrest.Matchers.equalTo ;
import static org.hamcrest.core.IsInstanceOf.instanceOf ;
import static org.hamcrest.core.IsInstanceOf.instanceOf ;
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertFalse ;
import static org.junit.Assert.assertFalse ;
@ -123,6 +124,20 @@ public class ServerPropertiesTests {
. getInternalProxies ( ) ) ;
. getInternalProxies ( ) ) ;
}
}
@Test
public void testTrailingSlashOfContextPathIsRemoved ( ) {
new RelaxedDataBinder ( this . properties , "server" ) . bind ( new MutablePropertyValues (
Collections . singletonMap ( "server.contextPath" , "/foo/" ) ) ) ;
assertThat ( this . properties . getContextPath ( ) , equalTo ( "/foo" ) ) ;
}
@Test
public void testSlashOfContextPathIsDefaultValue ( ) {
new RelaxedDataBinder ( this . properties , "server" ) . bind ( new MutablePropertyValues (
Collections . singletonMap ( "server.contextPath" , "/" ) ) ) ;
assertThat ( this . properties . getContextPath ( ) , equalTo ( "" ) ) ;
}
@Test
@Test
public void testCustomizeTomcat ( ) throws Exception {
public void testCustomizeTomcat ( ) throws Exception {
ConfigurableEmbeddedServletContainer factory = mock ( ConfigurableEmbeddedServletContainer . class ) ;
ConfigurableEmbeddedServletContainer factory = mock ( ConfigurableEmbeddedServletContainer . class ) ;