@ -108,9 +108,16 @@ public class EndpointWebMvcAutoConfigurationTests {
private static ThreadLocal < Ports > ports = new ThreadLocal < Ports > ( ) ;
private static ThreadLocal < Ports > ports = new ThreadLocal < Ports > ( ) ;
private static ServerProperties server = new ServerProperties ( ) ;
private static ManagementServerProperties management = new ManagementServerProperties ( ) ;
@Before
@Before
public void grabPorts ( ) {
public void grabPorts ( ) {
ports . set ( new Ports ( ) ) ;
Ports values = new Ports ( ) ;
ports . set ( values ) ;
server . setPort ( values . server ) ;
management . setPort ( values . management ) ;
}
}
@After
@After
@ -171,8 +178,7 @@ public class EndpointWebMvcAutoConfigurationTests {
this . applicationContext . register ( RootConfig . class , EndpointConfig . class ,
this . applicationContext . register ( RootConfig . class , EndpointConfig . class ,
DifferentPortConfig . class , BaseConfiguration . class ,
DifferentPortConfig . class , BaseConfiguration . class ,
EndpointWebMvcAutoConfiguration . class , ErrorMvcAutoConfiguration . class ) ;
EndpointWebMvcAutoConfiguration . class , ErrorMvcAutoConfiguration . class ) ;
EnvironmentTestUtils . addEnvironment ( this . applicationContext ,
management . setContextPath ( "/admin" ) ;
"management.context-path=/admin" ) ;
this . applicationContext . refresh ( ) ;
this . applicationContext . refresh ( ) ;
assertContent ( "/controller" , ports . get ( ) . server , "controlleroutput" ) ;
assertContent ( "/controller" , ports . get ( ) . server , "controlleroutput" ) ;
assertContent ( "/admin/endpoint" , ports . get ( ) . management , "endpointoutput" ) ;
assertContent ( "/admin/endpoint" , ports . get ( ) . management , "endpointoutput" ) ;
@ -186,8 +192,8 @@ public class EndpointWebMvcAutoConfigurationTests {
this . applicationContext . register ( RootConfig . class , EndpointConfig . class ,
this . applicationContext . register ( RootConfig . class , EndpointConfig . class ,
DifferentPortConfig . class , BaseConfiguration . class ,
DifferentPortConfig . class , BaseConfiguration . class ,
EndpointWebMvcAutoConfiguration . class , ErrorMvcAutoConfiguration . class ) ;
EndpointWebMvcAutoConfiguration . class , ErrorMvcAutoConfiguration . class ) ;
EnvironmentTestUtils. addEnvironment ( this . applicationContext ,
management. setContextPath ( "/admin" ) ;
"management.context-path=/admin" , "server.context-path= /spring") ;
server . setContextPath ( " /spring") ;
this . applicationContext . refresh ( ) ;
this . applicationContext . refresh ( ) ;
assertContent ( "/spring/controller" , ports . get ( ) . server , "controlleroutput" ) ;
assertContent ( "/spring/controller" , ports . get ( ) . server , "controlleroutput" ) ;
assertContent ( "/admin/endpoint" , ports . get ( ) . management , "endpointoutput" ) ;
assertContent ( "/admin/endpoint" , ports . get ( ) . management , "endpointoutput" ) ;
@ -506,9 +512,9 @@ public class EndpointWebMvcAutoConfigurationTests {
EmbeddedServletContainerAutoConfiguration . class ,
EmbeddedServletContainerAutoConfiguration . class ,
JacksonAutoConfiguration . class , EndpointAutoConfiguration . class ,
JacksonAutoConfiguration . class , EndpointAutoConfiguration . class ,
HttpMessageConvertersAutoConfiguration . class ,
HttpMessageConvertersAutoConfiguration . class ,
DispatcherServletAutoConfiguration . class ,
DispatcherServletAutoConfiguration . class , WebMvcAutoConfiguration . class ,
ManagementServerPropertiesAutoConfiguration . class ,
ManagementServerPropertiesAutoConfiguration . class ,
ServerPropertiesAutoConfiguration . class , WebMvcAutoConfiguration . class } )
ServerPropertiesAutoConfiguration . class } )
protected static class BaseConfiguration {
protected static class BaseConfiguration {
}
}
@ -551,7 +557,8 @@ public class EndpointWebMvcAutoConfigurationTests {
super . customize ( container ) ;
super . customize ( container ) ;
}
}
} ;
} ;
properties . setPort ( ports . get ( ) . server ) ;
properties . setPort ( server . getPort ( ) ) ;
properties . setContextPath ( server . getContextPath ( ) ) ;
return properties ;
return properties ;
}
}
@ -574,9 +581,7 @@ public class EndpointWebMvcAutoConfigurationTests {
@Bean
@Bean
public ManagementServerProperties managementServerProperties ( ) {
public ManagementServerProperties managementServerProperties ( ) {
ManagementServerProperties properties = new ManagementServerProperties ( ) ;
return management ;
properties . setPort ( ports . get ( ) . management ) ;
return properties ;
}
}
@Bean
@Bean