Commit 70c61381 authored by Andy Wilkinson's avatar Andy Wilkinson

Fix incomplete calls to assertThat

parent c1d7d5ec
...@@ -91,7 +91,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> { ...@@ -91,7 +91,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
public void basicArchiveCreation() throws IOException { public void basicArchiveCreation() throws IOException {
this.task.setMainClassName("com.example.Main"); this.task.setMainClassName("com.example.Main");
this.task.execute(); this.task.execute();
assertThat(this.task.getArchivePath().exists()); assertThat(this.task.getArchivePath()).exists();
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) { try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class")) assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class"))
.isEqualTo(this.launcherClass); .isEqualTo(this.launcherClass);
...@@ -226,7 +226,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> { ...@@ -226,7 +226,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this.task.getManifest().getAttributes().put("Main-Class", this.task.getManifest().getAttributes().put("Main-Class",
"com.example.CustomLauncher"); "com.example.CustomLauncher");
this.task.execute(); this.task.execute();
assertThat(this.task.getArchivePath().exists()); assertThat(this.task.getArchivePath()).exists();
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) { try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class")) assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class"))
.isEqualTo("com.example.CustomLauncher"); .isEqualTo("com.example.CustomLauncher");
...@@ -244,7 +244,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> { ...@@ -244,7 +244,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this.task.getManifest().getAttributes().put("Start-Class", this.task.getManifest().getAttributes().put("Start-Class",
"com.example.CustomMain"); "com.example.CustomMain");
this.task.execute(); this.task.execute();
assertThat(this.task.getArchivePath().exists()); assertThat(this.task.getArchivePath()).exists();
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) { try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class")) assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class"))
.isEqualTo(this.launcherClass); .isEqualTo(this.launcherClass);
...@@ -258,7 +258,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> { ...@@ -258,7 +258,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this.task.setMainClassName("com.example.Main"); this.task.setMainClassName("com.example.Main");
this.task.setPreserveFileTimestamps(false); this.task.setPreserveFileTimestamps(false);
this.task.execute(); this.task.execute();
assertThat(this.task.getArchivePath().exists()); assertThat(this.task.getArchivePath()).exists();
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) { try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
Enumeration<JarEntry> entries = jarFile.entries(); Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {
...@@ -276,7 +276,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> { ...@@ -276,7 +276,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this.temp.newFile("charlie.txt")); this.temp.newFile("charlie.txt"));
this.task.setReproducibleFileOrder(true); this.task.setReproducibleFileOrder(true);
this.task.execute(); this.task.execute();
assertThat(this.task.getArchivePath().exists()); assertThat(this.task.getArchivePath()).exists();
List<String> textFiles = new ArrayList<>(); List<String> textFiles = new ArrayList<>();
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) { try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
Enumeration<JarEntry> entries = jarFile.entries(); Enumeration<JarEntry> entries = jarFile.entries();
...@@ -295,7 +295,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> { ...@@ -295,7 +295,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this.task.setMainClassName("com.example.Main"); this.task.setMainClassName("com.example.Main");
this.task.classpath(this.temp.newFile("spring-boot-devtools-0.1.2.jar")); this.task.classpath(this.temp.newFile("spring-boot-devtools-0.1.2.jar"));
this.task.execute(); this.task.execute();
assertThat(this.task.getArchivePath().exists()); assertThat(this.task.getArchivePath()).exists();
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) { try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
assertThat(jarFile.getEntry(this.libPath + "/spring-boot-devtools-0.1.2.jar")) assertThat(jarFile.getEntry(this.libPath + "/spring-boot-devtools-0.1.2.jar"))
.isNull(); .isNull();
...@@ -308,7 +308,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> { ...@@ -308,7 +308,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this.task.classpath(this.temp.newFile("spring-boot-devtools-0.1.2.jar")); this.task.classpath(this.temp.newFile("spring-boot-devtools-0.1.2.jar"));
this.task.setExcludeDevtools(false); this.task.setExcludeDevtools(false);
this.task.execute(); this.task.execute();
assertThat(this.task.getArchivePath().exists()); assertThat(this.task.getArchivePath()).exists();
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) { try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
assertThat(jarFile.getEntry(this.libPath + "/spring-boot-devtools-0.1.2.jar")) assertThat(jarFile.getEntry(this.libPath + "/spring-boot-devtools-0.1.2.jar"))
.isNotNull(); .isNotNull();
......
...@@ -54,7 +54,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> { ...@@ -54,7 +54,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
getTask().setMainClassName("com.example.Main"); getTask().setMainClassName("com.example.Main");
getTask().providedClasspath(this.temp.newFile("spring-boot-devtools-0.1.2.jar")); getTask().providedClasspath(this.temp.newFile("spring-boot-devtools-0.1.2.jar"));
getTask().execute(); getTask().execute();
assertThat(getTask().getArchivePath().exists()); assertThat(getTask().getArchivePath()).exists();
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) { try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
assertThat(jarFile assertThat(jarFile
.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar")) .getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar"))
...@@ -69,7 +69,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> { ...@@ -69,7 +69,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
getTask().providedClasspath(this.temp.newFile("spring-boot-devtools-0.1.2.jar")); getTask().providedClasspath(this.temp.newFile("spring-boot-devtools-0.1.2.jar"));
getTask().setExcludeDevtools(false); getTask().setExcludeDevtools(false);
getTask().execute(); getTask().execute();
assertThat(getTask().getArchivePath().exists()); assertThat(getTask().getArchivePath()).exists();
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) { try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
assertThat(jarFile assertThat(jarFile
.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar")) .getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar"))
...@@ -87,7 +87,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> { ...@@ -87,7 +87,7 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
getTask().from(webappFolder); getTask().from(webappFolder);
getTask().setMainClassName("com.example.Main"); getTask().setMainClassName("com.example.Main");
getTask().execute(); getTask().execute();
assertThat(getTask().getArchivePath().exists()); assertThat(getTask().getArchivePath()).exists();
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) { try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
assertThat(jarFile.getEntry("org/")).isNotNull(); assertThat(jarFile.getEntry("org/")).isNotNull();
assertThat(jarFile.getEntry("org/foo.txt")).isNotNull(); assertThat(jarFile.getEntry("org/foo.txt")).isNotNull();
......
...@@ -32,7 +32,6 @@ import org.springframework.http.MediaType; ...@@ -32,7 +32,6 @@ import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
...@@ -103,7 +102,7 @@ public class UserVehicleControllerTests { ...@@ -103,7 +102,7 @@ public class UserVehicleControllerTests {
@Test(expected = NoSuchBeanDefinitionException.class) @Test(expected = NoSuchBeanDefinitionException.class)
public void welcomeCommandLineRunnerShouldBeAvailable() { public void welcomeCommandLineRunnerShouldBeAvailable() {
// Since we're a @WebMvcTest WelcomeCommandLineRunner should not be available. // Since we're a @WebMvcTest WelcomeCommandLineRunner should not be available.
assertThat(this.applicationContext.getBean(WelcomeCommandLineRunner.class)); this.applicationContext.getBean(WelcomeCommandLineRunner.class);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment