Use AssertJ in spring-boot-samples

See gh-5083
This commit is contained in:
Phillip Webb
2016-02-06 14:53:10 -08:00
parent 962a598531
commit 1cc1fc6431
97 changed files with 580 additions and 733 deletions

View File

@@ -23,7 +23,7 @@ import org.junit.Test;
import org.springframework.boot.test.OutputCapture;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link SampleSimpleApplication}.
@@ -57,14 +57,14 @@ public class SampleSimpleApplicationTests {
public void testDefaultSettings() throws Exception {
SampleSimpleApplication.main(new String[0]);
String output = this.outputCapture.toString();
assertTrue("Wrong output: " + output, output.contains("Hello Phil"));
assertThat(output).contains("Hello Phil");
}
@Test
public void testCommandLineOverrides() throws Exception {
SampleSimpleApplication.main(new String[] { "--name=Gordon" });
String output = this.outputCapture.toString();
assertTrue("Wrong output: " + output, output.contains("Hello Gordon"));
assertThat(output).contains("Hello Gordon");
}
}

View File

@@ -24,8 +24,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link SampleSimpleApplication}.
@@ -41,9 +40,9 @@ public class SpringTestSampleSimpleApplicationTests {
@Test
public void testContextLoads() throws Exception {
assertNotNull(this.ctx);
assertTrue(this.ctx.containsBean("helloWorldService"));
assertTrue(this.ctx.containsBean("sampleSimpleApplication"));
assertThat(this.ctx).isNotNull();
assertThat(this.ctx.containsBean("helloWorldService")).isTrue();
assertThat(this.ctx.containsBean("sampleSimpleApplication")).isTrue();
}
}