Skip to content

Commit 4cdfd6f

Browse files
committed
Polish "Handle missing manifest files in JarTypeFilter"
See gh-24597
1 parent 86eecb0 commit 4cdfd6f

File tree

1 file changed

+8
-6
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven

1 file changed

+8
-6
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/JarTypeFilterTests.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,20 @@ void whenArtifactHasNoManifestFileThenItIsIncluded() {
6565
assertThat(new JarTypeFilter().filter(createArtifactWithNoManifest())).isFalse();
6666
}
6767

68-
private Artifact createArtifact(String jarType) {
68+
private Artifact createArtifact(String springBootJarType) {
6969
Path jarPath = this.temp.resolve("test.jar");
7070
Manifest manifest = new Manifest();
7171
manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
72-
if (jarType != null) {
73-
manifest.getMainAttributes().putValue("Spring-Boot-Jar-Type", jarType);
72+
if (springBootJarType != null) {
73+
manifest.getMainAttributes().putValue("Spring-Boot-Jar-Type", springBootJarType);
7474
}
7575
try {
7676
new JarOutputStream(new FileOutputStream(jarPath.toFile()), manifest).close();
7777
}
7878
catch (IOException ex) {
7979
throw new RuntimeException(ex);
8080
}
81-
Artifact artifact = mock(Artifact.class);
82-
given(artifact.getFile()).willReturn(jarPath.toFile());
83-
return artifact;
81+
return mockArtifact(jarPath);
8482
}
8583

8684
private Artifact createArtifactWithNoManifest() {
@@ -91,6 +89,10 @@ private Artifact createArtifactWithNoManifest() {
9189
catch (IOException ex) {
9290
throw new RuntimeException(ex);
9391
}
92+
return mockArtifact(jarPath);
93+
}
94+
95+
private Artifact mockArtifact(Path jarPath) {
9496
Artifact artifact = mock(Artifact.class);
9597
given(artifact.getFile()).willReturn(jarPath.toFile());
9698
return artifact;

0 commit comments

Comments
 (0)