diff --git a/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java b/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java index 0b687b32..aee8bf24 100644 --- a/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java +++ b/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java @@ -252,7 +252,7 @@ private void init(URL localRootURL, VirtualFileHandler peer, ZipWrapper zipWrapp // init initial root EntryInfo that will be overwritten // if zip entry exists for rootEntryPath - entries.put("", new EntryInfo(new ZipEntryHandler(this, null, name, true), null)); + entries.put("", new EntryInfo(new ZipEntryHandler(this, null, name, false), null)); // It's lazy init now //initEntries(); diff --git a/src/test/java/org/jboss/test/virtual/test/FileCleanupUnitTest.java b/src/test/java/org/jboss/test/virtual/test/FileCleanupUnitTest.java index b2c86078..c40d056e 100644 --- a/src/test/java/org/jboss/test/virtual/test/FileCleanupUnitTest.java +++ b/src/test/java/org/jboss/test/virtual/test/FileCleanupUnitTest.java @@ -291,16 +291,27 @@ public void testTempUrls() throws Exception VirtualFile ear = root.getChild("level1.zip"); VirtualFile earCopy = modify(ear); + assertEquals(ear.toURL(), earCopy.toURL()); assertEquals(getProtocol() + urlString + "level1.zip/", earCopy.toURL().toExternalForm()); + VirtualFile o2 = ear.getChild("level2.zip"); VirtualFile l2 = earCopy.getChild("level2.zip"); + assertEquals(o2.toURL(), l2.toURL()); assertEquals(getProtocol() + urlString + "level1.zip/level2.zip/", l2.toURL().toExternalForm()); + + VirtualFile o2sub = o2.getChild("test2.txt"); VirtualFile l2sub = l2.getChild("test2.txt"); + assertEquals(o2sub.toURL(), l2sub.toURL()); assertEquals(getProtocol() + urlString + "level1.zip/level2.zip/test2.txt", l2sub.toURL().toExternalForm()); + VirtualFile o3 = o2.getChild("level3.zip"); VirtualFile l3 = l2.getChild("level3.zip"); + assertEquals(o3.toURL(), l3.toURL()); assertEquals(getProtocol() + urlString + "level1.zip/level2.zip/level3.zip/", l3.toURL().toExternalForm()); + + VirtualFile o3sub = o3.getChild("test3.txt"); VirtualFile l3sub = l3.getChild("test3.txt"); + assertEquals(o3sub.toURL(), l3sub.toURL()); assertEquals(getProtocol() + urlString + "level1.zip/level2.zip/level3.zip/test3.txt", l3sub.toURL().toExternalForm()); ear.cleanup(); diff --git a/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java b/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java index 50d2d59d..6dae5171 100644 --- a/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java +++ b/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java @@ -860,7 +860,7 @@ public void testVFJarSerialization() String name = tmpJar.getName(); String vfsPath = tmpJar.getPath(); vfsPath = vfsPath.substring(tmpRoot.getPath().length()+1); - URL url = new URL("vfs" + tmpJar.toURL()); + URL url = new URL("vfs" + tmpJar.toURL() + "/"); //url = JarUtils.createJarURL(url); log.debug("name: "+name); log.debug("vfsPath: "+vfsPath); @@ -1195,10 +1195,9 @@ public void testDirURLs() throws Exception log.debug("outerURL: "+outerURL); assertTrue(outerURL+" ends in '/'", outerURL.getPath().endsWith("/")); // Validate that jar1 is under unpacked-outer.jar - URL jar1URL = new URL(outerURL, "jar1.jar"); + URL jar1URL = new URL(outerURL, "jar1.jar/"); log.debug("jar1URL: "+jar1URL+", path="+jar1URL.getPath()); - assertTrue("jar1URL path ends in unpacked-outer.jar/jar1.jar!/", - jar1URL.getPath().endsWith("unpacked-outer.jar/jar1.jar")); + assertTrue("jar1URL path ends in unpacked-outer.jar/jar1.jar!/", jar1URL.getPath().endsWith("unpacked-outer.jar/jar1.jar/")); VirtualFile jar1 = outerJar.findChild("jar1.jar"); assertEquals(jar1URL.getPath(), jar1.toURL().getPath()); @@ -1224,17 +1223,15 @@ public void testDirURIs() throws Exception log.debug("outerURI: "+outerURI); assertTrue(outerURI+" ends in '/'", outerURI.getPath().endsWith("/")); // Validate that jar1 is under unpacked-outer.jar - URI jar1URI = new URI(outerURI+"jar1.jar"); + URI jar1URI = new URI(outerURI+"jar1.jar/"); log.debug("jar1URI: "+jar1URI+", path="+jar1URI.getPath()); - assertTrue("jar1URI path ends in unpacked-outer.jar/jar1.jar!/", - jar1URI.getPath().endsWith("unpacked-outer.jar/jar1.jar")); + assertTrue("jar1URI path ends in unpacked-outer.jar/jar1.jar!/", jar1URI.getPath().endsWith("unpacked-outer.jar/jar1.jar/")); VirtualFile jar1 = outerJar.findChild("jar1.jar"); assertEquals(jar1URI.getPath(), jar1.toURI().getPath()); VirtualFile packedJar = vfs.findChild("jar1.jar"); jar1URI = packedJar.findChild("org/jboss/test/vfs/support").toURI(); - assertTrue("Jar directory entry URLs must end in /: " + jar1URI.toString(), - jar1URI.toString().endsWith("/")); + assertTrue("Jar directory entry URLs must end in /: " + jar1URI.toString(), jar1URI.toString().endsWith("/")); } /** @@ -1391,8 +1388,8 @@ public void testJarWithSpacesInPath() VirtualFile tstjar = vfs.findChild("path with spaces/tst.jar"); assertNotNull("tstjar != null", tstjar); URI uri = tstjar.toURI(); - URI expectedURI = new URI("vfs"+rootURL.toString()+"/path%20with%20spaces/tst.jar"); - assertEquals(uri.getPath(), expectedURI.getPath()); + URI expectedURI = new URI("vfs"+rootURL.toString()+"/path%20with%20spaces/tst.jar/"); + assertEquals(expectedURI.getPath(), uri.getPath()); InputStream is = uri.toURL().openStream(); is.close(); @@ -1400,8 +1397,8 @@ public void testJarWithSpacesInPath() tstjar = vfs.findChild("path with spaces/tst%20nospace.jar"); assertNotNull("tstjar != null", tstjar); uri = tstjar.toURI(); - expectedURI = new URI("vfs"+rootURL.toString()+"/path%20with%20spaces/tst%2520nospace.jar"); - assertEquals(uri.getPath(), expectedURI.getPath()); + expectedURI = new URI("vfs"+rootURL.toString()+"/path%20with%20spaces/tst%2520nospace.jar/"); + assertEquals(expectedURI.getPath(), uri.getPath()); is = uri.toURL().openStream(); is.close();