@ -163,19 +163,37 @@ public class SpringApplicationTests {
}
}
@Test
@Test
public void disableBanner ( ) throws Exception {
public void disableBannerWithMode ( ) throws Exception {
SpringApplication application = spy ( new SpringApplication ( ExampleConfig . class ) ) ;
SpringApplication application = spy ( new SpringApplication ( ExampleConfig . class ) ) ;
application . setWebEnvironment ( false ) ;
application . setWebEnvironment ( false ) ;
application . setShow Banner ( Banner . Mode . OFF ) ;
application . setBannerMode ( Banner . Mode . OFF ) ;
this . context = application . run ( ) ;
this . context = application . run ( ) ;
verify ( application , never ( ) ) . printBanner ( ( Environment ) anyObject ( ) ) ;
verify ( application , never ( ) ) . printBanner ( ( Environment ) anyObject ( ) ) ;
}
}
@SuppressWarnings ( "deprecation" )
@Test
@Test
public void disableBannerViaProperty ( ) throws Exception {
public void disableBannerWithBoolean ( ) throws Exception {
SpringApplication application = spy ( new SpringApplication ( ExampleConfig . class ) ) ;
SpringApplication application = spy ( new SpringApplication ( ExampleConfig . class ) ) ;
application . setWebEnvironment ( false ) ;
application . setWebEnvironment ( false ) ;
this . context = application . run ( "--spring.main.show_banner=OFF" ) ;
application . setShowBanner ( false ) ;
this . context = application . run ( ) ;
verify ( application , never ( ) ) . printBanner ( ( Environment ) anyObject ( ) ) ;
}
@Test
public void disableBannerViaShowBannerProperty ( ) throws Exception {
SpringApplication application = spy ( new SpringApplication ( ExampleConfig . class ) ) ;
application . setWebEnvironment ( false ) ;
this . context = application . run ( "--spring.main.show_banner=false" ) ;
verify ( application , never ( ) ) . printBanner ( ( Environment ) anyObject ( ) ) ;
}
@Test
public void disableBannerViaBannerModeProperty ( ) throws Exception {
SpringApplication application = spy ( new SpringApplication ( ExampleConfig . class ) ) ;
application . setWebEnvironment ( false ) ;
this . context = application . run ( "--spring.main.banner-mode=off" ) ;
verify ( application , never ( ) ) . printBanner ( ( Environment ) anyObject ( ) ) ;
verify ( application , never ( ) ) . printBanner ( ( Environment ) anyObject ( ) ) ;
}
}
@ -219,17 +237,8 @@ public class SpringApplicationTests {
public void enableBannerInLogViaProperty ( ) throws Exception {
public void enableBannerInLogViaProperty ( ) throws Exception {
SpringApplication application = spy ( new SpringApplication ( ExampleConfig . class ) ) ;
SpringApplication application = spy ( new SpringApplication ( ExampleConfig . class ) ) ;
application . setWebEnvironment ( false ) ;
application . setWebEnvironment ( false ) ;
this . context = application . run ( "--spring.main.show_banner=LOG" ) ;
this . context = application . run ( "--spring.main.banner-mode=log" ) ;
verify ( application , atLeastOnce ( ) ) . setShowBanner ( Banner . Mode . LOG ) ;
verify ( application , atLeastOnce ( ) ) . setBannerMode ( Banner . Mode . LOG ) ;
}
@Test
public void verifyBannerOutputContainsLogInfo ( ) throws Exception {
SpringApplication application = spy ( new SpringApplication ( ExampleConfig . class ) ) ;
application . setWebEnvironment ( false ) ;
application . run ( "--spring.main.show_banner=LOG" ,
"--banner.location=classpath:test-banner.txt" ) ;
verify ( application , atLeastOnce ( ) ) . setShowBanner ( Banner . Mode . LOG ) ;
assertThat ( this . output . toString ( ) , containsString ( "o.s.boot.SpringApplication" ) ) ;
assertThat ( this . output . toString ( ) , containsString ( "o.s.boot.SpringApplication" ) ) ;
}
}
@ -565,8 +574,8 @@ public class SpringApplicationTests {
TestSpringApplication application = new TestSpringApplication (
TestSpringApplication application = new TestSpringApplication (
ExampleConfig . class ) ;
ExampleConfig . class ) ;
application . setWebEnvironment ( false ) ;
application . setWebEnvironment ( false ) ;
this . context = application . run ( "--spring.main.show_ banner=OFF" ) ;
this . context = application . run ( "--spring.main.banner-mode =OFF" ) ;
assertThat ( application . getShow Banner ( ) , is ( Banner . Mode . OFF ) ) ;
assertThat ( application . getBannerMode ( ) , is ( Banner . Mode . OFF ) ) ;
}
}
@Test
@Test
@ -733,7 +742,7 @@ public class SpringApplicationTests {
private boolean useMockLoader ;
private boolean useMockLoader ;
private Banner . Mode showBanner ;
private Banner . Mode bannerMode ;
TestSpringApplication ( Object . . . sources ) {
TestSpringApplication ( Object . . . sources ) {
super ( sources ) ;
super ( sources ) ;
@ -764,13 +773,13 @@ public class SpringApplicationTests {
}
}
@Override
@Override
public void setShow Banner ( Banner . Mode bannerMode ) {
public void setBannerMode ( Banner . Mode bannerMode ) {
super . setShow Banner ( bannerMode ) ;
super . setBannerMode ( bannerMode ) ;
this . showBanner = bannerMode ;
this . bannerMode = bannerMode ;
}
}
public Banner . Mode getShow Banner ( ) {
public Banner . Mode getBannerMode ( ) {
return this . showBanner ;
return this . bannerMode ;
}
}
}
}