Commit 4cdfd6f1 authored by Stephane Nicoll's avatar Stephane Nicoll

Polish "Handle missing manifest files in JarTypeFilter"

See gh-24597
parent 86eecb01
...@@ -65,12 +65,12 @@ class JarTypeFilterTests { ...@@ -65,12 +65,12 @@ class JarTypeFilterTests {
assertThat(new JarTypeFilter().filter(createArtifactWithNoManifest())).isFalse(); assertThat(new JarTypeFilter().filter(createArtifactWithNoManifest())).isFalse();
} }
private Artifact createArtifact(String jarType) { private Artifact createArtifact(String springBootJarType) {
Path jarPath = this.temp.resolve("test.jar"); Path jarPath = this.temp.resolve("test.jar");
Manifest manifest = new Manifest(); Manifest manifest = new Manifest();
manifest.getMainAttributes().putValue("Manifest-Version", "1.0"); manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
if (jarType != null) { if (springBootJarType != null) {
manifest.getMainAttributes().putValue("Spring-Boot-Jar-Type", jarType); manifest.getMainAttributes().putValue("Spring-Boot-Jar-Type", springBootJarType);
} }
try { try {
new JarOutputStream(new FileOutputStream(jarPath.toFile()), manifest).close(); new JarOutputStream(new FileOutputStream(jarPath.toFile()), manifest).close();
...@@ -78,9 +78,7 @@ class JarTypeFilterTests { ...@@ -78,9 +78,7 @@ class JarTypeFilterTests {
catch (IOException ex) { catch (IOException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
Artifact artifact = mock(Artifact.class); return mockArtifact(jarPath);
given(artifact.getFile()).willReturn(jarPath.toFile());
return artifact;
} }
private Artifact createArtifactWithNoManifest() { private Artifact createArtifactWithNoManifest() {
...@@ -91,6 +89,10 @@ class JarTypeFilterTests { ...@@ -91,6 +89,10 @@ class JarTypeFilterTests {
catch (IOException ex) { catch (IOException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
return mockArtifact(jarPath);
}
private Artifact mockArtifact(Path jarPath) {
Artifact artifact = mock(Artifact.class); Artifact artifact = mock(Artifact.class);
given(artifact.getFile()).willReturn(jarPath.toFile()); given(artifact.getFile()).willReturn(jarPath.toFile());
return artifact; return artifact;
......
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