powerbroker commented on code in PR #34:
URL: https://github.com/apache/geronimo-xbean/pull/34#discussion_r1150759772
##########
xbean-finder/src/test/java/org/apache/xbean/finder/archive/JarArchiveTest.java:
##########
@@ -113,35 +114,75 @@ public void testIterator() throws Exception {
assertEquals(classes.length, actual.size());
}
- private List<String> list(final JarArchive archive) {
- final List<String> actual = new ArrayList<>();
- for (final Archive.Entry entry : archive) {
- actual.add(entry.getName());
+ @Test
+ public void testXBEAN337() throws Exception {
+
+
+ // Virtual path
+
+ String path = "/this!/!file!/does!/!not/exist.jar";
+ URL[] urls = {new URL("jar:file:" + path +
"!/some!/!inner!/.jar!/file.jar")};
+
+ try(JarArchive jar = new JarArchive(new URLClassLoader(urls),
urls[0])){
+
+ }catch(Exception ex){
+ Assert.assertTrue(String.format(
+ "Muzz never fail on '/this', but try full path with
exclamations('%s') instead",
+ path),
+ ex.getCause().getMessage().contains("exist.jar"));
+ }
+
+
+ // Real file
+
+ File tmpDir = testTmpDir.newFolder("!" +
JarArchiveTest.class.getSimpleName() + "!-temp!");
+
+ File exclamated = Files.copy(JarArchiveTest.classpath.toPath(),
+ tmpDir.toPath().resolve(
+ JarArchiveTest.classpath.getName()))
+ .toFile();
+
+ urls[0] = new URL("jar:" + exclamated.toURI().toURL() + "!/");
+
+ try(JarArchive jar = new JarArchive(new URLClassLoader(urls),
urls[0])){
+
+ Assert.assertEquals(String.format("Muzz successfully open '%s'",
exclamated.getAbsolutePath()),
+ this.archive.iterator().hasNext(),
+ jar.iterator().hasNext());
+ }
+
+
+ // Unsupported protocols stack
+
+ urls[0] = new URL("http:ftp:jar:" + exclamated.toURI().toURL() + "!/");
+
+ try(JarArchive jar = new JarArchive(new URLClassLoader(urls),
urls[0])){
+ Assert.fail(String.format("Muzz eat only local file URLs:"
+ + " 'file:/...' or 'jar:file:/...!/' but not '%s'",
+ urls[0]));
+ }catch(UnsupportedOperationException ex){
Review Comment:
it's my mistake, definitely IllegalArgumentException should be instead of
UnsupportedOperationException.
the test fails with UnsupportedOperationException, i wonder how i could miss
it.
guys, my project configuration is now broken. can i kindly ask you to
include this little fix into your commits?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]