Move tests to JUnit 5 wherever possible

This commit is contained in:
Andy Wilkinson
2019-05-24 11:24:29 +01:00
parent 36f56d034a
commit b18fffaf14
1320 changed files with 13424 additions and 14185 deletions

View File

@@ -21,9 +21,8 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.util.FileCopyUtils;
@@ -36,100 +35,100 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson
* @author Justin Rosenberg
*/
public class DefaultLaunchScriptTests {
class DefaultLaunchScriptTests {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@TempDir
File tempDir;
@Test
public void loadsDefaultScript() throws Exception {
void loadsDefaultScript() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null);
String content = new String(script.toByteArray());
assertThat(content).contains("Spring Boot Startup Script");
}
@Test
public void logFilenameCanBeReplaced() throws Exception {
void logFilenameCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("logFilename");
}
@Test
public void pidFilenameCanBeReplaced() throws Exception {
void pidFilenameCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("pidFilename");
}
@Test
public void initInfoProvidesCanBeReplaced() throws Exception {
void initInfoProvidesCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("initInfoProvides");
}
@Test
public void initInfoRequiredStartCanBeReplaced() throws Exception {
void initInfoRequiredStartCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("initInfoRequiredStart");
}
@Test
public void initInfoRequiredStopCanBeReplaced() throws Exception {
void initInfoRequiredStopCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("initInfoRequiredStop");
}
@Test
public void initInfoDefaultStartCanBeReplaced() throws Exception {
void initInfoDefaultStartCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("initInfoDefaultStart");
}
@Test
public void initInfoDefaultStopCanBeReplaced() throws Exception {
void initInfoDefaultStopCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("initInfoDefaultStop");
}
@Test
public void initInfoShortDescriptionCanBeReplaced() throws Exception {
void initInfoShortDescriptionCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("initInfoShortDescription");
}
@Test
public void initInfoDescriptionCanBeReplaced() throws Exception {
void initInfoDescriptionCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("initInfoDescription");
}
@Test
public void initInfoChkconfigCanBeReplaced() throws Exception {
void initInfoChkconfigCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("initInfoChkconfig");
}
@Test
public void modeCanBeReplaced() throws Exception {
void modeCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("mode");
}
@Test
public void useStartStopDaemonCanBeReplaced() throws Exception {
void useStartStopDaemonCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("useStartStopDaemon");
}
@Test
public void logFolderCanBeReplaced() throws Exception {
void logFolderCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("logFolder");
}
@Test
public void pidFolderCanBeReplaced() throws Exception {
void pidFolderCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("pidFolder");
}
@Test
public void confFolderCanBeReplaced() throws Exception {
void confFolderCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("confFolder");
}
@Test
public void stopWaitTimeCanBeReplaced() throws Exception {
void stopWaitTimeCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("stopWaitTime");
}
@Test
public void inlinedConfScriptFileLoad() throws IOException {
void inlinedConfScriptFileLoad() throws IOException {
DefaultLaunchScript script = new DefaultLaunchScript(null,
createProperties("inlinedConfScript:src/test/resources/example.script"));
String content = new String(script.toByteArray());
@@ -137,29 +136,29 @@ public class DefaultLaunchScriptTests {
}
@Test
public void defaultForUseStartStopDaemonIsTrue() throws Exception {
void defaultForUseStartStopDaemonIsTrue() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null);
String content = new String(script.toByteArray());
assertThat(content).contains("USE_START_STOP_DAEMON=\"true\"");
}
@Test
public void defaultForModeIsAuto() throws Exception {
void defaultForModeIsAuto() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null);
String content = new String(script.toByteArray());
assertThat(content).contains("MODE=\"auto\"");
}
@Test
public void defaultForStopWaitTimeIs60() throws Exception {
void defaultForStopWaitTimeIs60() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null);
String content = new String(script.toByteArray());
assertThat(content).contains("STOP_WAIT_TIME=\"60\"");
}
@Test
public void loadFromFile() throws Exception {
File file = this.temporaryFolder.newFile();
void loadFromFile() throws Exception {
File file = new File(this.tempDir, "script");
FileCopyUtils.copy("ABC".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, null);
String content = new String(script.toByteArray());
@@ -167,8 +166,8 @@ public class DefaultLaunchScriptTests {
}
@Test
public void expandVariables() throws Exception {
File file = this.temporaryFolder.newFile();
void expandVariables() throws Exception {
File file = new File(this.tempDir, "script");
FileCopyUtils.copy("h{{a}}ll{{b}}".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, createProperties("a:e", "b:o"));
String content = new String(script.toByteArray());
@@ -176,8 +175,8 @@ public class DefaultLaunchScriptTests {
}
@Test
public void expandVariablesMultiLine() throws Exception {
File file = this.temporaryFolder.newFile();
void expandVariablesMultiLine() throws Exception {
File file = new File(this.tempDir, "script");
FileCopyUtils.copy("h{{a}}l\nl{{b}}".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, createProperties("a:e", "b:o"));
String content = new String(script.toByteArray());
@@ -185,8 +184,8 @@ public class DefaultLaunchScriptTests {
}
@Test
public void expandVariablesWithDefaults() throws Exception {
File file = this.temporaryFolder.newFile();
void expandVariablesWithDefaults() throws Exception {
File file = new File(this.tempDir, "script");
FileCopyUtils.copy("h{{a:e}}ll{{b:o}}".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, null);
String content = new String(script.toByteArray());
@@ -194,8 +193,8 @@ public class DefaultLaunchScriptTests {
}
@Test
public void expandVariablesCanDefaultToBlank() throws Exception {
File file = this.temporaryFolder.newFile();
void expandVariablesCanDefaultToBlank() throws Exception {
File file = new File(this.tempDir, "script");
FileCopyUtils.copy("s{{p:}}{{r:}}ing".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, null);
String content = new String(script.toByteArray());
@@ -203,8 +202,8 @@ public class DefaultLaunchScriptTests {
}
@Test
public void expandVariablesWithDefaultsOverride() throws Exception {
File file = this.temporaryFolder.newFile();
void expandVariablesWithDefaultsOverride() throws Exception {
File file = new File(this.tempDir, "script");
FileCopyUtils.copy("h{{a:e}}ll{{b:o}}".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, createProperties("a:a"));
String content = new String(script.toByteArray());
@@ -212,8 +211,8 @@ public class DefaultLaunchScriptTests {
}
@Test
public void expandVariablesMissingAreUnchanged() throws Exception {
File file = this.temporaryFolder.newFile();
void expandVariablesMissingAreUnchanged() throws Exception {
File file = new File(this.tempDir, "script");
FileCopyUtils.copy("h{{a}}ll{{b}}".getBytes(), file);
DefaultLaunchScript script = new DefaultLaunchScript(file, null);
String content = new String(script.toByteArray());

View File

@@ -21,12 +21,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.util.FileSystemUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,27 +33,25 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
* @author Phillip Webb
*/
public class FileUtilsTests {
class FileUtilsTests {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@TempDir
File tempDir;
private File outputDirectory;
private File originDirectory;
@Before
@BeforeEach
public void init() throws IOException {
this.outputDirectory = this.temporaryFolder.newFolder("remove");
this.originDirectory = this.temporaryFolder.newFolder("keep");
FileSystemUtils.deleteRecursively(this.outputDirectory);
FileSystemUtils.deleteRecursively(this.originDirectory);
this.outputDirectory = new File(this.tempDir, "remove");
this.originDirectory = new File(this.tempDir, "keep");
this.outputDirectory.mkdirs();
this.originDirectory.mkdirs();
}
@Test
public void simpleDuplicateFile() throws IOException {
void simpleDuplicateFile() throws IOException {
File file = new File(this.outputDirectory, "logback.xml");
file.createNewFile();
new File(this.originDirectory, "logback.xml").createNewFile();
@@ -65,7 +60,7 @@ public class FileUtilsTests {
}
@Test
public void nestedDuplicateFile() throws IOException {
void nestedDuplicateFile() throws IOException {
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");
@@ -76,7 +71,7 @@ public class FileUtilsTests {
}
@Test
public void nestedNonDuplicateFile() throws IOException {
void nestedNonDuplicateFile() throws IOException {
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");
@@ -87,7 +82,7 @@ public class FileUtilsTests {
}
@Test
public void nonDuplicateFile() throws IOException {
void nonDuplicateFile() throws IOException {
File file = new File(this.outputDirectory, "logback.xml");
file.createNewFile();
new File(this.originDirectory, "different.xml").createNewFile();
@@ -96,8 +91,8 @@ public class FileUtilsTests {
}
@Test
public void hash() throws Exception {
File file = this.temporaryFolder.newFile();
void hash() throws Exception {
File file = new File(this.tempDir, "file");
try (OutputStream outputStream = new FileOutputStream(file)) {
outputStream.write(new byte[] { 1, 2, 3 });
}

View File

@@ -18,7 +18,7 @@ package org.springframework.boot.loader.tools;
import java.io.File;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
@@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Phillip Webb
* @author Andy Wilkinson
*/
public class LayoutsTests {
class LayoutsTests {
@Test
public void jarFile() {
void jarFile() {
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);
@@ -40,7 +40,7 @@ public class LayoutsTests {
}
@Test
public void warFile() {
void warFile() {
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);
@@ -48,13 +48,13 @@ public class LayoutsTests {
}
@Test
public void unknownFile() {
void unknownFile() {
assertThatIllegalStateException().isThrownBy(() -> Layouts.forFile(new File("test.txt")))
.withMessageContaining("Unable to deduce layout for 'test.txt'");
}
@Test
public void jarLayout() {
void jarLayout() {
Layout layout = new Layouts.Jar();
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.COMPILE)).isEqualTo("BOOT-INF/lib/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.CUSTOM)).isEqualTo("BOOT-INF/lib/");
@@ -63,7 +63,7 @@ public class LayoutsTests {
}
@Test
public void warLayout() {
void warLayout() {
Layout layout = new Layouts.War();
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.COMPILE)).isEqualTo("WEB-INF/lib/");
assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.CUSTOM)).isEqualTo("WEB-INF/lib/");

View File

@@ -16,14 +16,14 @@
package org.springframework.boot.loader.tools;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.boot.loader.tools.MainClassFinder.MainClass;
import org.springframework.boot.loader.tools.MainClassFinder.MainClassCallback;
@@ -39,20 +39,17 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
*
* @author Phillip Webb
*/
public class MainClassFinderTests {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
class MainClassFinderTests {
private TestJarFile testJarFile;
@Before
public void setup() throws IOException {
this.testJarFile = new TestJarFile(this.temporaryFolder);
@BeforeEach
public void setup(@TempDir File tempDir) throws IOException {
this.testJarFile = new TestJarFile(tempDir);
}
@Test
public void findMainClassInJar() throws Exception {
void findMainClassInJar() throws Exception {
this.testJarFile.addClass("B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("A.class", ClassWithoutMainMethod.class);
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(), "");
@@ -60,7 +57,7 @@ public class MainClassFinderTests {
}
@Test
public void findMainClassInJarSubFolder() throws Exception {
void findMainClassInJarSubFolder() throws Exception {
this.testJarFile.addClass("a/b/c/D.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithoutMainMethod.class);
this.testJarFile.addClass("a/b/F.class", ClassWithoutMainMethod.class);
@@ -69,7 +66,7 @@ public class MainClassFinderTests {
}
@Test
public void usesBreadthFirstJarSearch() throws Exception {
void usesBreadthFirstJarSearch() throws Exception {
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(), "");
@@ -77,7 +74,7 @@ public class MainClassFinderTests {
}
@Test
public void findSingleJarSearch() throws Exception {
void findSingleJarSearch() throws Exception {
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
assertThatIllegalStateException()
@@ -87,7 +84,7 @@ public class MainClassFinderTests {
}
@Test
public void findSingleJarSearchPrefersAnnotatedMainClass() throws Exception {
void findSingleJarSearchPrefersAnnotatedMainClass() throws Exception {
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", AnnotatedClassWithMainMethod.class);
String mainClass = MainClassFinder.findSingleMainClass(this.testJarFile.getJarFile(), "",
@@ -96,7 +93,7 @@ public class MainClassFinderTests {
}
@Test
public void findMainClassInJarSubLocation() throws Exception {
void findMainClassInJarSubLocation() throws Exception {
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(), "a/");
@@ -105,7 +102,7 @@ public class MainClassFinderTests {
}
@Test
public void findMainClassInFolder() throws Exception {
void findMainClassInFolder() throws Exception {
this.testJarFile.addClass("B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("A.class", ClassWithoutMainMethod.class);
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarSource());
@@ -113,7 +110,7 @@ public class MainClassFinderTests {
}
@Test
public void findMainClassInSubFolder() throws Exception {
void findMainClassInSubFolder() throws Exception {
this.testJarFile.addClass("a/b/c/D.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithoutMainMethod.class);
this.testJarFile.addClass("a/b/F.class", ClassWithoutMainMethod.class);
@@ -122,7 +119,7 @@ public class MainClassFinderTests {
}
@Test
public void usesBreadthFirstFolderSearch() throws Exception {
void usesBreadthFirstFolderSearch() throws Exception {
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());
@@ -130,7 +127,7 @@ public class MainClassFinderTests {
}
@Test
public void findSingleFolderSearch() throws Exception {
void findSingleFolderSearch() throws Exception {
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
assertThatIllegalStateException()
@@ -140,7 +137,7 @@ public class MainClassFinderTests {
}
@Test
public void findSingleFolderSearchPrefersAnnotatedMainClass() throws Exception {
void findSingleFolderSearchPrefersAnnotatedMainClass() throws Exception {
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", AnnotatedClassWithMainMethod.class);
String mainClass = MainClassFinder.findSingleMainClass(this.testJarFile.getJarSource(),
@@ -149,7 +146,7 @@ public class MainClassFinderTests {
}
@Test
public void doWithFolderMainMethods() throws Exception {
void doWithFolderMainMethods() throws Exception {
this.testJarFile.addClass("a/b/c/D.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithoutMainMethod.class);
this.testJarFile.addClass("a/b/F.class", ClassWithoutMainMethod.class);
@@ -160,7 +157,7 @@ public class MainClassFinderTests {
}
@Test
public void doWithJarMainMethods() throws Exception {
void doWithJarMainMethods() throws Exception {
this.testJarFile.addClass("a/b/c/D.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithoutMainMethod.class);
this.testJarFile.addClass("a/b/F.class", ClassWithoutMainMethod.class);

View File

@@ -37,10 +37,9 @@ import java.util.zip.ZipOutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.zeroturnaround.zip.ZipUtil;
import org.springframework.boot.loader.tools.sample.ClassWithMainMethod;
@@ -61,7 +60,7 @@ import static org.mockito.Mockito.mock;
* @author Phillip Webb
* @author Andy Wilkinson
*/
public class RepackagerTests {
class RepackagerTests {
private static final Libraries NO_LIBRARIES = (callback) -> {
};
@@ -79,33 +78,33 @@ public class RepackagerTests {
JAN_1_1985 = calendar.getTime().getTime();
}
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@TempDir
File tempDir;
private TestJarFile testJarFile;
@Before
@BeforeEach
public void setup() throws IOException {
this.testJarFile = new TestJarFile(this.temporaryFolder);
this.testJarFile = new TestJarFile(this.tempDir);
}
@Test
public void nullSource() {
void nullSource() {
assertThatIllegalArgumentException().isThrownBy(() -> new Repackager(null));
}
@Test
public void missingSource() {
void missingSource() {
assertThatIllegalArgumentException().isThrownBy(() -> new Repackager(new File("missing")));
}
@Test
public void directorySource() {
assertThatIllegalArgumentException().isThrownBy(() -> new Repackager(this.temporaryFolder.getRoot()));
void directorySource() {
assertThatIllegalArgumentException().isThrownBy(() -> new Repackager(this.tempDir));
}
@Test
public void specificMainClass() throws Exception {
void specificMainClass() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -119,7 +118,7 @@ public class RepackagerTests {
}
@Test
public void mainClassFromManifest() throws Exception {
void mainClassFromManifest() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class);
Manifest manifest = new Manifest();
manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
@@ -136,7 +135,7 @@ public class RepackagerTests {
}
@Test
public void mainClassFound() throws Exception {
void mainClassFound() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -149,7 +148,7 @@ public class RepackagerTests {
}
@Test
public void jarIsOnlyRepackagedOnce() throws Exception {
void jarIsOnlyRepackagedOnce() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -163,7 +162,7 @@ public class RepackagerTests {
}
@Test
public void multipleMainClassFound() throws Exception {
void multipleMainClassFound() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/D.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile();
@@ -173,7 +172,7 @@ public class RepackagerTests {
}
@Test
public void noMainClass() throws Exception {
void noMainClass() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class);
assertThatIllegalStateException()
.isThrownBy(() -> new Repackager(this.testJarFile.getFile()).repackage(NO_LIBRARIES))
@@ -181,7 +180,7 @@ public class RepackagerTests {
}
@Test
public void noMainClassAndLayoutIsNone() throws Exception {
void noMainClassAndLayoutIsNone() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -193,7 +192,7 @@ public class RepackagerTests {
}
@Test
public void noMainClassAndLayoutIsNoneWithNoMain() throws Exception {
void noMainClassAndLayoutIsNoneWithNoMain() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -205,7 +204,7 @@ public class RepackagerTests {
}
@Test
public void sameSourceAndDestinationWithBackup() throws Exception {
void sameSourceAndDestinationWithBackup() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -215,7 +214,7 @@ public class RepackagerTests {
}
@Test
public void sameSourceAndDestinationWithoutBackup() throws Exception {
void sameSourceAndDestinationWithoutBackup() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -226,10 +225,10 @@ public class RepackagerTests {
}
@Test
public void differentDestination() throws Exception {
void differentDestination() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File source = this.testJarFile.getFile();
File dest = this.temporaryFolder.newFile("different.jar");
File dest = new File(this.tempDir, "different.jar");
Repackager repackager = new Repackager(source);
repackager.repackage(dest, NO_LIBRARIES);
assertThat(new File(source.getParent(), source.getName() + ".original")).doesNotExist();
@@ -238,7 +237,7 @@ public class RepackagerTests {
}
@Test
public void nullDestination() throws Exception {
void nullDestination() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
Repackager repackager = new Repackager(this.testJarFile.getFile());
assertThatIllegalArgumentException().isThrownBy(() -> repackager.repackage(null, NO_LIBRARIES))
@@ -246,26 +245,25 @@ public class RepackagerTests {
}
@Test
public void destinationIsDirectory() throws Exception {
void destinationIsDirectory() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
Repackager repackager = new Repackager(this.testJarFile.getFile());
assertThatIllegalArgumentException()
.isThrownBy(() -> repackager.repackage(this.temporaryFolder.getRoot(), NO_LIBRARIES))
assertThatIllegalArgumentException().isThrownBy(() -> repackager.repackage(this.tempDir, NO_LIBRARIES))
.withMessageContaining("Invalid destination");
}
@Test
public void overwriteDestination() throws Exception {
void overwriteDestination() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
Repackager repackager = new Repackager(this.testJarFile.getFile());
File dest = this.temporaryFolder.newFile("dest.jar");
File dest = new File(this.tempDir, "dest.jar");
dest.createNewFile();
repackager.repackage(dest, NO_LIBRARIES);
assertThat(hasLauncherClasses(dest)).isTrue();
}
@Test
public void nullLibraries() throws Exception {
void nullLibraries() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -274,12 +272,12 @@ public class RepackagerTests {
}
@Test
public void libraries() throws Exception {
TestJarFile libJar = new TestJarFile(this.temporaryFolder);
void libraries() throws Exception {
TestJarFile libJar = new TestJarFile(this.tempDir);
libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class, JAN_1_1985);
File libJarFile = libJar.getFile();
File libJarFileToUnpack = libJar.getFile();
File libNonJarFile = this.temporaryFolder.newFile();
File libNonJarFile = new File(this.tempDir, "non-lib.jar");
FileCopyUtils.copy(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, libNonJarFile);
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
this.testJarFile.addFile("BOOT-INF/lib/" + libJarFileToUnpack.getName(), libJarFileToUnpack);
@@ -302,8 +300,8 @@ public class RepackagerTests {
}
@Test
public void duplicateLibraries() throws Exception {
TestJarFile libJar = new TestJarFile(this.temporaryFolder);
void duplicateLibraries() throws Exception {
TestJarFile libJar = new TestJarFile(this.tempDir);
libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
File libJarFile = libJar.getFile();
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
@@ -316,8 +314,8 @@ public class RepackagerTests {
}
@Test
public void customLayout() throws Exception {
TestJarFile libJar = new TestJarFile(this.temporaryFolder);
void customLayout() throws Exception {
TestJarFile libJar = new TestJarFile(this.tempDir);
libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
File libJarFile = libJar.getFile();
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
@@ -336,8 +334,8 @@ public class RepackagerTests {
}
@Test
public void customLayoutNoBootLib() throws Exception {
TestJarFile libJar = new TestJarFile(this.temporaryFolder);
void customLayoutNoBootLib() throws Exception {
TestJarFile libJar = new TestJarFile(this.tempDir);
libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
File libJarFile = libJar.getFile();
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
@@ -353,7 +351,7 @@ public class RepackagerTests {
}
@Test
public void springBootVersion() throws Exception {
void springBootVersion() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -363,7 +361,7 @@ public class RepackagerTests {
}
@Test
public void executableJarLayoutAttributes() throws Exception {
void executableJarLayoutAttributes() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile();
Repackager repackager = new Repackager(file);
@@ -376,7 +374,7 @@ public class RepackagerTests {
}
@Test
public void executableWarLayoutAttributes() throws Exception {
void executableWarLayoutAttributes() throws Exception {
this.testJarFile.addClass("WEB-INF/classes/a/b/C.class", ClassWithMainMethod.class);
File file = this.testJarFile.getFile("war");
Repackager repackager = new Repackager(file);
@@ -389,7 +387,7 @@ public class RepackagerTests {
}
@Test
public void nullCustomLayout() throws Exception {
void nullCustomLayout() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class);
Repackager repackager = new Repackager(this.testJarFile.getFile());
assertThatIllegalArgumentException().isThrownBy(() -> repackager.setLayout(null))
@@ -397,8 +395,8 @@ public class RepackagerTests {
}
@Test
public void dontRecompressZips() throws Exception {
TestJarFile nested = new TestJarFile(this.temporaryFolder);
void dontRecompressZips() throws Exception {
TestJarFile nested = new TestJarFile(this.tempDir);
nested.addClass("a/b/C.class", ClassWithoutMainMethod.class);
File nestedFile = nested.getFile();
this.testJarFile.addFile("test/nested.jar", nestedFile);
@@ -414,10 +412,10 @@ public class RepackagerTests {
}
@Test
public void addLauncherScript() throws Exception {
void addLauncherScript() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File source = this.testJarFile.getFile();
File dest = this.temporaryFolder.newFile("dest.jar");
File dest = new File(this.tempDir, "dest.jar");
Repackager repackager = new Repackager(source);
LaunchScript script = new MockLauncherScript("ABC");
repackager.repackage(dest, NO_LIBRARIES, script);
@@ -434,8 +432,8 @@ public class RepackagerTests {
}
@Test
public void unpackLibrariesTakePrecedenceOverExistingSourceEntries() throws Exception {
TestJarFile nested = new TestJarFile(this.temporaryFolder);
void unpackLibrariesTakePrecedenceOverExistingSourceEntries() throws Exception {
TestJarFile nested = new TestJarFile(this.tempDir);
nested.addClass("a/b/C.class", ClassWithoutMainMethod.class);
File nestedFile = nested.getFile();
String name = "BOOT-INF/lib/" + nestedFile.getName();
@@ -450,8 +448,8 @@ public class RepackagerTests {
}
@Test
public void existingSourceEntriesTakePrecedenceOverStandardLibraries() throws Exception {
TestJarFile nested = new TestJarFile(this.temporaryFolder);
void existingSourceEntriesTakePrecedenceOverStandardLibraries() throws Exception {
TestJarFile nested = new TestJarFile(this.tempDir);
nested.addClass("a/b/C.class", ClassWithoutMainMethod.class);
File nestedFile = nested.getFile();
this.testJarFile.addFile("BOOT-INF/lib/" + nestedFile.getName(), nested.getFile());
@@ -461,7 +459,8 @@ public class RepackagerTests {
long sourceLength = nestedFile.length();
repackager.repackage((callback) -> {
nestedFile.delete();
File toZip = RepackagerTests.this.temporaryFolder.newFile();
File toZip = new File(this.tempDir, "to-zip");
toZip.createNewFile();
ZipUtil.packEntry(toZip, nestedFile);
callback.library(new Library(nestedFile, LibraryScope.COMPILE));
});
@@ -471,11 +470,13 @@ public class RepackagerTests {
}
@Test
public void metaInfIndexListIsRemovedFromRepackagedJar() throws Exception {
void metaInfIndexListIsRemovedFromRepackagedJar() throws Exception {
this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
this.testJarFile.addFile("META-INF/INDEX.LIST", this.temporaryFolder.newFile("INDEX.LIST"));
File indexList = new File(this.tempDir, "INDEX.LIST");
indexList.createNewFile();
this.testJarFile.addFile("META-INF/INDEX.LIST", indexList);
File source = this.testJarFile.getFile();
File dest = this.temporaryFolder.newFile("dest.jar");
File dest = new File(this.tempDir, "dest.jar");
Repackager repackager = new Repackager(source);
repackager.repackage(dest, NO_LIBRARIES);
try (JarFile jarFile = new JarFile(dest)) {
@@ -484,7 +485,7 @@ public class RepackagerTests {
}
@Test
public void customLayoutFactoryWithoutLayout() throws Exception {
void customLayoutFactoryWithoutLayout() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File source = this.testJarFile.getFile();
Repackager repackager = new Repackager(source, new TestLayoutFactory());
@@ -495,7 +496,7 @@ public class RepackagerTests {
}
@Test
public void customLayoutFactoryWithLayout() throws Exception {
void customLayoutFactoryWithLayout() throws Exception {
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
File source = this.testJarFile.getFile();
Repackager repackager = new Repackager(source, new TestLayoutFactory());
@@ -507,11 +508,13 @@ public class RepackagerTests {
}
@Test
public void metaInfAopXmlIsMovedBeneathBootInfClassesWhenRepackaged() throws Exception {
void metaInfAopXmlIsMovedBeneathBootInfClassesWhenRepackaged() throws Exception {
this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
this.testJarFile.addFile("META-INF/aop.xml", this.temporaryFolder.newFile("aop.xml"));
File aopXml = new File(this.tempDir, "aop.xml");
aopXml.createNewFile();
this.testJarFile.addFile("META-INF/aop.xml", aopXml);
File source = this.testJarFile.getFile();
File dest = this.temporaryFolder.newFile("dest.jar");
File dest = new File(this.tempDir, "dest.jar");
Repackager repackager = new Repackager(source);
repackager.repackage(dest, NO_LIBRARIES);
try (JarFile jarFile = new JarFile(dest)) {
@@ -521,10 +524,10 @@ public class RepackagerTests {
}
@Test
public void allEntriesUseUnixPlatformAndUtf8NameEncoding() throws IOException {
void allEntriesUseUnixPlatformAndUtf8NameEncoding() throws IOException {
this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
File source = this.testJarFile.getFile();
File dest = this.temporaryFolder.newFile("dest.jar");
File dest = new File(this.tempDir, "dest.jar");
Repackager repackager = new Repackager(source);
repackager.repackage(dest, NO_LIBRARIES);
try (ZipFile zip = new ZipFile(dest)) {
@@ -538,10 +541,10 @@ public class RepackagerTests {
}
@Test
public void loaderIsWrittenFirstThenApplicationClassesThenLibraries() throws IOException {
void loaderIsWrittenFirstThenApplicationClassesThenLibraries() throws IOException {
this.testJarFile.addClass("com/example/Application.class", ClassWithMainMethod.class);
File source = this.testJarFile.getFile();
File dest = this.temporaryFolder.newFile("dest.jar");
File dest = new File(this.tempDir, "dest.jar");
File libraryOne = createLibrary();
File libraryTwo = createLibrary();
File libraryThree = createLibrary();
@@ -557,12 +560,12 @@ public class RepackagerTests {
}
@Test
public void existingEntryThatMatchesUnpackLibraryIsMarkedForUnpack() throws IOException {
void existingEntryThatMatchesUnpackLibraryIsMarkedForUnpack() throws IOException {
File library = createLibrary();
this.testJarFile.addClass("WEB-INF/classes/com/example/Application.class", ClassWithMainMethod.class);
this.testJarFile.addFile("WEB-INF/lib/" + library.getName(), library);
File source = this.testJarFile.getFile("war");
File dest = this.temporaryFolder.newFile("dest.war");
File dest = new File(this.tempDir, "dest.war");
Repackager repackager = new Repackager(source);
repackager.setLayout(new Layouts.War());
repackager.repackage(dest, (callback) -> callback.library(new Library(library, LibraryScope.COMPILE, true)));
@@ -573,8 +576,8 @@ public class RepackagerTests {
}
@Test
public void layoutCanOmitLibraries() throws IOException {
TestJarFile libJar = new TestJarFile(this.temporaryFolder);
void layoutCanOmitLibraries() throws IOException {
TestJarFile libJar = new TestJarFile(this.tempDir);
libJar.addClass("a/b/C.class", ClassWithoutMainMethod.class);
File libJarFile = libJar.getFile();
this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class);
@@ -589,8 +592,8 @@ public class RepackagerTests {
}
@Test
public void jarThatUsesCustomCompressionConfigurationCanBeRepackaged() throws IOException {
File source = this.temporaryFolder.newFile("source.jar");
void jarThatUsesCustomCompressionConfigurationCanBeRepackaged() throws IOException {
File source = new File(this.tempDir, "source.jar");
ZipOutputStream output = new ZipOutputStream(new FileOutputStream(source)) {
{
this.def = new Deflater(Deflater.NO_COMPRESSION, true);
@@ -603,18 +606,18 @@ public class RepackagerTests {
output.write(data);
output.closeEntry();
output.close();
File dest = this.temporaryFolder.newFile("dest.jar");
File dest = new File(this.tempDir, "dest.jar");
Repackager repackager = new Repackager(source);
repackager.setMainClass("com.example.Main");
repackager.repackage(dest, NO_LIBRARIES);
}
@Test
public void moduleInfoClassRemainsInRootOfJarWhenRepackaged() throws Exception {
void moduleInfoClassRemainsInRootOfJarWhenRepackaged() throws Exception {
this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
this.testJarFile.addClass("module-info.class", ClassWithoutMainMethod.class);
File source = this.testJarFile.getFile();
File dest = this.temporaryFolder.newFile("dest.jar");
File dest = new File(this.tempDir, "dest.jar");
Repackager repackager = new Repackager(source);
repackager.repackage(dest, NO_LIBRARIES);
try (JarFile jarFile = new JarFile(dest)) {
@@ -624,11 +627,13 @@ public class RepackagerTests {
}
@Test
public void kotlinModuleMetadataMovesBeneathBootInfClassesWhenRepackaged() throws Exception {
void kotlinModuleMetadataMovesBeneathBootInfClassesWhenRepackaged() throws Exception {
this.testJarFile.addClass("A.class", ClassWithMainMethod.class);
this.testJarFile.addFile("META-INF/test.kotlin_module", this.temporaryFolder.newFile("test.kotlin_module"));
File kotlinModule = new File(this.tempDir, "test.kotlin_module");
kotlinModule.createNewFile();
this.testJarFile.addFile("META-INF/test.kotlin_module", kotlinModule);
File source = this.testJarFile.getFile();
File dest = this.temporaryFolder.newFile("dest.jar");
File dest = new File(this.tempDir, "dest.jar");
Repackager repackager = new Repackager(source);
repackager.repackage(dest, NO_LIBRARIES);
try (JarFile jarFile = new JarFile(dest)) {
@@ -638,7 +643,7 @@ public class RepackagerTests {
}
private File createLibrary() throws IOException {
TestJarFile library = new TestJarFile(this.temporaryFolder);
TestJarFile library = new TestJarFile(this.tempDir);
library.addClass("com/example/library/Library.class", ClassWithoutMainMethod.class);
return library.getFile();
}

View File

@@ -24,10 +24,10 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import org.junit.rules.TemporaryFolder;
import org.zeroturnaround.zip.FileSource;
import org.zeroturnaround.zip.ZipEntrySource;
import org.zeroturnaround.zip.ZipUtil;
@@ -40,15 +40,15 @@ public class TestJarFile {
private final byte[] buffer = new byte[4096];
private final TemporaryFolder temporaryFolder;
private final File temporaryFolder;
private final File jarSource;
private final List<ZipEntrySource> entries = new ArrayList<>();
public TestJarFile(TemporaryFolder temporaryFolder) throws IOException {
public TestJarFile(File temporaryFolder) throws IOException {
this.temporaryFolder = temporaryFolder;
this.jarSource = temporaryFolder.newFolder();
this.jarSource = new File(temporaryFolder, "jar-source");
}
public void addClass(String filename, Class<?> classToCopy) throws IOException {
@@ -120,8 +120,7 @@ public class TestJarFile {
}
public File getFile(String extension) throws IOException {
File file = this.temporaryFolder.newFile();
file = new File(file.getParent(), file.getName() + "." + extension);
File file = new File(this.temporaryFolder, UUID.randomUUID() + "." + extension);
ZipUtil.pack(this.entries.toArray(new ZipEntrySource[0]), file);
return file;
}

View File

@@ -24,16 +24,16 @@ package org.springframework.boot.loader.tools;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.boot.loader.tools.JarWriter.ZipHeaderPeekInputStream;
import static org.assertj.core.api.Assertions.assertThat;
public class ZipHeaderPeekInputStreamTests {
class ZipHeaderPeekInputStreamTests {
@Test
public void hasZipHeaderReturnsTrueWhenStreamStartsWithZipHeader() throws IOException {
void hasZipHeaderReturnsTrueWhenStreamStartsWithZipHeader() throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(
new ByteArrayInputStream(new byte[] { 0x50, 0x4b, 0x03, 0x04, 5, 6 }))) {
assertThat(in.hasZipHeader()).isTrue();
@@ -41,7 +41,7 @@ public class ZipHeaderPeekInputStreamTests {
}
@Test
public void hasZipHeaderReturnsFalseWhenStreamDoesNotStartWithZipHeader() throws IOException {
void hasZipHeaderReturnsFalseWhenStreamDoesNotStartWithZipHeader() throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(
new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 }))) {
assertThat(in.hasZipHeader()).isFalse();
@@ -49,7 +49,7 @@ public class ZipHeaderPeekInputStreamTests {
}
@Test
public void readIndividualBytes() throws IOException {
void readIndividualBytes() throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(
new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 }))) {
assertThat(in.read()).isEqualTo(0);
@@ -62,7 +62,7 @@ public class ZipHeaderPeekInputStreamTests {
}
@Test
public void readMultipleBytes() throws IOException {
void readMultipleBytes() throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(
new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 }))) {
byte[] bytes = new byte[3];
@@ -75,7 +75,7 @@ public class ZipHeaderPeekInputStreamTests {
}
@Test
public void readingMoreThanEntireStreamReadsToEndOfStream() throws IOException {
void readingMoreThanEntireStreamReadsToEndOfStream() throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(
new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 }))) {
byte[] bytes = new byte[8];
@@ -86,7 +86,7 @@ public class ZipHeaderPeekInputStreamTests {
}
@Test
public void readOfSomeOfTheHeaderThenMoreThanEntireStreamReadsToEndOfStream() throws IOException {
void readOfSomeOfTheHeaderThenMoreThanEntireStreamReadsToEndOfStream() throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(
new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 }))) {
byte[] bytes = new byte[8];
@@ -98,7 +98,7 @@ public class ZipHeaderPeekInputStreamTests {
}
@Test
public void readMoreThanEntireStreamWhenStreamLengthIsLessThanZipHeaderLength() throws IOException {
void readMoreThanEntireStreamWhenStreamLengthIsLessThanZipHeaderLength() throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(new ByteArrayInputStream(new byte[] { 10 }))) {
byte[] bytes = new byte[8];
assertThat(in.read(bytes)).isEqualTo(1);
@@ -107,7 +107,7 @@ public class ZipHeaderPeekInputStreamTests {
}
@Test
public void readMoreThanEntireStreamWhenStreamLengthIsSameAsHeaderLength() throws IOException {
void readMoreThanEntireStreamWhenStreamLengthIsSameAsHeaderLength() throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(
new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 }))) {
byte[] bytes = new byte[8];
@@ -117,7 +117,7 @@ public class ZipHeaderPeekInputStreamTests {
}
@Test
public void readMoreThanEntireStreamWhenStreamLengthIsZero() throws IOException {
void readMoreThanEntireStreamWhenStreamLengthIsZero() throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(new ByteArrayInputStream(new byte[0]))) {
byte[] bytes = new byte[8];
assertThat(in.read(bytes)).isEqualTo(-1);