Polish "Add test to spring-boot-sample-quartz"

Closes gh-11621
pull/11643/merge
Stephane Nicoll 7 years ago
parent 5f1f04a33a
commit 51f0d88eec

@ -19,6 +19,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId> <artifactId>spring-boot-starter-quartz</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>

@ -19,7 +19,9 @@ package sample.quartz;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.test.rule.OutputCapture; import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.context.ConfigurableApplicationContext;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -35,9 +37,11 @@ public class SampleQuartzApplicationTests {
@Test @Test
public void test() { public void test() {
SampleQuartzApplication.main(new String[0]); try (ConfigurableApplicationContext context = SpringApplication.run(
SampleQuartzApplication.class)) {
String output = this.outputCapture.toString(); String output = this.outputCapture.toString();
assertThat(output).contains("Hello World!"); assertThat(output).contains("Hello World!");
} }
}
} }

Loading…
Cancel
Save