powerbroker commented on code in PR #34:
URL: https://github.com/apache/geronimo-xbean/pull/34#discussion_r1150773605


##########
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:
   i just have no idea how i could commit a failing test 3 months ago... and 
how @rmannibucau could accept it...
   
   but now in my(obsolete & broken) context the test fails - there is 'throw 
IllegalArgument..' in constructor AND 'catch UnsupportedOp...' in test



-- 
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: dev-unsubscr...@geronimo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to