[jboss-cvs] JBossAS SVN: r75170 - in projects/vfs/trunk/src: test/java/org/jboss/test/virtual/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Jun 28 17:29:09 EDT 2008


Author: alesj
Date: 2008-06-28 17:29:09 -0400 (Sat, 28 Jun 2008)
New Revision: 75170

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/zip/ZipDirWrapper.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CustomTestCase.java
Log:
[JBVFS-42]; fix nested dir content read.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/zip/ZipDirWrapper.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/zip/ZipDirWrapper.java	2008-06-28 20:13:05 UTC (rev 75169)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/zip/ZipDirWrapper.java	2008-06-28 21:29:09 UTC (rev 75170)
@@ -55,7 +55,13 @@
 
    InputStream openStream(ZipEntry ent) throws IOException
    {
-      return getRootAsStream();
+      zisCopy.reset();
+      // TODO - optimize this
+      ZipInputStream zis = new ZipInputStream(zisCopy);
+      ZipEntry entry = zis.getNextEntry();
+      while (entry != null && entry.getName().equals(ent.getName()) == false)
+         entry = zis.getNextEntry();
+      return zis;
    }
 
    Enumeration<? extends ZipEntry> entries() throws IOException

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CustomTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CustomTestCase.java	2008-06-28 20:13:05 UTC (rev 75169)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CustomTestCase.java	2008-06-28 21:29:09 UTC (rev 75170)
@@ -21,6 +21,7 @@
  */
 package org.jboss.test.virtual.test;
 
+import java.io.InputStream;
 import java.net.URL;
 import java.util.List;
 
@@ -64,5 +65,31 @@
       List<String> resources = visitor.getResources();
       assertNotNull(resources);
       assertTrue("Resources empty", resources.size() > 0);
+      for (String path : resources)
+      {
+         VirtualFile clazz = file.getChild(path);
+         assertNotNull(clazz);
+         assertTrue(isClass(clazz));
+      }
    }
+
+   protected boolean isClass(VirtualFile file) throws Exception
+   {
+      InputStream is = file.openStream();
+      try
+      {
+         int read = is.read();
+         String cafebabe = "";
+         while(read >= 0 && cafebabe.length() < 8)
+         {
+            cafebabe += Integer.toHexString(read);
+            read = is.read();
+         }
+         return "CAFEBABE".equalsIgnoreCase(cafebabe);
+      }
+      finally
+      {
+         is.close();
+      }
+   }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list