Use AssertJ in spring-boot-tools

See gh-5083
This commit is contained in:
Phillip Webb
2016-02-06 14:53:00 -08:00
parent 7f9358f4d8
commit 00cfe1d054
37 changed files with 1326 additions and 1402 deletions

View File

@@ -26,9 +26,7 @@ import org.junit.rules.TemporaryFolder;
import org.springframework.util.FileCopyUtils;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link DefaultLaunchScript}.
@@ -45,7 +43,7 @@ public class DefaultLaunchScriptTests {
public void loadsDefaultScript() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null);
String content = new String(script.toByteArray());
assertThat(content, containsString("Spring Boot Startup Script"));
assertThat(content).contains("Spring Boot Startup Script");
}
@Test
@@ -82,14 +80,14 @@ public class DefaultLaunchScriptTests {
public void defaultForUseStartStopDaemonIsTrue() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null);
String content = new String(script.toByteArray());
assertThat(content, containsString("USE_START_STOP_DAEMON=\"true\""));
assertThat(content).contains("USE_START_STOP_DAEMON=\"true\"");
}
@Test
public void defaultForModeIsAuto() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null);
String content = new String(script.toByteArray());
assertThat(content, containsString("MODE=\"auto\""));
assertThat(content).contains("MODE=\"auto\"");
}
@Test
@@ -98,7 +96,7 @@ public class DefaultLaunchScriptTests {
FileCopyUtils.copy("ABC".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, null);
String content = new String(script.toByteArray());
assertThat(content, equalTo("ABC"));
assertThat(content).isEqualTo("ABC");
}
@Test
@@ -108,7 +106,7 @@ public class DefaultLaunchScriptTests {
DefaultLaunchScript script = new DefaultLaunchScript(file,
createProperties("a:e", "b:o"));
String content = new String(script.toByteArray());
assertThat(content, equalTo("hello"));
assertThat(content).isEqualTo("hello");
}
@Test
@@ -118,7 +116,7 @@ public class DefaultLaunchScriptTests {
DefaultLaunchScript script = new DefaultLaunchScript(file,
createProperties("a:e", "b:o"));
String content = new String(script.toByteArray());
assertThat(content, equalTo("hel\nlo"));
assertThat(content).isEqualTo("hel\nlo");
}
@Test
@@ -127,7 +125,7 @@ public class DefaultLaunchScriptTests {
FileCopyUtils.copy("h{{a:e}}ll{{b:o}}".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, null);
String content = new String(script.toByteArray());
assertThat(content, equalTo("hello"));
assertThat(content).isEqualTo("hello");
}
@Test
@@ -137,7 +135,7 @@ public class DefaultLaunchScriptTests {
DefaultLaunchScript script = new DefaultLaunchScript(file,
createProperties("a:a"));
String content = new String(script.toByteArray());
assertThat(content, equalTo("hallo"));
assertThat(content).isEqualTo("hallo");
}
@Test
@@ -146,14 +144,14 @@ public class DefaultLaunchScriptTests {
FileCopyUtils.copy("h{{a}}ll{{b}}".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, null);
String content = new String(script.toByteArray());
assertThat(content, equalTo("h{{a}}ll{{b}}"));
assertThat(content).isEqualTo("h{{a}}ll{{b}}");
}
private void assertThatPlaceholderCanBeReplaced(String placeholder) throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null,
createProperties(placeholder + ":__test__"));
String content = new String(script.toByteArray());
assertThat(content, containsString("__test__"));
assertThat(content).contains("__test__");
}
private Map<?, ?> createProperties(String... pairs) {

View File

@@ -28,10 +28,7 @@ import org.junit.rules.TemporaryFolder;
import org.springframework.util.FileSystemUtils;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link FileUtils}.
@@ -65,31 +62,31 @@ public class FileUtilsTests {
new File(this.originDirectory, "logback.xml").createNewFile();
FileUtils.removeDuplicatesFromOutputDirectory(this.outputDirectory,
this.originDirectory);
assertFalse(file.exists());
assertThat(file.exists()).isFalse();
}
@Test
public void nestedDuplicateFile() throws IOException {
assertTrue(new File(this.outputDirectory, "sub").mkdirs());
assertTrue(new File(this.originDirectory, "sub").mkdirs());
assertThat(new File(this.outputDirectory, "sub").mkdirs()).isTrue();
assertThat(new File(this.originDirectory, "sub").mkdirs()).isTrue();
File file = new File(this.outputDirectory, "sub/logback.xml");
file.createNewFile();
new File(this.originDirectory, "sub/logback.xml").createNewFile();
FileUtils.removeDuplicatesFromOutputDirectory(this.outputDirectory,
this.originDirectory);
assertFalse(file.exists());
assertThat(file.exists()).isFalse();
}
@Test
public void nestedNonDuplicateFile() throws IOException {
assertTrue(new File(this.outputDirectory, "sub").mkdirs());
assertTrue(new File(this.originDirectory, "sub").mkdirs());
assertThat(new File(this.outputDirectory, "sub").mkdirs()).isTrue();
assertThat(new File(this.originDirectory, "sub").mkdirs()).isTrue();
File file = new File(this.outputDirectory, "sub/logback.xml");
file.createNewFile();
new File(this.originDirectory, "sub/different.xml").createNewFile();
FileUtils.removeDuplicatesFromOutputDirectory(this.outputDirectory,
this.originDirectory);
assertTrue(file.exists());
assertThat(file.exists()).isTrue();
}
@Test
@@ -99,7 +96,7 @@ public class FileUtilsTests {
new File(this.originDirectory, "different.xml").createNewFile();
FileUtils.removeDuplicatesFromOutputDirectory(this.outputDirectory,
this.originDirectory);
assertTrue(file.exists());
assertThat(file.exists()).isTrue();
}
@Test
@@ -112,8 +109,8 @@ public class FileUtilsTests {
finally {
outputStream.close();
}
assertThat(FileUtils.sha1Hash(file),
equalTo("7037807198c22a7d2b0807371d763779a84fdfcf"));
assertThat(FileUtils.sha1Hash(file))
.isEqualTo("7037807198c22a7d2b0807371d763779a84fdfcf");
}
}

View File

@@ -21,9 +21,7 @@ import java.net.URL;
import org.junit.Test;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link JvmUtils}.
@@ -36,8 +34,8 @@ public class JvmUtilsTests {
public void getToolsJar() throws Exception {
URL jarUrl = JvmUtils.getToolsJarUrl();
// System.out.println(jarUrl);
assertThat(jarUrl.toString(), endsWith(".jar"));
assertThat(new File(jarUrl.toURI()).exists(), equalTo(true));
assertThat(jarUrl.toString()).endsWith(".jar");
assertThat(new File(jarUrl.toURI()).exists()).isTrue();
}
}

View File

@@ -22,10 +22,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link Layouts}.
@@ -40,18 +37,20 @@ public class LayoutsTests {
@Test
public void jarFile() throws Exception {
assertThat(Layouts.forFile(new File("test.jar")), instanceOf(Layouts.Jar.class));
assertThat(Layouts.forFile(new File("test.JAR")), instanceOf(Layouts.Jar.class));
assertThat(Layouts.forFile(new File("test.jAr")), instanceOf(Layouts.Jar.class));
assertThat(Layouts.forFile(new File("te.st.jar")), instanceOf(Layouts.Jar.class));
assertThat(Layouts.forFile(new File("test.jar"))).isInstanceOf(Layouts.Jar.class);
assertThat(Layouts.forFile(new File("test.JAR"))).isInstanceOf(Layouts.Jar.class);
assertThat(Layouts.forFile(new File("test.jAr"))).isInstanceOf(Layouts.Jar.class);
assertThat(Layouts.forFile(new File("te.st.jar")))
.isInstanceOf(Layouts.Jar.class);
}
@Test
public void warFile() throws Exception {
assertThat(Layouts.forFile(new File("test.war")), instanceOf(Layouts.War.class));
assertThat(Layouts.forFile(new File("test.WAR")), instanceOf(Layouts.War.class));
assertThat(Layouts.forFile(new File("test.wAr")), instanceOf(Layouts.War.class));
assertThat(Layouts.forFile(new File("te.st.war")), instanceOf(Layouts.War.class));
assertThat(Layouts.forFile(new File("test.war"))).isInstanceOf(Layouts.War.class);
assertThat(Layouts.forFile(new File("test.WAR"))).isInstanceOf(Layouts.War.class);
assertThat(Layouts.forFile(new File("test.wAr"))).isInstanceOf(Layouts.War.class);
assertThat(Layouts.forFile(new File("te.st.war")))
.isInstanceOf(Layouts.War.class);
}
@Test
@@ -64,40 +63,40 @@ public class LayoutsTests {
@Test
public void jarLayout() throws Exception {
Layout layout = new Layouts.Jar();
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.COMPILE),
equalTo("lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.CUSTOM),
equalTo("lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.PROVIDED),
equalTo("lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.RUNTIME),
equalTo("lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.COMPILE))
.isEqualTo("lib/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.CUSTOM))
.isEqualTo("lib/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.PROVIDED))
.isEqualTo("lib/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.RUNTIME))
.isEqualTo("lib/");
}
@Test
public void warLayout() throws Exception {
Layout layout = new Layouts.War();
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.COMPILE),
equalTo("WEB-INF/lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.CUSTOM),
equalTo("WEB-INF/lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.PROVIDED),
equalTo("WEB-INF/lib-provided/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.RUNTIME),
equalTo("WEB-INF/lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.COMPILE))
.isEqualTo("WEB-INF/lib/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.CUSTOM))
.isEqualTo("WEB-INF/lib/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.PROVIDED))
.isEqualTo("WEB-INF/lib-provided/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.RUNTIME))
.isEqualTo("WEB-INF/lib/");
}
@Test
public void moduleLayout() throws Exception {
Layout layout = new Layouts.Module();
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.COMPILE),
equalTo("lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.PROVIDED),
nullValue());
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.RUNTIME),
equalTo("lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.CUSTOM),
equalTo("lib/"));
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.COMPILE))
.isEqualTo("lib/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.PROVIDED))
.isNull();
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.RUNTIME))
.isEqualTo("lib/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.CUSTOM))
.isEqualTo("lib/");
}
}

View File

@@ -30,8 +30,7 @@ import org.springframework.boot.loader.tools.MainClassFinder.ClassNameCallback;
import org.springframework.boot.loader.tools.sample.ClassWithMainMethod;
import org.springframework.boot.loader.tools.sample.ClassWithoutMainMethod;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link MainClassFinder}.
@@ -58,7 +57,7 @@ public class MainClassFinderTests {
this.testJarFile.addClass("B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("A.class", ClassWithoutMainMethod.class);
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(), "");
assertThat(actual, equalTo("B"));
assertThat(actual).isEqualTo("B");
}
@Test
@@ -67,7 +66,7 @@ public class MainClassFinderTests {
this.testJarFile.addClass("a/b/c/E.class", ClassWithoutMainMethod.class);
this.testJarFile.addClass("a/b/F.class", ClassWithoutMainMethod.class);
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(), "");
assertThat(actual, equalTo("a.b.c.D"));
assertThat(actual).isEqualTo("a.b.c.D");
}
@Test
@@ -75,7 +74,7 @@ public class MainClassFinderTests {
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(), "");
assertThat(actual, equalTo("a.B"));
assertThat(actual).isEqualTo("a.B");
}
@Test
@@ -94,7 +93,7 @@ public class MainClassFinderTests {
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(),
"a/");
assertThat(actual, equalTo("B"));
assertThat(actual).isEqualTo("B");
}
@@ -103,7 +102,7 @@ public class MainClassFinderTests {
this.testJarFile.addClass("B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("A.class", ClassWithoutMainMethod.class);
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarSource());
assertThat(actual, equalTo("B"));
assertThat(actual).isEqualTo("B");
}
@Test
@@ -112,7 +111,7 @@ public class MainClassFinderTests {
this.testJarFile.addClass("a/b/c/E.class", ClassWithoutMainMethod.class);
this.testJarFile.addClass("a/b/F.class", ClassWithoutMainMethod.class);
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarSource());
assertThat(actual, equalTo("a.b.c.D"));
assertThat(actual).isEqualTo("a.b.c.D");
}
@Test
@@ -120,7 +119,7 @@ public class MainClassFinderTests {
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarSource());
assertThat(actual, equalTo("a.B"));
assertThat(actual).isEqualTo("a.B");
}
@Test
@@ -141,7 +140,7 @@ public class MainClassFinderTests {
this.testJarFile.addClass("a/b/G.class", ClassWithMainMethod.class);
ClassNameCollector callback = new ClassNameCollector();
MainClassFinder.doWithMainClasses(this.testJarFile.getJarSource(), callback);
assertThat(callback.getClassNames().toString(), equalTo("[a.b.G, a.b.c.D]"));
assertThat(callback.getClassNames().toString()).isEqualTo("[a.b.G, a.b.c.D]");
}
@Test
@@ -152,7 +151,7 @@ public class MainClassFinderTests {
this.testJarFile.addClass("a/b/G.class", ClassWithMainMethod.class);
ClassNameCollector callback = new ClassNameCollector();
MainClassFinder.doWithMainClasses(this.testJarFile.getJarFile(), "", callback);
assertThat(callback.getClassNames().toString(), equalTo("[a.b.G, a.b.c.D]"));
assertThat(callback.getClassNames().toString()).isEqualTo("[a.b.G, a.b.c.D]");
}
private static class ClassNameCollector implements ClassNameCallback<Object> {

View File

@@ -38,10 +38,7 @@ import org.springframework.boot.loader.tools.sample.ClassWithMainMethod;
import org.springframework.boot.loader.tools.sample.ClassWithoutMainMethod;
import org.springframework.util.FileCopyUtils;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
@@ -112,11 +109,11 @@ public class RepackagerTests {
repackager.setMainClass("a.b.C");
repackager.repackage(NO_LIBRARIES);
Manifest actualManifest = getManifest(file);
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"),
equalTo("org.springframework.boot.loader.JarLauncher"));
assertThat(actualManifest.getMainAttributes().getValue("Start-Class"),
equalTo("a.b.C"));
assertThat(hasLauncherClasses(file), equalTo(true));
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class"))
.isEqualTo("a.b.C");
assertThat(hasLauncherClasses(file)).isTrue();
}
@Test
@@ -130,11 +127,11 @@ public class RepackagerTests {
Repackager repackager = new Repackager(file);
repackager.repackage(NO_LIBRARIES);
Manifest actualManifest = getManifest(file);
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"),
equalTo("org.springframework.boot.loader.JarLauncher"));
assertThat(actualManifest.getMainAttributes().getValue("Start-Class"),
equalTo("a.b.C"));
assertThat(hasLauncherClasses(file), equalTo(true));
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class"))
.isEqualTo("a.b.C");
assertThat(hasLauncherClasses(file)).isTrue();
}
@Test
@@ -144,11 +141,11 @@ public class RepackagerTests {
Repackager repackager = new Repackager(file);
repackager.repackage(NO_LIBRARIES);
Manifest actualManifest = getManifest(file);
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"),
equalTo("org.springframework.boot.loader.JarLauncher"));
assertThat(actualManifest.getMainAttributes().getValue("Start-Class"),
equalTo("a.b.C"));
assertThat(hasLauncherClasses(file), equalTo(true));
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class"))
.isEqualTo("a.b.C");
assertThat(hasLauncherClasses(file)).isTrue();
}
@Test
@@ -159,11 +156,11 @@ public class RepackagerTests {
repackager.repackage(NO_LIBRARIES);
repackager.repackage(NO_LIBRARIES);
Manifest actualManifest = getManifest(file);
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"),
equalTo("org.springframework.boot.loader.JarLauncher"));
assertThat(actualManifest.getMainAttributes().getValue("Start-Class"),
equalTo("a.b.C"));
assertThat(hasLauncherClasses(file), equalTo(true));
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("org.springframework.boot.loader.JarLauncher");
assertThat(actualManifest.getMainAttributes().getValue("Start-Class"))
.isEqualTo("a.b.C");
assertThat(hasLauncherClasses(file)).isTrue();
}
@Test
@@ -194,9 +191,9 @@ public class RepackagerTests {
repackager.setLayout(new Layouts.None());
repackager.repackage(file, NO_LIBRARIES);
Manifest actualManifest = getManifest(file);
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"),
equalTo("a.b.C"));
assertThat(hasLauncherClasses(file), equalTo(false));
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo("a.b.C");
assertThat(hasLauncherClasses(file)).isFalse();
}
@Test
@@ -207,9 +204,9 @@ public class RepackagerTests {
repackager.setLayout(new Layouts.None());
repackager.repackage(file, NO_LIBRARIES);
Manifest actualManifest = getManifest(file);
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"),
equalTo(null));
assertThat(hasLauncherClasses(file), equalTo(false));
assertThat(actualManifest.getMainAttributes().getValue("Main-Class"))
.isEqualTo(null);
assertThat(hasLauncherClasses(file)).isFalse();
}
@Test
@@ -218,9 +215,8 @@ public class RepackagerTests {
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
repackager.repackage(NO_LIBRARIES);
assertThat(new File(file.getParent(), file.getName() + ".original").exists(),
equalTo(true));
assertThat(hasLauncherClasses(file), equalTo(true));
assertThat(new File(file.getParent(), file.getName() + ".original")).exists();
assertThat(hasLauncherClasses(file)).isTrue();
}
@Test
@@ -230,9 +226,9 @@ public class RepackagerTests {
Repackager repackager = new Repackager(file);
repackager.setBackupSource(false);
repackager.repackage(NO_LIBRARIES);
assertThat(new File(file.getParent(), file.getName() + ".original").exists(),
equalTo(false));
assertThat(hasLauncherClasses(file), equalTo(true));
assertThat(new File(file.getParent(), file.getName() + ".original"))
.doesNotExist();
assertThat(hasLauncherClasses(file)).isTrue();
}
@Test
@@ -242,10 +238,10 @@ public class RepackagerTests {
File dest = this.temporaryFolder.newFile("different.jar");
Repackager repackager = new Repackager(source);
repackager.repackage(dest, NO_LIBRARIES);
assertThat(new File(source.getParent(), source.getName() + ".original").exists(),
equalTo(false));
assertThat(hasLauncherClasses(source), equalTo(false));
assertThat(hasLauncherClasses(dest), equalTo(true));
assertThat(new File(source.getParent(), source.getName() + ".original"))
.doesNotExist();
assertThat(hasLauncherClasses(source)).isFalse();
assertThat(hasLauncherClasses(dest)).isTrue();
}
@Test
@@ -273,7 +269,7 @@ public class RepackagerTests {
File dest = this.temporaryFolder.newFile("dest.jar");
dest.createNewFile();
repackager.repackage(dest, NO_LIBRARIES);
assertThat(hasLauncherClasses(dest), equalTo(true));
assertThat(hasLauncherClasses(dest)).isTrue();
}
@Test
@@ -309,14 +305,14 @@ public class RepackagerTests {
callback.library(new Library(libNonJarFile, LibraryScope.COMPILE));
}
});
assertThat(hasEntry(file, "lib/" + libJarFile.getName()), equalTo(true));
assertThat(hasEntry(file, "lib/" + libJarFileToUnpack.getName()), equalTo(true));
assertThat(hasEntry(file, "lib/" + libNonJarFile.getName()), equalTo(false));
assertThat(hasEntry(file, "lib/" + libJarFile.getName())).isTrue();
assertThat(hasEntry(file, "lib/" + libJarFileToUnpack.getName())).isTrue();
assertThat(hasEntry(file, "lib/" + libNonJarFile.getName())).isFalse();
JarEntry entry = getEntry(file, "lib/" + libJarFile.getName());
assertThat(entry.getTime(), equalTo(JAN_1_1985));
assertThat(entry.getTime()).isEqualTo(JAN_1_1985);
entry = getEntry(file, "lib/" + libJarFileToUnpack.getName());
assertThat(entry.getComment(), startsWith("UNPACK:"));
assertThat(entry.getComment().length(), equalTo(47));
assertThat(entry.getComment()).startsWith("UNPACK:");
assertThat(entry.getComment().length()).isEqualTo(47);
}
@Test
@@ -357,9 +353,9 @@ public class RepackagerTests {
callback.library(new Library(libJarFile, scope));
}
});
assertThat(hasEntry(file, "test/" + libJarFile.getName()), equalTo(true));
assertThat(getManifest(file).getMainAttributes().getValue("Main-Class"),
equalTo("testLauncher"));
assertThat(hasEntry(file, "test/" + libJarFile.getName())).isTrue();
assertThat(getManifest(file).getMainAttributes().getValue("Main-Class"))
.isEqualTo("testLauncher");
}
@Test
@@ -369,8 +365,8 @@ public class RepackagerTests {
Repackager repackager = new Repackager(file);
repackager.repackage(NO_LIBRARIES);
Manifest actualManifest = getManifest(file);
assertThat(actualManifest.getMainAttributes()
.containsKey(new Attributes.Name("Spring-Boot-Version")), equalTo(true));
assertThat(actualManifest.getMainAttributes())
.containsKey(new Attributes.Name("Spring-Boot-Version"));
}
@Test
@@ -399,10 +395,10 @@ public class RepackagerTests {
});
JarFile jarFile = new JarFile(file);
try {
assertThat(jarFile.getEntry("lib/" + nestedFile.getName()).getMethod(),
equalTo(ZipEntry.STORED));
assertThat(jarFile.getEntry("test/nested.jar").getMethod(),
equalTo(ZipEntry.STORED));
assertThat(jarFile.getEntry("lib/" + nestedFile.getName()).getMethod())
.isEqualTo(ZipEntry.STORED);
assertThat(jarFile.getEntry("test/nested.jar").getMethod())
.isEqualTo(ZipEntry.STORED);
}
finally {
jarFile.close();
@@ -418,12 +414,12 @@ public class RepackagerTests {
LaunchScript script = new MockLauncherScript("ABC");
repackager.repackage(dest, NO_LIBRARIES, script);
byte[] bytes = FileCopyUtils.copyToByteArray(dest);
assertThat(new String(bytes), startsWith("ABC"));
assertThat(hasLauncherClasses(source), equalTo(false));
assertThat(hasLauncherClasses(dest), equalTo(true));
assertThat(new String(bytes)).startsWith("ABC");
assertThat(hasLauncherClasses(source)).isFalse();
assertThat(hasLauncherClasses(dest)).isTrue();
try {
assertThat(Files.getPosixFilePermissions(dest.toPath()),
hasItem(PosixFilePermission.OWNER_EXECUTE));
assertThat(Files.getPosixFilePermissions(dest.toPath()))
.contains(PosixFilePermission.OWNER_EXECUTE);
}
catch (UnsupportedOperationException ex) {
// Probably running the test on Windows
@@ -450,8 +446,8 @@ public class RepackagerTests {
});
JarFile jarFile = new JarFile(file);
try {
assertThat(jarFile.getEntry("lib/" + nestedFile.getName()).getComment(),
startsWith("UNPACK:"));
assertThat(jarFile.getEntry("lib/" + nestedFile.getName()).getComment())
.startsWith("UNPACK:");
}
finally {
jarFile.close();
@@ -482,8 +478,8 @@ public class RepackagerTests {
});
JarFile jarFile = new JarFile(file);
try {
assertThat(jarFile.getEntry("lib/" + nestedFile.getName()).getSize(),
equalTo(sourceLength));
assertThat(jarFile.getEntry("lib/" + nestedFile.getName()).getSize())
.isEqualTo(sourceLength);
}
finally {
jarFile.close();