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


##########
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:
   ```
   Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29)
   Maven home: /home/rmannibucau/.sdkman/candidates/mvnd/0.9.0
   Java version: 1.8.0_312, vendor: Azul Systems, Inc., runtime: 
/home/rmannibucau/.sdkman/candidates/java/8.0.312-zulu/jre
   Default locale: fr_FR, platform encoding: UTF-8
   OS name: "linux", version: "5.19.0-35-generic", arch: "amd64", family: "unix"
   ```
   
   master, no diff and build is green, we should likely refine why to ensure we 
dont hide an issue in tests IMHO
   will try to look in a few hours why it passes for me
   
   ok, found my issue, got some intermediary state of previous PR, mea culpa, 
ok to drop UnsupportedOpEx



-- 
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