@ -17,9 +17,6 @@
@@ -17,9 +17,6 @@
package org.springframework.boot.actuate.autoconfigure ;
import org.junit.Test ;
import org.springframework.context.annotation.AnnotationConfigApplicationContext ;
import org.springframework.context.annotation.Bean ;
import org.springframework.context.annotation.Configuration ;
import static org.hamcrest.Matchers.equalTo ;
import static org.hamcrest.Matchers.nullValue ;
@ -29,37 +26,38 @@ import static org.junit.Assert.assertThat;
@@ -29,37 +26,38 @@ import static org.junit.Assert.assertThat;
* Tests for { @link ManagementServerPropertiesAutoConfiguration } .
*
* @author Phillip Webb
* @author Stephane Nicoll
* /
public class ManagementServerPropertiesAutoConfigurationTests {
@Test
public void defaultManagementServerProperties ( ) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext (
ManagementServerPropertiesAutoConfiguration . class ) ;
assertThat ( context . getBean ( ManagementServerProperties . class ) . getPort ( ) ,
nullValue ( ) ) ;
context . close ( ) ;
ManagementServerProperties properties = new ManagementServerProperties ( ) ;
assertThat ( properties . getPort ( ) , nullValue ( ) ) ;
assertThat ( properties . getContextPath ( ) , equalTo ( "" ) ) ;
}
@Test
public void definedManagementServerProperties ( ) throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext (
Config . class , ManagementServerPropertiesAutoConfiguration . class ) ;
assertThat ( context . getBean ( ManagementServerProperties . class ) . getPort ( ) ,
equalTo ( Integer . valueOf ( 123 ) ) ) ;
context . close ( ) ;
public void definedManagementServerProperties ( ) {
ManagementServerProperties properties = new ManagementServerProperties ( ) ;
properties . setPort ( 123 ) ;
properties . setContextPath ( "/foo" ) ;
assertThat ( properties . getPort ( ) , equalTo ( 123 ) ) ;
assertThat ( properties . getContextPath ( ) , equalTo ( "/foo" ) ) ;
}
@Configuration
public static class Config {
@Bean
public ManagementServerProperties managementServerProperties ( ) {
ManagementServerProperties properties = new ManagementServerProperties ( ) ;
properties . setPort ( 123 ) ;
return properties ;
}
@Test
public void trailingSlashOfContextPathIsRemoved ( ) {
ManagementServerProperties properties = new ManagementServerProperties ( ) ;
properties . setContextPath ( "/foo/" ) ;
assertThat ( properties . getContextPath ( ) , equalTo ( "/foo" ) ) ;
}
@Test
public void slashOfContextPathIsDefaultValue ( ) {
ManagementServerProperties properties = new ManagementServerProperties ( ) ;
properties . setContextPath ( "/" ) ;
assertThat ( properties . getContextPath ( ) , equalTo ( "" ) ) ;
}
}