Index: src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java =================================================================== --- src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java (revision 78086) +++ src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java (working copy) @@ -26,11 +26,13 @@ import java.net.URL; import java.util.Arrays; import java.util.HashSet; +import java.util.Set; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; import junit.framework.Test; import junit.framework.TestSuite; + import org.jboss.virtual.VFS; import org.jboss.virtual.VirtualFile; import org.jboss.virtual.plugins.context.file.FileSystemContext; @@ -274,44 +276,43 @@ // Access the classes contents as a jar file URL classesURL = classes.toURL(); String[] entryNames = { - "META-INF/MANIFEST.MF", - "WEB-INF/", - "WEB-INF/classes/", - "WEB-INF/classes/com/", - "WEB-INF/classes/com/sun/", - "WEB-INF/classes/com/sun/ts/", - "WEB-INF/classes/com/sun/ts/tests/", - "WEB-INF/classes/com/sun/ts/tests/ejb30/", - "WEB-INF/classes/com/sun/ts/tests/ejb30/persistence/", - "WEB-INF/classes/com/sun/ts/tests/ejb30/persistence/ee/", - "WEB-INF/classes/com/sun/ts/tests/ejb30/persistence/ee/packaging/", - "WEB-INF/classes/com/sun/ts/tests/ejb30/persistence/ee/packaging/web/", - "WEB-INF/classes/com/sun/ts/tests/ejb30/persistence/ee/packaging/web/scope/", - "WEB-INF/classes/com/sun/ts/tests/ejb30/persistence/ee/packaging/web/scope/ServletTest.class", - "WEB-INF/classes/com/sun/ts/tests/ejb30/persistence/ee/common/", - "WEB-INF/classes/com/sun/ts/tests/ejb30/persistence/ee/common/Account.class", - "WEB-INF/classes/com/sun/ts/tests/servlet/", - "WEB-INF/classes/com/sun/ts/tests/servlet/common/", - "WEB-INF/classes/com/sun/ts/tests/servlet/common/servlets/", - "WEB-INF/classes/com/sun/ts/tests/servlet/common/servlets/HttpTCKServlet.class", - "WEB-INF/classes/com/sun/ts/tests/servlet/common/util/", - "WEB-INF/classes/com/sun/ts/tests/servlet/common/util/Data.class", - "WEB-INF/classes/META-INF/", - "WEB-INF/classes/META-INF/persistence.xml", - "WEB-INF/web.xml", - "WEB-INF/jboss-web.xml" + "com/", + "com/sun/", + "com/sun/ts/", + "com/sun/ts/tests/", + "com/sun/ts/tests/ejb30/", + "com/sun/ts/tests/ejb30/persistence/", + "com/sun/ts/tests/ejb30/persistence/ee/", + "com/sun/ts/tests/ejb30/persistence/ee/packaging/", + "com/sun/ts/tests/ejb30/persistence/ee/packaging/web/", + "com/sun/ts/tests/ejb30/persistence/ee/packaging/web/scope/", + "com/sun/ts/tests/ejb30/persistence/ee/packaging/web/scope/ServletTest.class", + "com/sun/ts/tests/ejb30/persistence/ee/common/", + "com/sun/ts/tests/ejb30/persistence/ee/common/Account.class", + "com/sun/ts/tests/servlet/", + "com/sun/ts/tests/servlet/common/", + "com/sun/ts/tests/servlet/common/servlets/", + "com/sun/ts/tests/servlet/common/servlets/HttpTCKServlet.class", + "com/sun/ts/tests/servlet/common/util/", + "com/sun/ts/tests/servlet/common/util/Data.class", + "META-INF/", + "META-INF/persistence.xml", }; JarInputStream jis = new JarInputStream( classesURL.openStream() ); HashSet missingEntries = new HashSet(Arrays.asList(entryNames)); + Set excess = new HashSet(); int count = 0; JarEntry jarEntry; while((jarEntry = jis.getNextJarEntry()) != null) { String name = jarEntry.getName(); - missingEntries.remove(name); + boolean removed = missingEntries.remove(name); + if(!removed) + excess.add(name); count ++; } assertEquals("No missing entries: "+missingEntries, 0, missingEntries.size()); + assertEquals("Excess entries: " + excess, 0, excess.size()); classes.closeStreams(); } Index: src/main/java/org/jboss/virtual/plugins/context/zip/ZipStreamWrapper.java =================================================================== --- src/main/java/org/jboss/virtual/plugins/context/zip/ZipStreamWrapper.java (revision 78086) +++ src/main/java/org/jboss/virtual/plugins/context/zip/ZipStreamWrapper.java (working copy) @@ -21,15 +21,11 @@ */ package org.jboss.virtual.plugins.context.zip; -import org.jboss.logging.Logger; -import org.jboss.virtual.VFSUtils; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Enumeration; @@ -40,6 +36,9 @@ import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; +import org.jboss.logging.Logger; +import org.jboss.virtual.VFSUtils; + /** * ZipStreamWrapper - for abstracted access to in-memory zip file * @@ -170,9 +169,18 @@ while(it.hasNext()) { InMemoryFile memFile = it.next(); - if (memFile.entry.getName().startsWith(path)) + ZipEntry oldEntry = memFile.entry; + if (oldEntry.getName().startsWith(path)) { - zout.putNextEntry(memFile.entry); + String n = oldEntry.getName().substring(path.length()); + if(n.length() == 0) + continue; + ZipEntry newEntry = new ZipEntry(n); + newEntry.setComment(oldEntry.getComment()); + newEntry.setTime(oldEntry.getTime()); + newEntry.setSize(oldEntry.getSize()); + newEntry.setCrc(oldEntry.getCrc()); + zout.putNextEntry(newEntry); zout.write(memFile.fileBytes); } }