Skip to content

Commit

Permalink
Polish BannerTests
Browse files Browse the repository at this point in the history
  • Loading branch information
dreis2211 authored and philwebb committed Feb 13, 2018
1 parent a9eefae commit cd0c5ba
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -71,41 +71,36 @@ public void setup() {

@Test
public void testDefaultBanner() {
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
SpringApplication application = createSpringApplication();
this.context = application.run();
assertThat(this.out.toString()).contains(":: Spring Boot ::");
}

@Test
public void testDefaultBannerInLog() {
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
SpringApplication application = createSpringApplication();
this.context = application.run();
assertThat(this.out.toString()).contains(":: Spring Boot ::");
}

@Test
public void testCustomBanner() {
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
SpringApplication application = createSpringApplication();
application.setBanner(new DummyBanner());
this.context = application.run();
assertThat(this.out.toString()).contains("My Banner");
}

@Test
public void testBannerInContext() {
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
SpringApplication application = createSpringApplication();
this.context = application.run();
assertThat(this.context.containsBean("springBootBanner")).isTrue();
}

@Test
public void testCustomBannerInContext() {
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
SpringApplication application = createSpringApplication();
Banner banner = mock(Banner.class);
application.setBanner(banner);
this.context = application.run();
Expand All @@ -122,13 +117,18 @@ public void testCustomBannerInContext() {

@Test
public void testDisableBannerInContext() {
SpringApplication application = new SpringApplication(Config.class);
SpringApplication application = createSpringApplication();
application.setBannerMode(Mode.OFF);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run();
assertThat(this.context.containsBean("springBootBanner")).isFalse();
}

private SpringApplication createSpringApplication() {
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
return application;
}

static class DummyBanner implements Banner {

@Override
Expand Down

0 comments on commit cd0c5ba

Please sign in to comment.