Skip to content

Commit

Permalink
Polish "Handle missing manifest files in JarTypeFilter"
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Dec 23, 2020
1 parent 86eecb0 commit 4cdfd6f
Showing 1 changed file with 8 additions and 6 deletions.
Expand Up @@ -65,22 +65,20 @@ void whenArtifactHasNoManifestFileThenItIsIncluded() {
assertThat(new JarTypeFilter().filter(createArtifactWithNoManifest())).isFalse();
}

private Artifact createArtifact(String jarType) {
private Artifact createArtifact(String springBootJarType) {
Path jarPath = this.temp.resolve("test.jar");
Manifest manifest = new Manifest();
manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
if (jarType != null) {
manifest.getMainAttributes().putValue("Spring-Boot-Jar-Type", jarType);
if (springBootJarType != null) {
manifest.getMainAttributes().putValue("Spring-Boot-Jar-Type", springBootJarType);
}
try {
new JarOutputStream(new FileOutputStream(jarPath.toFile()), manifest).close();
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
Artifact artifact = mock(Artifact.class);
given(artifact.getFile()).willReturn(jarPath.toFile());
return artifact;
return mockArtifact(jarPath);
}

private Artifact createArtifactWithNoManifest() {
Expand All @@ -91,6 +89,10 @@ private Artifact createArtifactWithNoManifest() {
catch (IOException ex) {
throw new RuntimeException(ex);
}
return mockArtifact(jarPath);
}

private Artifact mockArtifact(Path jarPath) {
Artifact artifact = mock(Artifact.class);
given(artifact.getFile()).willReturn(jarPath.toFile());
return artifact;
Expand Down

0 comments on commit 4cdfd6f

Please sign in to comment.