[Jboss-cvs] JBossAS SVN: r56697 - in projects/microcontainer/trunk/container/src: main/org/jboss/virtual/plugins/context main/org/jboss/virtual/plugins/context/file main/org/jboss/virtual/plugins/context/jar tests/org/jboss/test/virtual/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Sep 9 12:55:25 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-09-09 12:55:15 -0400 (Sat, 09 Sep 2006)
New Revision: 56697

Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractURLHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/file/FileHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NoCopyNestedJarHandler.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestFileVFS.java
Log:
Add support for serialization of virtual files

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractURLHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractURLHandler.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractURLHandler.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -23,7 +23,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.Serializable;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -39,13 +38,13 @@
  * @version $Revision: 1.1 $
  */
 public abstract class AbstractURLHandler extends AbstractVirtualFileHandler
-   implements Serializable
 {
+   /** serialVersionUID */
    private static final long serialVersionUID = 1L;
 
    /** The url */
    private final URL url;
-   
+
    /**
     * Create a newURLHandler.
     * 
@@ -115,4 +114,5 @@
    {
       return url.toURI();
    }
+
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/AbstractVirtualFileHandler.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -27,9 +27,8 @@
 import java.io.ObjectStreamField;
 import java.io.ObjectInputStream.GetField;
 import java.io.ObjectOutputStream.PutField;
-import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -38,6 +37,8 @@
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.plugins.vfs.helpers.PathTokenizer;
 import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.VFSContextFactory;
+import org.jboss.virtual.spi.VFSContextFactoryLocator;
 import org.jboss.virtual.spi.VirtualFileHandler;
 
 /**
@@ -51,29 +52,36 @@
 {
    /** The log */
    protected final Logger log = Logger.getLogger(getClass());
+   /** serialVersionUID */
    private static final long serialVersionUID = 1L;
    /** The class serial fields */
    private static final ObjectStreamField[] serialPersistentFields = {
-      new ObjectStreamField("rootURL", URL.class),
-      new ObjectStreamField("url", URL.class),
+      new ObjectStreamField("rootURI", URI.class),
+      new ObjectStreamField("parent", VirtualFileHandler.class),
       new ObjectStreamField("name", String.class)
    };
 
-   /** The VFS context */
-   private transient VFSContext context;
+   /** The VFS context
+    * @serialField rootURI URI the VFS context rootURI
+    */
+   private VFSContext context;
    
-   /** The parent */
-   private final VirtualFileHandler parent;
+   /** The parent
+    * @serialField parent VirtualFileHandler the virtual file parent
+    */
+   private VirtualFileHandler parent;
 
-   /** The name */
-   private final String name;
-   
+   /** The name
+    * @serialField name String the virtual file name
+    */
+   private String name;
+
    /** The vfsPath */
    private transient String vfsPath;
 
    /** The reference count */
-   private AtomicInteger references = new AtomicInteger(0);
-   
+   private transient AtomicInteger references = new AtomicInteger(0);
+
    /**
     * Create a new handler
     * 
@@ -325,25 +333,22 @@
    private void writeObject(ObjectOutputStream out)
       throws IOException
    {
-      /*
-      // Write out the serialPersistentFields
       PutField fields = out.putFields();
-      fields.put("rootURL", this.getVFSContext().getRootURL());
-      fields.put("vfsPath", this.getPathName());
+      fields.put("rootURI", this.getVFSContext().getRootURI());
+      fields.put("parent", parent);
+      fields.put("name", name);
       out.writeFields();
-      */
-      out.defaultWriteObject();
    }
    private void readObject(ObjectInputStream in)
       throws IOException, ClassNotFoundException
    {
-      /*
       // Read in the serialPersistentFields
       GetField fields = in.readFields();
-      URL rootURL = (URL) fields.get("rootURL", null);
-      this.vfsPath = (String) fields.get("vfsPath", null);
-         VFSContextFactory factory = VFSContextFactoryLocator.getFactory(rootURL);
-         this.context = factory.getVFS(rootURL);
-      */
+      URI rootURI = (URI) fields.get("rootURI", null);
+      this.parent = (VirtualFileHandler) fields.get("parent", null);
+      this.name = (String) fields.get("name", null);
+      VFSContextFactory factory = VFSContextFactoryLocator.getFactory(rootURI);
+      this.context = factory.getVFS(rootURI);
+      this.references = new AtomicInteger(0);
    }
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/file/FileHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/file/FileHandler.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/file/FileHandler.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -26,7 +26,6 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -183,7 +182,7 @@
    {
       in.defaultReadObject();
       // Initialize the transient values
-      this.file = new File(super.getURL().getPath());
+      this.file = new File(getURL().getPath());
    }
 
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/AbstractJarHandler.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -22,9 +22,12 @@
 package org.jboss.virtual.plugins.context.jar;
 
 import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.JarURLConnection;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -40,16 +43,20 @@
  * AbstractJarHandler.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
  * @version $Revision: 1.1 $
  */
 public class AbstractJarHandler extends AbstractURLHandler
 {
+   /** serialVersionUID */
+   private static final long serialVersionUID = 1;
+
    /** The jar file */
-   private JarFile jar;
+   private transient JarFile jar;
 
    /** The jar entries */
-   private List<VirtualFileHandler> entries;
-   
+   private transient List<VirtualFileHandler> entries;
+
    /**
     * Get a jar entry name
     * 
@@ -118,7 +125,7 @@
          entries.add(handler);
       }
    }
-   
+
    protected void doClose()
    {
       /* TODO Figure out why this breaks things randomly
@@ -229,4 +236,31 @@
       }
       return vfh;
    }
+
+   /**
+    * Restore the jar file from the jar URL
+    * 
+    * @param in
+    * @throws IOException
+    * @throws ClassNotFoundException
+    */
+   private void readObject(ObjectInputStream in)
+      throws IOException, ClassNotFoundException
+   {
+      in.defaultReadObject();
+      // Initialize the transient values
+      URL jarURL = super.getURL();
+      URLConnection conn = jarURL.openConnection();
+      if( conn instanceof JarURLConnection )
+      {
+         JarURLConnection jconn = (JarURLConnection) conn;
+         JarFile jarFile = jconn.getJarFile();
+         initJarFile(jarFile);
+      }
+      else
+      {
+         throw new IOException("Cannot restore from non-JarURLConnection, url: "+jarURL);
+      }
+   }
+
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarEntryHandler.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -41,14 +41,15 @@
  */
 public class JarEntryHandler extends AbstractURLHandler
 {
+   /** serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
    /** The jar file */
    private final JarFile jar;
    
    /** The jar entry */
    private final JarEntry entry;
-
    
-   
    /**
     * Create a new JarHandler.
     * 

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarHandler.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/JarHandler.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -36,6 +36,9 @@
  */
 public class JarHandler extends AbstractJarHandler
 {
+   /** serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
    /**
     * Create a new JarHandler.
     * 

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -16,7 +16,6 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -33,6 +32,9 @@
 public class NestedJarFromStream
    extends AbstractVirtualFileHandler
 {
+   /** serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
    private ZipInputStream zis;
    private HashMap<String, JarEntryContents> entries = new HashMap<String, JarEntryContents>();
    private URL jarURL;
@@ -100,7 +102,7 @@
 
    public long getSize()
    {
-      return entries.size();
+      return size;
    }
 
    public long getLastModified() throws IOException
@@ -238,6 +240,8 @@
    public static class JarEntryContents
       extends AbstractVirtualFileHandler
    {
+      /** serialVersionUID */
+      private static final long serialVersionUID = 1L;
       private ZipEntry entry;
       private URL entryURL;
       private String vfsPath;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NestedJarHandler.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -40,8 +40,11 @@
  */
 public class NestedJarHandler extends AbstractJarHandler
 {
+   /** serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
    /** The jar entry */
-   private JarEntry entry;
+   private transient JarEntry entry;
    
    /**
     * Create a temporary jar

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NoCopyNestedJarHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NoCopyNestedJarHandler.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/NoCopyNestedJarHandler.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -21,8 +21,6 @@
 */
 package org.jboss.virtual.plugins.context.jar;
 
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -42,10 +40,12 @@
  */
 public class NoCopyNestedJarHandler extends AbstractJarHandler
 {
+   /** serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
    /** The jar entry */
    private JarEntry entry;
    private NestedJarFromStream njar;
-
       
    /**
     * Create a new NestedJarHandler.

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestFileVFS.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestFileVFS.java	2006-09-09 15:39:13 UTC (rev 56696)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestFileVFS.java	2006-09-09 16:55:15 UTC (rev 56697)
@@ -12,18 +12,21 @@
 import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.net.URI;
 import java.net.URL;
 import java.util.HashSet;
 import java.util.List;
 import java.util.jar.Attributes;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.ZipInputStream;
 
 import org.jboss.test.BaseTestCase;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
 import org.jboss.virtual.plugins.context.jar.NestedJarFromStream;
 import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
 import org.jboss.virtual.spi.VFSContext;
@@ -69,7 +72,6 @@
       JarFile jf = new JarFile(outerJar);
 
       URL rootURL = outerJar.getParentFile().toURL();
-      VFS vfs = VFS.getVFS(rootURL);
       VFSContextFactory factory = VFSContextFactoryLocator.getFactory(rootURL);
       VFSContext context = factory.getVFS(rootURL);
 
@@ -296,7 +298,7 @@
       Manifest mf = new Manifest(mfIS);
       Attributes mainAttrs = mf.getMainAttributes();
       String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar1", version);
+      assertEquals(Attributes.Name.SPECIFICATION_TITLE.toString(), "jar1", version);
       mfIS.close();
    }
 
@@ -355,24 +357,172 @@
       oos.writeObject(tmpVF);
       oos.close();
 
+      // Check the tmpVF attributes against the tmp file
+      long lastModified = tmp.lastModified();
+      long size = tmp.length();
+      String name = tmp.getName();
+      String vfsPath = tmp.getPath();
+      vfsPath = vfsPath.substring(tmpRoot.getPath().length()+1);
+      URL url = tmp.toURL();
+      log.debug("name: "+name);
+      log.debug("vfsPath: "+vfsPath);
+      log.debug("url: "+url);
+      log.debug("lastModified: "+lastModified);
+      log.debug("size: "+size);
+      assertEquals("name", name, tmpVF.getName());
+      assertEquals("pathName", vfsPath, tmpVF.getPathName());
+      assertEquals("lastModified", lastModified, tmpVF.getLastModified());
+      assertEquals("size", size, tmpVF.getSize());
+      assertEquals("url", url, tmpVF.toURL());
+      assertEquals("isArchive", false, tmpVF.isArchive());
+      assertEquals("isFile", true, tmpVF.isFile());
+      assertEquals("isDirectory", false, tmpVF.isDirectory());
+      assertEquals("isHidden", false, tmpVF.isHidden());
+
+      // Read in the VF from the serialized file
       FileInputStream fis = new FileInputStream(tmp);
       ObjectInputStream ois = new ObjectInputStream(fis);
       VirtualFile tmpVF2 = (VirtualFile) ois.readObject();
       ois.close();
-      long lastModified = tmpVF.getLastModified();
-      long size = tmpVF.getSize();
-      String name = tmpVF.getName();
-      String pathName = tmpVF.getPathName();
-      URL url = tmpVF.toURL();
+      // Validated the deserialized attribtes against the tmp file
+      assertEquals("name", name, tmpVF2.getName());
+      assertEquals("pathName", vfsPath, tmpVF2.getPathName());
+      assertEquals("lastModified", lastModified, tmpVF2.getLastModified());
+      assertEquals("size", size, tmpVF2.getSize());
+      assertEquals("url", url, tmpVF2.toURL());
+      assertEquals("isArchive", false, tmpVF2.isArchive());
+      assertEquals("isFile", true, tmpVF2.isFile());
+      assertEquals("isDirectory", false, tmpVF2.isDirectory());
+      assertEquals("isHidden", false, tmpVF2.isHidden());
+   }
 
+   /**
+    * Test the serialization of VirtualFiles representing a jar
+    * @throws Exception
+    */
+   public void testVFJarSerialization()
+      throws Exception
+   {
+      File tmpRoot = File.createTempFile("vfs", ".root");
+      tmpRoot.delete();
+      tmpRoot.mkdir();
+      tmpRoot.deleteOnExit();
+      // Create a test jar containing a txt file
+      File tmpJar = new File(tmpRoot, "tst.jar");
+      tmpJar.createNewFile();
+      tmpJar.deleteOnExit();
+      FileOutputStream fos = new FileOutputStream(tmpJar);
+      JarOutputStream jos = new JarOutputStream(fos);
+      // Write a text file to include in a test jar
+      JarEntry txtEntry = new JarEntry("tst.txt");
+      jos.putNextEntry(txtEntry);
+      txtEntry.setSize("testVFJarSerialization".length());
+      txtEntry.setTime(System.currentTimeMillis());
+      jos.write("testVFJarSerialization".getBytes());
+      jos.close();
+      log.info("+++ testVFJarSerialization, tmp="+tmpJar.getCanonicalPath());
+
+      URI rootURI = tmpRoot.toURI();
+      VFS vfs = VFS.getVFS(rootURI);
+      File vfsSer = new File(tmpRoot, "vfs.ser");
+      vfsSer.createNewFile();
+      vfsSer.deleteOnExit();
+
+      VirtualFile tmpVF = vfs.findChildFromRoot("tst.jar");
+      // Validate the vf jar against the tmp file attributes
+      long lastModified = tmpJar.lastModified();
+      long size = tmpJar.length();
+      String name = tmpJar.getName();
+      String vfsPath = tmpJar.getPath();
+      vfsPath = vfsPath.substring(tmpRoot.getPath().length()+1);
+      URL url = tmpJar.toURL();
+      url = JarUtils.createJarURL(url);
+      log.debug("name: "+name);
+      log.debug("vfsPath: "+vfsPath);
+      log.debug("url: "+url);
+      log.debug("lastModified: "+lastModified);
+      log.debug("size: "+size);
+      assertEquals("name", name, tmpVF.getName());
+      assertEquals("pathName", vfsPath, tmpVF.getPathName());
+      assertEquals("lastModified", lastModified, tmpVF.getLastModified());
+      assertEquals("size", size, tmpVF.getSize());
+      assertEquals("url", url, tmpVF.toURL());
+      assertEquals("isArchive", true, tmpVF.isArchive());
+      // TODO: these should pass
+      //assertEquals("isFile", true, tmpVF.isFile());
+      //assertEquals("isDirectory", false, tmpVF.isDirectory());
+      assertEquals("isHidden", false, tmpVF.isHidden());
+      // Write out the vfs jar file
+      fos = new FileOutputStream(vfsSer);
+      ObjectOutputStream oos = new ObjectOutputStream(fos);
+      oos.writeObject(tmpVF);
+      oos.close();
+
+      // Read in the VF from the serialized file
+      FileInputStream fis = new FileInputStream(vfsSer);
+      ObjectInputStream ois = new ObjectInputStream(fis);
+      VirtualFile tmpVF2 = (VirtualFile) ois.readObject();
+      ois.close();
+      // Validate the vf jar against the tmp file attributes
       assertEquals("name", name, tmpVF2.getName());
-      assertEquals("pathName", pathName, tmpVF2.getPathName());
+      assertEquals("pathName", vfsPath, tmpVF2.getPathName());
       assertEquals("lastModified", lastModified, tmpVF2.getLastModified());
       assertEquals("size", size, tmpVF2.getSize());
       assertEquals("url", url, tmpVF2.toURL());
+      assertEquals("isArchive", true, tmpVF2.isArchive());
+      // TODO: these should pass
+      //assertEquals("isFile", true, tmpVF2.isFile());
+      //assertEquals("isDirectory", false, tmpVF2.isDirectory());
+      assertEquals("isHidden", false, tmpVF2.isHidden());
    }
 
    /**
+    * Test the serialization of VirtualFiles representing a jar
+    * @throws Exception
+    */
+   public void testVFNestedJarSerialization()
+      throws Exception
+   {
+      // this expects to be run with a working dir of the container root
+      File outerJar = new File("output/lib/outer.jar");
+      File lib = outerJar.getParentFile();
+      URI rootURI = lib.toURI();
+      VFS vfs = VFS.getVFS(rootURI);
+      VirtualFile inner = vfs.findChildFromRoot("outer.jar/jar1.jar");
+
+      File vfsSer = new File(lib, "testVFNestedJarSerialization.ser");
+      vfsSer.createNewFile();
+      vfsSer.deleteOnExit();
+      // Write out the vfs inner jar file
+      FileOutputStream fos = new FileOutputStream(vfsSer);
+      ObjectOutputStream oos = new ObjectOutputStream(fos);
+      oos.writeObject(inner);
+      oos.close();
+
+      
+      // Read in the VF from the serialized file
+      FileInputStream fis = new FileInputStream(vfsSer);
+      ObjectInputStream ois = new ObjectInputStream(fis);
+      inner = (VirtualFile) ois.readObject();
+      ois.close();
+      List<VirtualFile> contents = inner.getChildren();
+      // META-INF/*, org/jboss/test/vfs/support/jar1/* at least
+      assertTrue("jar1.jar children.length("+contents.size()+") >= 2", contents.size() >= 2);
+      for(VirtualFile vf : contents)
+      {
+         log.info("  "+vf.getName());
+      }
+      VirtualFile vf = vfs.findChildFromRoot("outer.jar/jar1.jar");
+      VirtualFile jar1MF = vf.findChild("META-INF/MANIFEST.MF");
+      InputStream mfIS = jar1MF.openStream();
+      Manifest mf = new Manifest(mfIS);
+      Attributes mainAttrs = mf.getMainAttributes();
+      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals(Attributes.Name.SPECIFICATION_TITLE.toString(), "jar1", version);
+      mfIS.close();
+   }
+
+  /**
     * Test that the URL of a VFS corresponding to a directory ends in '/' so that
     * URLs created relative to it are under the directory.
     * 




More information about the jboss-cvs-commits mailing list