Skip to content

Commit

Permalink
use different implementation
Browse files Browse the repository at this point in the history
by @pkriens
adjust testcases since this version uses different messages and treats MERGE differently than the previous implementation.
Basically now if a MERGE is not supported / possible, then the existing file is kept (is NOT overwritten).

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
  • Loading branch information
chrisrueger committed Oct 30, 2024
1 parent e57320e commit 85b01b5
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 158 deletions.
26 changes: 13 additions & 13 deletions biz.aQute.bndlib.tests/test/test/IncludeResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void testIncludeResourceDuplicatesDefaultOverwrite() throws Exception {
Jar jar = a.build();
assertFalse(a.check());
assertEquals(
"Duplicate file overwritten: META-INF/services/foo (Consider using the onduplicate: directive to handle duplicates.)",
"includeresource.duplicates: Duplicate overwritten: META-INF/services/foo (Consider using the onduplicate: directive to handle duplicates.)",
a.getWarnings()
.get(0));

Expand Down Expand Up @@ -266,7 +266,7 @@ public void testIncludeResourceMixedMetaInfDuplicatesMerge() throws Exception {
assertEquals("a\nb", IO.collect(resourceFoo.openInputStream()));

Resource resourceManifest = jar.getResource("META-INF/bar.txt");
assertEquals("b", IO.collect(resourceManifest.openInputStream()));
assertEquals("a", IO.collect(resourceManifest.openInputStream()));

}
}
Expand Down Expand Up @@ -300,7 +300,7 @@ public void testIncludeResourceDuplicatesError() throws Exception {
"@jar/jarA.jar!/META-INF/services/*, @jar/jarB.jar!/META-INF/services/*;onduplicate:=ERROR");
Jar jar = a.build();
assertFalse(a.check());
assertEquals("Duplicate file: META-INF/services/foo", a.getErrors()
assertEquals("includeresource.duplicates: duplicate found for path META-INF/services/foo", a.getErrors()
.get(0));

assertTrue(jar.getDirectories()
Expand All @@ -322,7 +322,7 @@ public void testIncludeResourceDuplicatesWarning() throws Exception {
"@jar/jarA.jar!/META-INF/services/*, @jar/jarB.jar!/META-INF/services/*;onduplicate:=WARN");
Jar jar = a.build();
assertFalse(a.check());
assertEquals("Duplicate file: META-INF/services/foo", a.getWarnings()
assertEquals("includeresource.duplicates: duplicate found for path META-INF/services/foo", a.getWarnings()
.get(0));

assertTrue(jar.getDirectories()
Expand Down Expand Up @@ -387,7 +387,7 @@ public void testIncludeResourceLiteralDuplicatesMerge(@InjectTemporaryDirectory
b.getJar()
.writeFolder(tmp);

assertEquals("b", IO.collect(IO.getFile(tmp, "a/a.txt")));
assertEquals("a", IO.collect(IO.getFile(tmp, "a/a.txt")));
}
}

Expand Down Expand Up @@ -416,7 +416,7 @@ public void testIncludeResourceLiteralDuplicatesError(@InjectTemporaryDirectory
b.setIncludeResource("/a/a.txt;literal='a', /a/a.txt;literal='b';onduplicate:=ERROR");
b.build();
assertFalse(b.check());
assertEquals("Duplicate file: /a/a.txt", b.getErrors()
assertEquals("includeresource.duplicates: duplicate found for path /a/a.txt", b.getErrors()
.get(0));

b.getJar()
Expand Down Expand Up @@ -461,12 +461,12 @@ public void testIncludeResourceDuplicatesMergeWithoutPlugin() throws Exception {
.containsKey("META-INF/services"));

Resource resource = jar.getResource("META-INF/services/foo");
// we expect OVERWRITE because there is no plugin with the tag
// we expect nothing because there is no plugin with the tag
// 'nonexistingtag'
// which means we have nothing which can merge META-INF/services
// files.
// so the default OVERWRITE behavior applies
assertEquals("b", IO.collect(resource.openInputStream()));
// so we keep the existing file
assertEquals("a", IO.collect(resource.openInputStream()));

}

Expand Down Expand Up @@ -507,12 +507,12 @@ public void testIncludeResourceDuplicatesTagWithoutStrategyEnumButNonExistingTag
.containsKey("META-INF/services"));

Resource resource = jar.getResource("META-INF/services/foo");
// we expect OVERWRITE because there is no plugin with the tag
// we expect nothing because there is no plugin with the tag
// 'nonexistingtag'
// which means we have nothing which can merge META-INF/services
// files.
// so the default OVERWRITE behavior applies
assertEquals("b", IO.collect(resource.openInputStream()));
// so we keep the existing file
assertEquals("a", IO.collect(resource.openInputStream()));

}
}
Expand All @@ -527,7 +527,7 @@ public void testIncludeResourceDuplicatesMergeWithTagAndWarn() throws Exception
"@jar/jarA.jar!/META-INF/services/*, @jar/jarB.jar!/META-INF/services/*;onduplicate:='MERGE,metainfservices,WARN'");
Jar jar = a.build();
assertFalse(a.check());
assertEquals("Duplicate file: META-INF/services/foo", a.getWarnings()
assertEquals("includeresource.duplicates: duplicate found for path META-INF/services/foo", a.getWarnings()
.get(0));

assertTrue(jar.getDirectories()
Expand Down
Loading

0 comments on commit 85b01b5

Please sign in to comment.