[Jboss-cvs] JBossAS SVN: r56965 - in projects/microcontainer/trunk/container: . src/main/org/jboss/vfs src/resources/tests/vfs src/resources/tests/vfs/test src/resources/tests/vfs/test/unpacked-outer.jar src/resources/tests/vfs/test/unpacked-outer.jar/META-INF src/resources/tests/vfs/test/unpacked-outer.jar/org src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar1 src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar2 src/tests/org/jboss/test/vfs src/tests/org/jboss/test/vfs/support src/tests/org/jboss/test/virtual/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 19 09:04:20 EDT 2006


Author: adrian at jboss.org
Date: 2006-09-19 09:03:56 -0400 (Tue, 19 Sep 2006)
New Revision: 56965

Added:
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/jar1.jar
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/jar2.jar
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/outer.jar
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/p0.jar
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/META-INF/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/META-INF/MANIFEST.MF
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/jar1.jar
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/jar2.jar
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/CommonClass.class
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar1/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar1/ClassInJar1.class
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar2/
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar2/ClassInJar2.class
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SundryVFSUnitTestCase.java
Removed:
   projects/microcontainer/trunk/container/src/main/org/jboss/vfs/JarTraversal.java
   projects/microcontainer/trunk/container/src/main/org/jboss/vfs/VFSFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/vfs/VFSFactoryLocator.java
   projects/microcontainer/trunk/container/src/main/org/jboss/vfs/classloading/
   projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file/
   projects/microcontainer/trunk/container/src/main/org/jboss/vfs/spi/
   projects/microcontainer/trunk/container/src/main/org/jboss/vfs/visitor/
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/SundryVFSTests.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/TestClassLoading.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/TestFileVFS.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/support/CommonClass.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/support/jar1/
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/support/jar2/
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SimpleTest.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SundryVFSTests.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestFileVFS.java
Modified:
   projects/microcontainer/trunk/container/build-test.xml
   projects/microcontainer/trunk/container/build-test14.xml
   projects/microcontainer/trunk/container/build.xml
Log:
* Remove the old vfs implementation
* Fix the tests so you don't have to build in ant first
* Make the tests run under ant, i.e. rename to *UnitTestCase
* Fix the resource copy so it doesn't corrupt the jars

Modified: projects/microcontainer/trunk/container/build-test.xml
===================================================================
--- projects/microcontainer/trunk/container/build-test.xml	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/build-test.xml	2006-09-19 13:03:56 UTC (rev 56965)
@@ -149,66 +149,6 @@
     <jar jarfile="${build.lib}/jboss-container-test.jar" manifest="${build.etc}/default.mf">
       <fileset dir="${build.classes}"/>
     </jar>
-
-     <!--  vfs test jars -->
-     <jar destfile="${build.lib}/jar1.jar">
-        <manifest>
-           <attribute name="Specification-Title" value="jar1" />
-           <attribute name="Specification-Version" value="1.0.0.GA-jar1" />
-           <attribute name="Specification-Vendor" value="JBoss Inc." />
-        </manifest>
-        <zipfileset dir="${build.classes}">
-           <include name="org/jboss/test/vfs/support/jar1/**" />
-        </zipfileset>
-     </jar>
-     <jar destfile="${build.lib}/jar2.jar">
-        <manifest>
-           <attribute name="Specification-Title" value="jar2" />
-           <attribute name="Specification-Version" value="1.0.0.GA-jar2" />
-           <attribute name="Specification-Vendor" value="JBoss Inc." />
-        </manifest>
-        <zipfileset dir="${build.classes}">
-           <include name="org/jboss/test/vfs/support/jar2/**" />
-        </zipfileset>
-     </jar>
-     <jar destfile="${build.lib}/outer.jar">
-       <manifest>
-          <attribute name="Specification-Title" value="outer-jar" />
-          <attribute name="Specification-Version" value="1.0.0.GA" />
-          <attribute name="Specification-Vendor" value="JBoss Inc." />
-          <attribute name="Implementation-Title" value="outer-jar-test" />
-          <attribute name="Implementation-URL" value="www.jboss.org" />
-          <attribute name="Implementation-Version" value="1.0.0.GA-jboss" />
-          <attribute name="Implementation-Vendor" value="JBoss Inc." />
-       </manifest>
-        <zipfileset dir="${build.lib}">
-           <include name="jar1.jar" />
-           <include name="jar2.jar" />
-        </zipfileset>
-        <zipfileset dir="${build.classes}">
-           <include name="org/jboss/test/vfs/support/*" />
-        </zipfileset>
-     </jar>
-     <!--  unpacked versions of vfs test jars -->
-      <unzip dest="${build.lib}/unpacked-outer.jar" src="${build.lib}/outer.jar">
-         
-      </unzip>
-
-     <!-- Profile service test jars -->
-    <jar destfile="${build.lib}/p0.jar">
-      <manifest>
-         <attribute name="Specification-Title" value="profile0-jar" />
-         <attribute name="Specification-Version" value="1.0.0.GA" />
-         <attribute name="Specification-Vendor" value="JBoss Inc." />
-         <attribute name="Implementation-Title" value="p0-jar-test" />
-         <attribute name="Implementation-URL" value="www.jboss.org" />
-         <attribute name="Implementation-Version" value="1.0.0.GA-jboss" />
-         <attribute name="Implementation-Vendor" value="JBoss Inc." />
-      </manifest>
-       <zipfileset dir="${build.classes}">
-          <include name="org/jboss/test/profileservice/profiles/p0/**" />
-       </zipfileset>
-    </jar>
   </target>
 
   <!-- ================================================================== -->

Modified: projects/microcontainer/trunk/container/build-test14.xml
===================================================================
--- projects/microcontainer/trunk/container/build-test14.xml	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/build-test14.xml	2006-09-19 13:03:56 UTC (rev 56965)
@@ -185,61 +185,6 @@
     <jar jarfile="${build.lib.retro}/jboss-container-test14.jar" manifest="${build.etc}/default.mf">
       <fileset dir="${build.classes.retro}"/>
     </jar>
-
-     <jar destfile="${build.lib.retro}/jar1.jar">
-        <manifest>
-           <attribute name="Specification-Title" value="jar1" />
-           <attribute name="Specification-Version" value="1.0.0.GA-jar1" />
-           <attribute name="Specification-Vendor" value="JBoss Inc." />
-        </manifest>
-        <zipfileset dir="${build.classes.retro}">
-           <include name="org/jboss/test/vfs/support/jar1/**" />
-        </zipfileset>
-     </jar>
-     <jar destfile="${build.lib.retro}/jar2.jar">
-        <manifest>
-           <attribute name="Specification-Title" value="jar2" />
-           <attribute name="Specification-Version" value="1.0.0.GA-jar2" />
-           <attribute name="Specification-Vendor" value="JBoss Inc." />
-        </manifest>
-        <zipfileset dir="${build.classes.retro}">
-           <include name="org/jboss/test/vfs/support/jar2/**" />
-        </zipfileset>
-     </jar>
-     <jar destfile="${build.lib.retro}/outer.jar">
-       <manifest>
-          <attribute name="Specification-Title" value="outer-jar" />
-          <attribute name="Specification-Version" value="1.0.0.GA" />
-          <attribute name="Specification-Vendor" value="JBoss Inc." />
-          <attribute name="Implementation-Title" value="outer-jar-test" />
-          <attribute name="Implementation-URL" value="www.jboss.org" />
-          <attribute name="Implementation-Version" value="1.0.0.GA-jboss" />
-          <attribute name="Implementation-Vendor" value="JBoss Inc." />
-       </manifest>
-        <zipfileset dir="${build.lib.retro}">
-           <include name="jar1.jar" />
-           <include name="jar2.jar" />
-        </zipfileset>
-        <zipfileset dir="${build.classes.retro}">
-           <include name="org/jboss/test/vfs/support/*" />
-        </zipfileset>
-     </jar>
-
-  	<!-- Profile service test jars -->
-    <jar destfile="${build.lib.retro}/p0.jar">
-      <manifest>
-         <attribute name="Specification-Title" value="profile0-jar" />
-         <attribute name="Specification-Version" value="1.0.0.GA" />
-         <attribute name="Specification-Vendor" value="JBoss Inc." />
-         <attribute name="Implementation-Title" value="p0-jar-test" />
-         <attribute name="Implementation-URL" value="www.jboss.org" />
-         <attribute name="Implementation-Version" value="1.0.0.GA-jboss" />
-         <attribute name="Implementation-Vendor" value="JBoss Inc." />
-      </manifest>
-       <zipfileset dir="${build.classes.retro}">
-          <include name="org/jboss/test/profileservice/profiles/p0/**" />
-       </zipfileset>
-    </jar>
   </target>
 
   <!-- ================================================================== -->

Modified: projects/microcontainer/trunk/container/build.xml
===================================================================
--- projects/microcontainer/trunk/container/build.xml	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/build.xml	2006-09-19 13:03:56 UTC (rev 56965)
@@ -103,6 +103,15 @@
     <property name="javac.source" value="1.5"/>
     <property name="jar.prefix" value="jboss-container"/>
 
+    <patternset id="compile-resources.filter.pattern">
+       <include name="**/*"/>
+       <exclude name="tests/**"/>
+    </patternset>
+
+    <patternset id="compile-resources.pattern">
+       <include name="tests/**"/>
+    </patternset>
+
     <call target="_default:task-init"/>
 
   </target>

Deleted: projects/microcontainer/trunk/container/src/main/org/jboss/vfs/JarTraversal.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/vfs/JarTraversal.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/vfs/JarTraversal.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,118 +0,0 @@
-/*
-* JBoss, the OpenSource J2EE webOS
-*
-* Distributable under LGPL license.
-* See terms of license at gnu.org.
-*/
-package org.jboss.vfs;
-
-import java.io.FileInputStream;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class JarTraversal
-{
-   static String[] jarSuffixes = {
-      ".jar", ".zip", ".ear", ".war", ".sar"
-   };
-   static String jarPrefix = "+- ";
-   static String entryPrefix = "|  ";
-   static byte[] buffer = new byte[65535];
-   static boolean showOnlyArchives = false;
-
-   static
-   {
-      for(int i = 0; i < 10; i ++)
-      {
-         jarPrefix += "+- ";
-         entryPrefix += "|  ";
-      }
-   }
-
-   public static boolean isJar(String name)
-   {
-      boolean isJar = false;
-      for(int s = 0; isJar == false && s < jarSuffixes.length; s ++)
-      {
-         String suffix = jarSuffixes[s];
-         isJar |= name.endsWith(suffix);
-      }
-      return isJar;
-   }
-
-   static void processEntry(ZipInputStream zis, ZipEntry entry, int level) throws Exception
-   {
-      String name = entry.getName();
-      boolean isDirectory = entry.isDirectory();
-      if( isDirectory == true )
-         return;
-
-      // See if this is a jar archive
-      if( JarTraversal.isJar(name) )
-      {
-         System.out.print(jarPrefix.substring(0, 3*level));
-         System.out.println(name+" (archive)");
-         try
-         {
-            ZipInputStream entryZIS = new ZipInputStream(zis);
-            processJar(entryZIS, ++ level);
-         }
-         catch(Exception e)
-         {
-            e.printStackTrace();
-         }
-      }
-      else if( name.endsWith("MANIFEST.MF") )
-      {
-         System.out.print(entryPrefix.substring(0, 3*(level-1)));
-         System.out.print("+- ");
-         System.out.print(name);
-         Manifest mf = new Manifest(zis);
-         Attributes main = mf.getMainAttributes();
-
-         String cp = main.getValue(Attributes.Name.CLASS_PATH);
-         if( cp != null )
-         {
-            System.out.print(" Class-Path: ");
-            System.out.print(cp);
-            System.out.print(' ');
-         }
-         System.out.println();
-      }
-      else if( showOnlyArchives == false )
-      {
-         System.out.print(entryPrefix.substring(0, 3*(level-1)));
-         System.out.print("+- ");
-         System.out.println(name);
-      }
-   }
-
-   static void processJar(ZipInputStream zis, int level) throws Exception
-   {
-      ZipEntry entry;
-      while( (entry = zis.getNextEntry()) != null )
-      {
-         processEntry(zis, entry, level);
-      }
-   }
-
-   /** List the jar contents
-    * @param args the command line arguments
-    */
-   public static void main(String[] args) throws Exception
-   {
-      String name = args[0];
-      FileInputStream fis = new FileInputStream(name);
-      ZipInputStream zis = new ZipInputStream(fis);
-      System.out.println(name);
-      processJar(zis, 1);
-      System.out.println("Done");
-   }
-
-}

Deleted: projects/microcontainer/trunk/container/src/main/org/jboss/vfs/VFSFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/vfs/VFSFactory.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/vfs/VFSFactory.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,51 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.vfs;
-
-import org.jboss.vfs.spi.ReadOnlyVFS;
-
-import java.net.URL;
-import java.io.IOException;
-
-/**
- * The entry point to obtaining a VFS for a given URL root mount point
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public interface VFSFactory
-{
-   /**
-    * Get the URL protocols for which vfs factories exist
-    * @return list of supported protocols.
-    */
-   public String[] getProtocols();
-
-   /**
-    * Obtain a vfs for the given root url.
-    * 
-    * @param rootURL - the URL for the root of the virtual file system
-    * @return 
-    * @throws IOException - thrown if the root cannot be opened/accessed
-    */
-   public ReadOnlyVFS getVFS(URL rootURL) throws IOException;
-}

Deleted: projects/microcontainer/trunk/container/src/main/org/jboss/vfs/VFSFactoryLocator.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/vfs/VFSFactoryLocator.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/vfs/VFSFactoryLocator.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2005 Your Corporation. All Rights Reserved.
- */
-package org.jboss.vfs;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-
-/**
- * A singleton factory for locating VFSFactory instances given VFS root URLs.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class VFSFactoryLocator
-{
-   /** The VSFactory mapped keyed by the VFS protocol string */
-   private static HashMap<String, VFSFactory> factoryByProtocol = new HashMap<String, VFSFactory>();
-   /** The default file protocol faactory */
-   private static final String FILE_FACTORY = "org.jboss.vfs.file.DefaultVFSFactory";
-   /** Has the default initialzation been performed */
-   private static boolean initialized;
-
-   public synchronized static void registerFactory(VFSFactory factory)
-   {
-      String[] protocols = factory.getProtocols();
-      for(int n = 0; n < protocols.length; n ++)
-      {
-         String protocol = protocols[n];
-         factoryByProtocol.put(protocol, factory);
-      }
-   }
-
-   /**
-    * Return the VFSFactory for the VFS mount point specified by the
-    * rootURL.
-    *  
-    * @param rootURL - the URL to a VFS root
-    * @return the VFSFactory capable of handling the rootURL. This will be null
-    * if there is no factory registered for the rootURL protocol.
-    */
-   public synchronized static VFSFactory getFactory(URL rootURL)
-      throws Exception
-   {
-      if( initialized == false )
-         init();
-      String protocol = rootURL.getProtocol();
-      VFSFactory factory = factoryByProtocol.get(protocol);
-      return factory;
-   }
-
-   /**
-    * Load the default protocol VFS factories by searching for the
-    * META-INF/services/org.jboss.vfs.VFSFactory service provider config files
-    * using the thread context class loader. If that fails to locate a resource,
-    * default to the file
-    */
-   private static synchronized void init()
-      throws Exception
-   {
-      // Try to locate
-      ClassLoader loader = Thread.currentThread().getContextClassLoader();
-      Enumeration urls = loader.getResources("META-INF/services/org.jboss.vfs.VFSFactory");
-      while( urls.hasMoreElements() )
-      {
-         URL url = (URL) urls.nextElement();
-         VFSFactory[] factories = loadFactories(url, loader);
-         for(int n = 0; n < factories.length; n ++)
-         {
-            VFSFactory factory = factories[n];
-            registerFactory(factory);
-         }
-      }
-
-      // If there are no factories load the FILE_FACTORY
-      if( factoryByProtocol.size() == 0 )
-      {
-         Class<VFSFactory> c = (Class<VFSFactory>) loader.loadClass(FILE_FACTORY);
-         VFSFactory factory = c.newInstance();
-         registerFactory(factory);
-      }
-      initialized = true;
-   }
-
-   /**
-    * Load the VFSFactory classes found in the service file
-    * @param serviceURL
-    * @param loader
-    * @return A possibly zero length array of the VFSFactory instances
-    *    loaded from the serviceURL
-    */
-   private static VFSFactory[] loadFactories(URL serviceURL, ClassLoader loader)
-   {
-      ArrayList<VFSFactory> tmp = new ArrayList<VFSFactory>();
-      try
-      {
-         InputStream is = serviceURL.openStream();
-         BufferedReader br = new BufferedReader(new InputStreamReader(is));
-         String line;
-         while( (line = br.readLine()) != null )
-         {
-            if( line.startsWith("#") == true )
-               continue;
-            String[] classes = line.split("\\s+|#.*");
-            for(int n = 0; n < classes.length; n ++)
-            {
-               String name = classes[n];
-               if( name.length() == 0 )
-                  continue;
-               Class factoryClass = loader.loadClass(name);
-               VFSFactory factory = (VFSFactory) factoryClass.newInstance();
-               tmp.add(factory);
-            }
-         }
-      }
-      catch(Exception e)
-      {
-         
-      }
-      VFSFactory[] factories = new VFSFactory[tmp.size()];
-      tmp.toArray(factories);
-      return factories;
-   }
-}

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/jar1.jar
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/jar1.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/jar2.jar
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/jar2.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/outer.jar
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/outer.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/p0.jar
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/p0.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/META-INF/MANIFEST.MF
===================================================================
--- projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/META-INF/MANIFEST.MF	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/META-INF/MANIFEST.MF	2006-09-19 13:03:56 UTC (rev 56965)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.6.5
+Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
+Specification-Title: outer-jar
+Specification-Version: 1.0.0.GA
+Specification-Vendor: JBoss Inc.
+Implementation-Title: outer-jar-test
+Implementation-URL: www.jboss.org
+Implementation-Version: 1.0.0.GA-jboss
+Implementation-Vendor: JBoss Inc.
+

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/jar1.jar
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/jar1.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/jar2.jar
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/jar2.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/CommonClass.class
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/CommonClass.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar1/ClassInJar1.class
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar1/ClassInJar1.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar2/ClassInJar2.class
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/unpacked-outer.jar/org/jboss/test/vfs/support/jar2/ClassInJar2.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Deleted: projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/SundryVFSTests.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/SundryVFSTests.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/SundryVFSTests.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,65 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.vfs;
-
-import java.net.URL;
-
-import org.jboss.test.BaseTestCase;
-import org.jboss.vfs.VFSFactory;
-import org.jboss.vfs.VFSFactoryLocator;
-import org.jboss.vfs.spi.ReadOnlyVFS;
-import org.jboss.vfs.spi.VirtualFile;
-
-/**
- * SundryVFSTests.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class SundryVFSTests extends BaseTestCase
-{
-   public SundryVFSTests(String name)
-   {
-      super(name);
-   }
-
-   protected VirtualFile getVirtualFile(String root, String path) throws Exception
-   {
-      URL url = getResource(root);
-      assertNotNull(url);
-      VFSFactoryLocator locator = new VFSFactoryLocator();
-      VFSFactory factory = locator.getFactory(url);
-      ReadOnlyVFS vfs = factory.getVFS(url);
-      return vfs.resolveFile(path);
-   }
-   
-   public void testBrokenContext() throws Exception
-   {
-      getVirtualFile("/vfs/sundry", "jar/archive.jar");
-   }
-   
-   public void testArchive() throws Exception
-   {
-      VirtualFile file = getVirtualFile("/vfs/sundry/", "jar/archive.jar");
-      assertTrue("Should be an archive", file.isArchive());
-   }
-}

Deleted: projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/TestClassLoading.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/TestClassLoading.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/TestClassLoading.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2005 Your Corporation. All Rights Reserved.
- */
-package org.jboss.test.vfs;
-
-import java.net.URL;
-import junit.framework.TestCase;
-import org.jboss.vfs.VFSFactory;
-import org.jboss.vfs.VFSFactoryLocator;
-import org.jboss.vfs.classloading.VFSClassLoader;
-import org.jboss.vfs.spi.ReadOnlyVFS;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class TestClassLoading  extends TestCase
-{
-   public void testEarClasses()
-      throws Exception
-   {
-      URL root = new URL("file://usr/local/java5");
-      VFSFactory factory = VFSFactoryLocator.getFactory(root);
-      assertTrue("VFSFactory(file://usr/local/java5) != null", factory != null);
-
-      ReadOnlyVFS vfs = factory.getVFS(root);
-      String[] searchCtxts = {"jbosstest-web.ear"};
-      VFSClassLoader cl = new VFSClassLoader(searchCtxts, vfs);
-      URL appXml = cl.findResource("META-INF/application.xml");
-      assertTrue("META-INF/application.xml != null", appXml != null);
-   }
-}

Deleted: projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/TestFileVFS.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/TestFileVFS.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/TestFileVFS.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,407 +0,0 @@
-/*
-* JBoss, the OpenSource J2EE webOS
-*
-* Distributable under LGPL license.
-* See terms of license at gnu.org.
-*/
-package org.jboss.test.vfs;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.zip.ZipInputStream;
-
-import org.jboss.test.BaseTestCase;
-import org.jboss.vfs.VFSFactory;
-import org.jboss.vfs.VFSFactoryLocator;
-import org.jboss.vfs.file.NestedJarFromStream;
-import org.jboss.vfs.spi.ReadOnlyVFS;
-import org.jboss.vfs.spi.VirtualFile;
-import org.jboss.vfs.visitor.SuffixMatchVisitor;
-
-/**
- * Tests of the VFS implementation
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class TestFileVFS extends BaseTestCase
-{
-   public TestFileVFS(String name)
-   {
-      super(name);
-   }
-
-   /**
-    * Test that a VFSFactory can be created from the testcase CodeSource url
-    * @throws Exception
-    */
-   public void testVFSFactory()
-      throws Exception
-   {
-      URL root = getClass().getProtectionDomain().getCodeSource().getLocation();
-      VFSFactory factory = VFSFactoryLocator.getFactory(root);
-      assertTrue("VFSFactory(CodeSource.Location) != null", factory != null);
-   }
-
-   /**
-    * Test that NestedJarFromStream can provide access to nested jar content
-    * @throws Exception
-    */
-   public void testInnerJarFile()
-      throws Exception
-   {
-      MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
-      log.info("Starting heap usage: "+mem.getHeapMemoryUsage());
-
-      // this expects to be run with a working dir of the container root
-      File outerJar = new File("output/lib/outer.jar");
-      assertTrue(outerJar.getAbsolutePath()+" exists", outerJar.exists());
-      JarFile jf = new JarFile(outerJar);
-
-      JarEntry jar1 = jf.getJarEntry("jar1.jar");
-      URL jar1URL = new URL(outerJar.toURL(), "jar1.jar");
-      ZipInputStream jis1 = new ZipInputStream(jf.getInputStream(jar1));
-      NestedJarFromStream njfs = new NestedJarFromStream(jis1, jar1URL, "/jar1.jar", jar1);
-      NestedJarFromStream.JarEntryContents e1 = njfs.getEntry("org/jboss/test/vfs/support/jar1/ClassInJar1.class");
-      assertNotNull(e1);
-      log.info("org/jboss/test/vfs/support/CommonClass.class: "+e1);
-      NestedJarFromStream.JarEntryContents mfe1 = njfs.getEntry("META-INF/MANIFEST.MF");
-      assertNotNull("jar1!/META-INF/MANIFEST.MF", mfe1);
-      InputStream mfIS = mfe1.openStream();
-      Manifest mf = new Manifest(mfIS);
-      Attributes mainAttrs = mf.getMainAttributes();
-      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar1", version);
-      mfIS.close();
-      njfs.close();
-
-      JarEntry jar2 = jf.getJarEntry("jar2.jar");
-      URL jar2URL = new URL(outerJar.toURL(), "jar2.jar");
-      ZipInputStream jis2 = new ZipInputStream(jf.getInputStream(jar2));
-      NestedJarFromStream njfs2 = new NestedJarFromStream(jis2, jar2URL, "/jar2.jar", jar2);
-      NestedJarFromStream.JarEntryContents e2 = njfs2.getEntry("org/jboss/test/vfs/support/jar2/ClassInJar2.class");
-      assertNotNull(e2);
-      log.info("org/jboss/test/vfs/support/CommonClass.class: "+e2);
-      NestedJarFromStream.JarEntryContents mfe2 = njfs2.getEntry("META-INF/MANIFEST.MF");
-      assertNotNull("jar2!/META-INF/MANIFEST.MF", mfe2);
-      InputStream mf2IS = mfe2.openStream();
-      Manifest mf2 = new Manifest(mf2IS);
-      Attributes mainAttrs2 = mf2.getMainAttributes();
-      String version2 = mainAttrs2.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar2", version2);
-      mf2IS.close();
-      njfs2.close();
-      log.info("Ending heap usage: "+mem.getHeapMemoryUsage());
-   }
-
-   /**
-    * Basic tests of accessing resources in a jar
-    * @throws Exception
-    */
-   public void testFindResource()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File outerJar = new File("output/lib/outer.jar");
-      URL rootURL = outerJar.getParentFile().toURL();
-      VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
-      ReadOnlyVFS vfs = factory.getVFS(rootURL);
-      VirtualFile jar = vfs.resolveFile("outer.jar");
-      assertTrue("outer.jar != null", jar != null);
-
-      ArrayList<String> searchCtx = new ArrayList<String>();
-      searchCtx.add("outer.jar");
-      VirtualFile metaInf = vfs.resolveFile("META-INF/MANIFEST.MF", searchCtx);
-      assertTrue("META-INF/MANIFEST.MF != null", metaInf != null);
-      InputStream mfIS = metaInf.openStream();
-      assertTrue("META-INF/MANIFEST.MF.openStream != null", mfIS != null);
-      Manifest mf = new Manifest(mfIS);
-      Attributes mainAttrs = mf.getMainAttributes();
-      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_VERSION);
-      assertEquals("1.0.0.GA", version);
-      mfIS.close();
-   }
-
-   public void testFindResourceUnpackedJar()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File outerJar = new File("output/lib/unpacked-outer.jar");
-      URL rootURL = outerJar.getParentFile().toURL();
-      VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
-      ReadOnlyVFS vfs = factory.getVFS(rootURL);
-      VirtualFile jar = vfs.resolveFile("unpacked-outer.jar");
-      assertTrue("unpacked-outer.jar != null", jar != null);
-
-      ArrayList<String> searchCtx = new ArrayList<String>();
-      searchCtx.add("unpacked-outer.jar");
-      VirtualFile metaInf = vfs.resolveFile("META-INF/MANIFEST.MF", searchCtx);
-      assertTrue("META-INF/MANIFEST.MF != null", metaInf != null);
-      InputStream mfIS = metaInf.openStream();
-      assertTrue("META-INF/MANIFEST.MF.openStream != null", mfIS != null);
-      Manifest mf = new Manifest(mfIS);
-      Attributes mainAttrs = mf.getMainAttributes();
-      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_VERSION);
-      assertEquals("1.0.0.GA", version);
-      mfIS.close();
-   }
-
-   /**
-    * Test simple file resolution without search contexts
-    * @throws Exception
-    */
-   public void testResolveFile()
-      throws Exception
-   {
-      log.info("+++ testResolveFile, cwd="+(new File(".").getCanonicalPath()));
-      // this expects to be run with a working dir of the container root
-      File outerJarFile = new File("output/lib/outer.jar");
-      URL rootURL = outerJarFile.getParentFile().toURL();
-      VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
-      ReadOnlyVFS vfs = factory.getVFS(rootURL);
-
-      // Check resolving the root file
-      VirtualFile root = vfs.resolveFile("");
-      assertEquals("root name", "lib", root.getName());
-      assertEquals("root path", "", root.getPathName());
-      assertTrue("root isDirectory", root.isDirectory());
-
-      // Find the outer.jar
-      VirtualFile outerJar = vfs.resolveFile("outer.jar");
-      assertNotNull("outer.jar", outerJar);
-      assertEquals("outer.jar name", "outer.jar", outerJar.getName());
-      assertEquals("outer.jar path", "outer.jar", outerJar.getPathName());
-      
-      VirtualFile outerJarMF = vfs.resolveFile("outer.jar/META-INF/MANIFEST.MF");
-      assertNotNull("outer.jar/META-INF/MANIFEST.MF", outerJarMF);
-
-      // Test a non-canonical path
-      outerJarFile = new File("output/resources/../lib/outer.jar");
-      rootURL = outerJarFile.getParentFile().toURL();
-      // Check resolving the root file
-      root = vfs.resolveFile("");
-      assertEquals("root name", "lib", root.getName());
-      assertEquals("root path", "", root.getPathName());
-      assertTrue("root isDirectory", root.isDirectory());
-   }
-
-   /**
-    * Validate resolving a .class file given a set of search contexts in the
-    * vfs that make up a classpath.
-    * 
-    * @throws Exception
-    */
-   public void testResolveClassFileInClassPath()
-      throws Exception
-   {
-      log.info("+++ testResolveFile, cwd="+(new File(".").getCanonicalPath()));
-      // this expects to be run with a working dir of the container root
-      File libFile = new File("output/lib");
-      URL rootURL = libFile.toURL();
-      VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
-      ReadOnlyVFS vfs = factory.getVFS(rootURL);
-
-      // Find ClassInJar1.class
-      ArrayList<String> cp = new ArrayList<String>();
-      cp.add("jar1.jar");
-      VirtualFile c1 = vfs.resolveFile("org/jboss/test/vfs/support/jar1/ClassInJar1.class", cp);
-      assertNotNull("ClassInJar1.class VF", c1);
-      log.debug("Found ClassInJar1.class: "+c1);
-
-      // Find ClassInJar1$InnerClass.class
-      VirtualFile c1i = vfs.resolveFile("org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class", cp);
-      assertNotNull("ClassInJar1$InnerClass.class VF", c1i);
-      log.debug("Found ClassInJar1$InnerClass.class: "+c1i);
-
-      // Find ClassInJar2.class
-      cp.add("jar2.jar");
-      VirtualFile c2 = vfs.resolveFile("org/jboss/test/vfs/support/jar2/ClassInJar2.class", cp);
-      assertNotNull("ClassInJar2.class VF", c2);
-      log.debug("Found ClassInJar2.class: "+c2);
-   }
-
-   public void testResolveFileInUnpackedJar()
-      throws Exception
-   {
-      log.info("+++ testResolveFileInUnpackedJar, cwd="+(new File(".").getCanonicalPath()));
-      // this expects to be run with a working dir of the container root
-      File outerJarFile = new File("output/lib/unpacked-outer.jar");
-      URL rootURL = outerJarFile.getParentFile().toURL();
-      VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
-      ReadOnlyVFS vfs = factory.getVFS(rootURL);
-
-      // Check resolving the root file
-      VirtualFile root = vfs.resolveFile("");
-      assertEquals("root name", "lib", root.getName());
-      assertEquals("root path", "", root.getPathName());
-      assertTrue("root isDirectory", root.isDirectory());
-
-      // Find the outer.jar
-      VirtualFile outerJar = vfs.resolveFile("unpacked-outer.jar");
-      assertNotNull("unpacked-outer.jar", outerJar);
-      assertEquals("unpacked-outer.jar name", "unpacked-outer.jar", outerJar.getName());
-      assertEquals("unpacked-outer.jar path", "unpacked-outer.jar", outerJar.getPathName());
-      
-      VirtualFile outerJarMF = vfs.resolveFile("unpacked-outer.jar/META-INF/MANIFEST.MF");
-      assertNotNull("unpacked-outer.jar/META-INF/MANIFEST.MF", outerJarMF);
-
-      // Test a non-canonical path
-      outerJarFile = new File("output/resources/../lib/unpacked-outer.jar");
-      rootURL = outerJarFile.getParentFile().toURL();
-      // Check resolving the root file
-      root = vfs.resolveFile("");
-      assertEquals("root name", "lib", root.getName());
-      assertEquals("root path", "", root.getPathName());
-      assertTrue("root isDirectory", root.isDirectory());
-   }
-
-   /**
-    * Test file resolution with nested jars
-    * @throws Exception
-    */
-   public void testInnerJar()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File outerJar = new File("output/lib/outer.jar");
-      URL rootURL = outerJar.getParentFile().toURL();
-      VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
-      ReadOnlyVFS vfs = factory.getVFS(rootURL);
-      VirtualFile inner = vfs.resolveFile("outer.jar/jar1.jar");
-      log.info("IsFile: "+inner.isFile());
-      log.info(inner.getLastModified());
-      VirtualFile[] contents = inner.getChildren();
-      // META-INF/*, org/jboss/test/vfs/support/jar1/* at least
-      assertTrue("jar1.jar children.length("+contents.length+") >= 2", contents.length >= 2);
-      for(VirtualFile vf : contents)
-      {
-         log.info("  "+vf.getName());
-      }
-      ArrayList<String> searchCtxts = new ArrayList<String>();
-      searchCtxts.add("outer.jar/jar1.jar");
-      VirtualFile jar1MF = vfs.resolveFile("META-INF/MANIFEST.MF", searchCtxts);
-      InputStream mfIS = jar1MF.openStream();
-      Manifest mf = new Manifest(mfIS);
-      Attributes mainAttrs = mf.getMainAttributes();
-      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar1", version);
-      mfIS.close();
-   }
-
-   /**
-    * Test a scan of the outer.jar vfs to locate all .class files
-    * @throws Exception
-    */
-   public void testClassScan()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File outerJarFile = new File("output/lib/outer.jar");
-      URL rootURL = outerJarFile.toURL();
-      VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
-      ReadOnlyVFS vfs = factory.getVFS(rootURL);
-
-      HashSet<String> expectedClasses = new HashSet<String>();
-      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1.class");
-      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class");
-      expectedClasses.add("jar2.jar/org/jboss/test/vfs/support/jar2/ClassInJar2.class");
-      expectedClasses.add("org/jboss/test/vfs/support/CommonClass.class");
-      SuffixMatchVisitor classVisitor = new SuffixMatchVisitor(".class");
-      Iterator<VirtualFile> classes = vfs.scan(classVisitor);
-      int count = 0;
-      while( classes.hasNext() )
-      {
-         VirtualFile cf = classes.next();
-         String path = cf.getPathName();
-         if( path.endsWith(".class") )
-         {
-            assertTrue(path, expectedClasses.contains(path));
-            count ++;
-         }
-      }
-      assertEquals("There were 4 classes", 4, count);
-   }
-
-   /**
-    * Test the serialization of VirtualFiles
-    * @throws Exception
-    */
-   public void testVFSerialization()
-      throws Exception
-   {
-      File tmpRoot = File.createTempFile("vfs", ".root");
-      tmpRoot.delete();
-      tmpRoot.mkdir();
-      tmpRoot.deleteOnExit();
-      File tmp = new File(tmpRoot, "vfs.ser");
-      tmp.deleteOnExit();
-      log.info("+++ testVFSerialization, tmp="+tmp.getCanonicalPath());
-      URL rootURL = tmpRoot.toURL();
-      VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
-      ReadOnlyVFS vfs = factory.getVFS(rootURL);
-      VirtualFile tmpVF = vfs.resolveFile("vfs.ser");
-      FileOutputStream fos = new FileOutputStream(tmp);
-      ObjectOutputStream oos = new ObjectOutputStream(fos);
-      oos.writeObject(tmpVF);
-      oos.close();
-
-      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();
-
-      assertEquals("name", name, tmpVF2.getName());
-      assertEquals("pathName", pathName, tmpVF2.getPathName());
-      assertEquals("lastModified", lastModified, tmpVF2.getLastModified());
-      assertEquals("size", size, tmpVF2.getSize());
-      assertEquals("url", url, tmpVF2.toURL());
-   }
-
-   /**
-    * Test that the URL of a VFS corresponding to a directory ends in '/' so that
-    * URLs created relative to it are under the directory.
-    * 
-    * @throws Exception
-    */
-   public void testDirURLs()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File libFile = new File("output/lib");
-      URL rootURL = libFile.toURL();
-      VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
-      ReadOnlyVFS vfs = factory.getVFS(rootURL);
-
-      // Use the unpacked-outer.jar in output/lib
-      VirtualFile outerJar = vfs.resolveFile("unpacked-outer.jar");
-      URL outerURL = outerJar.toURL();
-      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");
-      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"));
-      VirtualFile jar1 = outerJar.findChild("jar1.jar");
-      assertEquals("jar1URL == VF.toURL()", jar1URL, jar1.toURL());
-   }
-}

Deleted: projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/support/CommonClass.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/support/CommonClass.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/vfs/support/CommonClass.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,10 +0,0 @@
-package org.jboss.test.vfs.support;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class CommonClass
-{
-
-}

Copied: projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java (from rev 56953, 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-18 21:34:28 UTC (rev 56953)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -0,0 +1,626 @@
+/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+package org.jboss.test.virtual.test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+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.Properties;
+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.VFSUtils;
+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.LinkInfo;
+import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.VFSContextFactory;
+import org.jboss.virtual.spi.VFSContextFactoryLocator;
+
+/**
+ * Tests of the VFS implementation
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision: 55523 $
+ */
+public class FileVFSUnitTestCase extends BaseTestCase
+{
+   public FileVFSUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Test that a VFSContextFactory can be created from the testcase CodeSource url
+    * @throws Exception
+    */
+   public void testVFSContextFactory()
+      throws Exception
+   {
+      URL root = getClass().getProtectionDomain().getCodeSource().getLocation();
+      VFSContextFactory factory = VFSContextFactoryLocator.getFactory(root);
+      assertTrue("VFSContextFactory(CodeSource.Location) != null", factory != null);
+   }
+
+   /**
+    * Test that NestedJarFromStream can provide access to nested jar content
+    * @throws Exception
+    */
+   public void testInnerJarFile()
+      throws Exception
+   {
+      URL outer = getResource("/vfs/test/outer.jar");
+      String path = outer.getPath();
+      File outerJar = new File(path);
+      assertTrue(outerJar.getAbsolutePath()+" exists", outerJar.exists());
+      JarFile jf = new JarFile(outerJar);
+
+      URL rootURL = outerJar.getParentFile().toURL();
+      VFSContextFactory factory = VFSContextFactoryLocator.getFactory(rootURL);
+      VFSContext context = factory.getVFS(rootURL);
+
+      JarEntry jar1 = jf.getJarEntry("jar1.jar");
+      URL jar1URL = new URL(outerJar.toURL(), "jar1.jar");
+      ZipInputStream jis1 = new ZipInputStream(jf.getInputStream(jar1));
+      NestedJarFromStream njfs = new NestedJarFromStream(context, null, jis1, jar1URL, jar1);
+      NestedJarFromStream.JarEntryContents e1 = njfs.getEntry("org/jboss/test/vfs/support/jar1/ClassInJar1.class");
+      assertNotNull(e1);
+      log.info("org/jboss/test/vfs/support/CommonClass.class: "+e1);
+      NestedJarFromStream.JarEntryContents mfe1 = njfs.getEntry("META-INF/MANIFEST.MF");
+      assertNotNull("jar1!/META-INF/MANIFEST.MF", mfe1);
+      InputStream mfIS = mfe1.openStream();
+      Manifest mf = new Manifest(mfIS);
+      Attributes mainAttrs = mf.getMainAttributes();
+      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals("jar1", version);
+      mfIS.close();
+      njfs.close();
+
+      JarEntry jar2 = jf.getJarEntry("jar2.jar");
+      URL jar2URL = new URL(outerJar.toURL(), "jar2.jar");
+      ZipInputStream jis2 = new ZipInputStream(jf.getInputStream(jar2));
+      NestedJarFromStream njfs2 = new NestedJarFromStream(context, null, jis2, jar2URL, jar2);
+      NestedJarFromStream.JarEntryContents e2 = njfs2.getEntry("org/jboss/test/vfs/support/jar2/ClassInJar2.class");
+      assertNotNull(e2);
+      log.info("org/jboss/test/vfs/support/CommonClass.class: "+e2);
+      NestedJarFromStream.JarEntryContents mfe2 = njfs2.getEntry("META-INF/MANIFEST.MF");
+      assertNotNull("jar2!/META-INF/MANIFEST.MF", mfe2);
+      InputStream mf2IS = mfe2.openStream();
+      Manifest mf2 = new Manifest(mf2IS);
+      Attributes mainAttrs2 = mf2.getMainAttributes();
+      String version2 = mainAttrs2.getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals("jar2", version2);
+      mf2IS.close();
+      njfs2.close();
+   }
+
+   /**
+    * Basic tests of accessing resources in a jar
+    * @throws Exception
+    */
+   public void testFindResource()
+      throws Exception
+   {
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile jar = vfs.findChildFromRoot("outer.jar");
+      assertTrue("outer.jar != null", jar != null);
+
+      /*
+      ArrayList<String> searchCtx = new ArrayList<String>();
+      searchCtx.add("outer.jar");
+      VirtualFile metaInf = vfs.resolveFile("META-INF/MANIFEST.MF", searchCtx);
+      */
+      VirtualFile metaInf = jar.findChild("META-INF/MANIFEST.MF");
+      assertTrue("META-INF/MANIFEST.MF != null", metaInf != null);
+      InputStream mfIS = metaInf.openStream();
+      assertTrue("META-INF/MANIFEST.MF.openStream != null", mfIS != null);
+      Manifest mf = new Manifest(mfIS);
+      Attributes mainAttrs = mf.getMainAttributes();
+      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_VERSION);
+      assertEquals("1.0.0.GA", version);
+      mfIS.close();
+   }
+
+   public void testFindResourceUnpackedJar()
+      throws Exception
+   {
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile jar = vfs.findChildFromRoot("unpacked-outer.jar");
+      assertTrue("unpacked-outer.jar != null", jar != null);
+
+      /**
+      ArrayList<String> searchCtx = new ArrayList<String>();
+      searchCtx.add("unpacked-outer.jar");
+      VirtualFile metaInf = vfs.resolveFile("META-INF/MANIFEST.MF", searchCtx);
+      */
+      VirtualFile metaInf = jar.findChild("META-INF/MANIFEST.MF");
+      assertTrue("META-INF/MANIFEST.MF != null", metaInf != null);
+      InputStream mfIS = metaInf.openStream();
+      assertTrue("META-INF/MANIFEST.MF.openStream != null", mfIS != null);
+      Manifest mf = new Manifest(mfIS);
+      Attributes mainAttrs = mf.getMainAttributes();
+      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_VERSION);
+      assertEquals("1.0.0.GA", version);
+      mfIS.close();
+   }
+
+   /**
+    * Test simple file resolution without search contexts
+    * @throws Exception
+    */
+   public void testResolveFile()
+      throws Exception
+   {
+      log.info("+++ testResolveFile, cwd="+(new File(".").getCanonicalPath()));
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+
+      // Check resolving the root file
+      VirtualFile root = vfs.findChildFromRoot("");
+      assertEquals("root name", "test", root.getName());
+      assertEquals("root path", "", root.getPathName());
+      assertTrue("root isDirectory", root.isDirectory());
+
+      // Find the outer.jar
+      VirtualFile outerJar = vfs.findChildFromRoot("outer.jar");
+      assertNotNull("outer.jar", outerJar);
+      assertEquals("outer.jar name", "outer.jar", outerJar.getName());
+      assertEquals("outer.jar path", "outer.jar", outerJar.getPathName());
+      
+      VirtualFile outerJarMF = vfs.findChildFromRoot("outer.jar/META-INF/MANIFEST.MF");
+      assertNotNull("outer.jar/META-INF/MANIFEST.MF", outerJarMF);
+
+      // Test a non-canonical path
+      rootURL = getResource("/vfs/sundry/../test");
+      // Check resolving the root file
+      root = vfs.findChildFromRoot("");
+      assertEquals("root name", "test", root.getName());
+      assertEquals("root path", "", root.getPathName());
+      assertTrue("root isDirectory", root.isDirectory());
+   }
+
+   /**
+    * Validate resolving a .class file given a set of search contexts in the
+    * vfs that make up a classpath.
+    * 
+    * @throws Exception
+    */
+   public void testResolveClassFileInClassPath()
+      throws Exception
+   {
+      log.info("+++ testResolveFile, cwd="+(new File(".").getCanonicalPath()));
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      
+      // Find ClassInJar1.class
+      VirtualFile vf = vfs.findChildFromRoot("jar1.jar"); 
+      VirtualFile c1 = vf.findChild("org/jboss/test/vfs/support/jar1/ClassInJar1.class");
+      assertNotNull("ClassInJar1.class VF", c1);
+      log.debug("Found ClassInJar1.class: "+c1);
+
+      // Find ClassInJar1$InnerClass.class
+      VirtualFile c1i = vf.findChild("org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class");
+      assertNotNull("ClassInJar1$InnerClass.class VF", c1i);
+      log.debug("Found ClassInJar1$InnerClass.class: "+c1i);
+
+      // Find ClassInJar2.class
+      vf = vfs.findChildFromRoot("jar2.jar");
+      VirtualFile c2 = vf.findChild("org/jboss/test/vfs/support/jar2/ClassInJar2.class");
+      assertNotNull("ClassInJar2.class VF", c2);
+      log.debug("Found ClassInJar2.class: "+c2);
+   }
+
+   public void testResolveFileInUnpackedJar()
+      throws Exception
+   {
+      log.info("+++ testResolveFileInUnpackedJar, cwd="+(new File(".").getCanonicalPath()));
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+
+      // Check resolving the root file
+      VirtualFile root = vfs.findChildFromRoot("");
+      assertEquals("root name", "test", root.getName());
+      assertEquals("root path", "", root.getPathName());
+      assertTrue("root isDirectory", root.isDirectory());
+
+      // Find the outer.jar
+      VirtualFile outerJar = vfs.findChildFromRoot("unpacked-outer.jar");
+      assertNotNull("unpacked-outer.jar", outerJar);
+      assertEquals("unpacked-outer.jar name", "unpacked-outer.jar", outerJar.getName());
+      assertEquals("unpacked-outer.jar path", "unpacked-outer.jar", outerJar.getPathName());
+      
+      VirtualFile outerJarMF = vfs.findChildFromRoot("unpacked-outer.jar/META-INF/MANIFEST.MF");
+      assertNotNull("unpacked-outer.jar/META-INF/MANIFEST.MF", outerJarMF);
+
+      // Test a non-canonical path
+      rootURL = getResource("/test/sundry/../test");
+      // Check resolving the root file
+      root = vfs.findChildFromRoot("");
+      assertEquals("root name", "test", root.getName());
+      assertEquals("root path", "", root.getPathName());
+      assertTrue("root isDirectory", root.isDirectory());
+   }
+
+   /**
+    * Test file resolution with nested jars
+    * @throws Exception
+    */
+   public void testInnerJar()
+      throws Exception
+   {
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile inner = vfs.findChildFromRoot("outer.jar/jar1.jar");
+      log.info("IsFile: "+inner.isFile());
+      log.info(inner.getLastModified());
+      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 a scan of the outer.jar vfs to locate all .class files
+    * @throws Exception
+    */
+   public void testClassScan()
+      throws Exception
+   {
+      URL rootURL = getResource("/vfs/test/outer.jar");
+      VFS vfs = VFS.getVFS(rootURL);
+
+      HashSet<String> expectedClasses = new HashSet<String>();
+      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1.class");
+      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class");
+      expectedClasses.add("jar2.jar/org/jboss/test/vfs/support/jar2/ClassInJar2.class");
+      expectedClasses.add("org/jboss/test/vfs/support/CommonClass.class");
+      SuffixMatchFilter classVisitor = new SuffixMatchFilter(".class");
+      List<VirtualFile> classes = vfs.getChildren(classVisitor);
+      int count = 0;
+      for (VirtualFile cf : classes)
+      {
+         String path = cf.getPathName();
+         if( path.endsWith(".class") )
+         {
+            assertTrue(path, expectedClasses.contains(path));
+            count ++;
+         }
+      }
+      assertEquals("There were 4 classes", 4, count);
+   }
+
+   /**
+    * Test the serialization of VirtualFiles
+    * @throws Exception
+    */
+   public void testVFSerialization()
+      throws Exception
+   {
+      File tmpRoot = File.createTempFile("vfs", ".root");
+      tmpRoot.delete();
+      tmpRoot.mkdir();
+      tmpRoot.deleteOnExit();
+      File tmp = new File(tmpRoot, "vfs.ser");
+      tmp.createNewFile();
+      tmp.deleteOnExit();
+      log.info("+++ testVFSerialization, tmp="+tmp.getCanonicalPath());
+      URL rootURL = tmpRoot.toURL();
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile tmpVF = vfs.findChildFromRoot("vfs.ser");
+      FileOutputStream fos = new FileOutputStream(tmp);
+      ObjectOutputStream oos = new ObjectOutputStream(fos);
+      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();
+      // 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", 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
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile inner = vfs.findChildFromRoot("outer.jar/jar1.jar");
+
+      File vfsSer = File.createTempFile("testVFNestedJarSerialization", ".ser");
+      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 parsing of a vfs link properties file. It contains test.classes.url
+    * and test.lib.url system property references that are configured to
+    * point to the CodeSource location of this class and /vfs/sundry/jar/
+    * respectively.
+    * 
+    * @throws Exception
+    */
+   public void testVfsLinkProperties()
+      throws Exception
+   {
+      URL linkURL = super.getResource("/vfs/links/war1.vfslink.properties");
+      assertNotNull("vfs/links/war1.vfslink.properties", linkURL);
+      // Find resources to use as the WEB-INF/{classes,lib} link targets
+      URL classesURL = getClass().getProtectionDomain().getCodeSource().getLocation();
+      assertNotNull("classesURL", classesURL);
+      System.setProperty("test.classes.url", classesURL.toString());
+      URL libURL = super.getResource("/vfs/sundry/jar");
+      assertNotNull("libURL", libURL);      
+      System.setProperty("test.lib.url", libURL.toString());
+
+      assertTrue("isLink", VFSUtils.isLink(linkURL.getPath()));
+      Properties props = new Properties();
+      InputStream linkIS = linkURL.openStream();
+      List<LinkInfo> infos = VFSUtils.readLinkInfo(linkIS, linkURL.getPath(), props);
+      assertEquals("LinkInfo count", 2, infos.size());
+      LinkInfo classesInfo = null;
+      LinkInfo libInfo = null;
+      for(LinkInfo info :infos)
+      {
+         if( info.getName().equals("WEB-INF/classes") )
+            classesInfo = info;
+         else if(info.getName().equals("WEB-INF/lib") )
+            libInfo = info;
+      }
+      assertNotNull("classesInfo", classesInfo);
+      assertEquals("classesInfo.target", classesURL.toURI(), classesInfo.getLinkTarget());
+      assertNotNull("libInfo", libInfo);
+      assertEquals("libInfo.target", libURL.toURI(), libInfo.getLinkTarget());
+   }
+
+   /**
+    * Test the test-link.war link
+    * @throws Exception
+    */
+   public void testWarLink()
+      throws Exception
+   {
+      // Find resources to use as the WEB-INF/{classes,lib} link targets
+      URL classesURL = getClass().getProtectionDomain().getCodeSource().getLocation();
+      assertNotNull("classesURL", classesURL);
+      System.setProperty("test.classes.url", classesURL.toString());
+      URL libURL = super.getResource("/vfs/sundry/jar");
+      assertNotNull("libURL", libURL);      
+      System.setProperty("test.lib.url", libURL.toString());
+
+      // Root the vfs at the link file parent directory
+      URL linkURL = super.getResource("/vfs/links/war1.vfslink.properties");
+      File linkFile = new File(linkURL.toURI());
+      File vfsRoot = linkFile.getParentFile();
+      assertNotNull("vfs/links/war1.vfslink.properties", linkURL);
+      VFS vfs = VFS.getVFS(vfsRoot.toURI());
+
+      // We should find the test-link.war the link represents
+      VirtualFile war = vfs.findChildFromRoot("test-link.war");
+      assertNotNull("war", war);
+
+      // Validate the WEB-INF/classes child link
+      VirtualFile classes = war.findChild("WEB-INF/classes");
+      String classesName = classes.getName();
+      String classesPathName = classes.getPathName();
+      boolean classesIsDirectory = classes.isDirectory();
+      assertEquals("classes.name", "classes", classesName);
+      assertEquals("classes.pathName", "test-link.war/WEB-INF/classes", classesPathName);
+      assertEquals("classes.isDirectory", true, classesIsDirectory);
+      // Should be able to find this class since classes points to out codesource
+      VirtualFile thisClass = classes.findChild("org/jboss/test/virtual/test/FileVFSUnitTestCase.class");
+      assertEquals("FileVFSUnitTestCase.class", thisClass.getName());
+
+      // Validate the WEB-INF/lib child link
+      VirtualFile lib = war.findChild("WEB-INF/lib");
+      String libName = lib.getName();
+      String libPathName = lib.getPathName();
+      boolean libIsDirectory = lib.isDirectory();
+      assertEquals("lib.name", "lib", libName);
+      assertEquals("lib.pathName", "test-link.war/WEB-INF/lib", libPathName);
+      assertEquals("lib.isDirectory", true, libIsDirectory);
+      // Should be able to find archive.jar under lib
+      VirtualFile archiveJar = lib.findChild("archive.jar");
+      assertEquals("archive.jar", archiveJar.getName());
+   }
+
+  /**
+    * Test that the URL of a VFS corresponding to a directory ends in '/' so that
+    * URLs created relative to it are under the directory. This requires that
+    * build-test.xml artifacts exist.
+    * 
+    * @throws Exception
+    */
+   public void testDirURLs() throws Exception
+   {
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+
+      VirtualFile outerJar = vfs.findChildFromRoot("unpacked-outer.jar");
+      URL outerURL = outerJar.toURL();
+      log.debug("outerURL: "+outerURL);
+      assertTrue(outerURL+" ends in '/'", outerURL.getPath().endsWith("/"));
+      // Validate that jar1 is under unpacked-outer.jar
+      URL jar1URL = JarUtils.createJarURL(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!/"));
+      VirtualFile jar1 = outerJar.findChild("jar1.jar");
+      assertEquals(jar1URL, jar1.toURL());
+   }
+}

Deleted: projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SimpleTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SimpleTest.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SimpleTest.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,49 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.virtual.test;
-
-import java.net.URL;
-
-import org.jboss.test.BaseTestCase;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-public class SimpleTest extends BaseTestCase
-{
-   public SimpleTest(String name)
-   {
-      super(name);
-   }
-
-   public void testSomething() throws Exception
-   {
-      VFS vfs = VFS.getVFS(new URL("file:/home/ejort/jboss-4.0/testsuite/output/lib"));
-      VirtualFile root = vfs.findChildFromRoot("jbosstest-web.ear");
-      System.out.println(root);
-
-      VirtualFile test = root.findChild("jbosstest-web.war/WEB-INF/lib/jbosstest-web-libservlet.jar/");
-      System.out.println(test);
-      
-      test = root.findChild("jbosstest-web.war/WEB-INF/lib/jbosstest-web-libservlet.jar/org/jboss/test/web/servlets/lib/SimpleServlet.class");
-      System.out.println(test);
-   }
-}

Deleted: projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SundryVFSTests.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SundryVFSTests.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SundryVFSTests.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,80 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.virtual.test;
-
-import java.net.URL;
-
-import org.jboss.test.BaseTestCase;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
-
-/**
- * SundryVFSTests.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class SundryVFSTests extends BaseTestCase
-{
-   public SundryVFSTests(String name)
-   {
-      super(name);
-   }
-
-   protected VirtualFile getVirtualFile(String root, String path) throws Exception
-   {
-      URL url = getResource(root);
-      assertNotNull(url);
-      return VFS.getVirtualFile(url, path);
-   }
-   
-   public void testBrokenContext() throws Exception
-   {
-      VirtualFile file = getVirtualFile("/vfs/sundry", "jar/archive.jar");
-      log.debug(file.getName() + " " + file);
-      assertTrue("Should be an archive", file.isArchive());
-      file = file.findChild("empty");
-      log.debug(file.getName() + " " + file);
-   }
-   
-   public void testArchive() throws Exception
-   {
-      VirtualFile file = getVirtualFile("/vfs/sundry/", "jar/archive.jar");
-      log.debug(file.getName() + " " + file);
-      assertTrue("Should be an archive", file.isArchive());
-      file = file.findChild("empty");
-      log.debug(file.getName() + " " + file);
-   }
-   
-   public void testArchive2() throws Exception
-   {
-      URL url = getResource("/vfs/sundry/jar/archive.jar");
-      url = JarUtils.createJarURL(url);
-      VFS vfs = VFS.getVFS(url);
-      VirtualFile file = vfs.getRoot();
-      log.debug(file.getName() + " " + file);
-      assertTrue("Should be an archive", file.isArchive());
-      file = file.findChild("empty");
-      log.debug(file.getName() + " " + file);
-   }
-}

Copied: projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SundryVFSUnitTestCase.java (from rev 56964, projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SundryVFSTests.java)
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SundryVFSTests.java	2006-09-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/SundryVFSUnitTestCase.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -0,0 +1,80 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.virtual.test;
+
+import java.net.URL;
+
+import org.jboss.test.BaseTestCase;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+
+/**
+ * SundryVFSTests.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SundryVFSUnitTestCase extends BaseTestCase
+{
+   public SundryVFSUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected VirtualFile getVirtualFile(String root, String path) throws Exception
+   {
+      URL url = getResource(root);
+      assertNotNull(url);
+      return VFS.getVirtualFile(url, path);
+   }
+   
+   public void testBrokenContext() throws Exception
+   {
+      VirtualFile file = getVirtualFile("/vfs/sundry", "jar/archive.jar");
+      log.debug(file.getName() + " " + file);
+      assertTrue("Should be an archive", file.isArchive());
+      file = file.findChild("empty");
+      log.debug(file.getName() + " " + file);
+   }
+   
+   public void testArchive() throws Exception
+   {
+      VirtualFile file = getVirtualFile("/vfs/sundry/", "jar/archive.jar");
+      log.debug(file.getName() + " " + file);
+      assertTrue("Should be an archive", file.isArchive());
+      file = file.findChild("empty");
+      log.debug(file.getName() + " " + file);
+   }
+   
+   public void testArchive2() throws Exception
+   {
+      URL url = getResource("/vfs/sundry/jar/archive.jar");
+      url = JarUtils.createJarURL(url);
+      VFS vfs = VFS.getVFS(url);
+      VirtualFile file = vfs.getRoot();
+      log.debug(file.getName() + " " + file);
+      assertTrue("Should be an archive", file.isArchive());
+      file = file.findChild("empty");
+      log.debug(file.getName() + " " + file);
+   }
+}

Deleted: 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-19 11:27:13 UTC (rev 56964)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/TestFileVFS.java	2006-09-19 13:03:56 UTC (rev 56965)
@@ -1,647 +0,0 @@
-/*
-* JBoss, the OpenSource J2EE webOS
-*
-* Distributable under LGPL license.
-* See terms of license at gnu.org.
-*/
-package org.jboss.test.virtual.test;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-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.Properties;
-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.VFSUtils;
-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.LinkInfo;
-import org.jboss.virtual.spi.VFSContext;
-import org.jboss.virtual.spi.VFSContextFactory;
-import org.jboss.virtual.spi.VFSContextFactoryLocator;
-
-/**
- * Tests of the VFS implementation
- * 
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision: 55523 $
- */
-public class TestFileVFS extends BaseTestCase
-{
-   public TestFileVFS(String name)
-   {
-      super(name);
-   }
-
-   /**
-    * Test that a VFSContextFactory can be created from the testcase CodeSource url
-    * @throws Exception
-    */
-   public void testVFSContextFactory()
-      throws Exception
-   {
-      URL root = getClass().getProtectionDomain().getCodeSource().getLocation();
-      VFSContextFactory factory = VFSContextFactoryLocator.getFactory(root);
-      assertTrue("VFSContextFactory(CodeSource.Location) != null", factory != null);
-   }
-
-   /**
-    * Test that NestedJarFromStream can provide access to nested jar content
-    * @throws Exception
-    */
-   public void testInnerJarFile()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File outerJar = new File("output/lib/outer.jar");
-      assertTrue(outerJar.getAbsolutePath()+" exists", outerJar.exists());
-      JarFile jf = new JarFile(outerJar);
-
-      URL rootURL = outerJar.getParentFile().toURL();
-      VFSContextFactory factory = VFSContextFactoryLocator.getFactory(rootURL);
-      VFSContext context = factory.getVFS(rootURL);
-
-      JarEntry jar1 = jf.getJarEntry("jar1.jar");
-      URL jar1URL = new URL(outerJar.toURL(), "jar1.jar");
-      ZipInputStream jis1 = new ZipInputStream(jf.getInputStream(jar1));
-      NestedJarFromStream njfs = new NestedJarFromStream(context, null, jis1, jar1URL, jar1);
-      NestedJarFromStream.JarEntryContents e1 = njfs.getEntry("org/jboss/test/vfs/support/jar1/ClassInJar1.class");
-      assertNotNull(e1);
-      log.info("org/jboss/test/vfs/support/CommonClass.class: "+e1);
-      NestedJarFromStream.JarEntryContents mfe1 = njfs.getEntry("META-INF/MANIFEST.MF");
-      assertNotNull("jar1!/META-INF/MANIFEST.MF", mfe1);
-      InputStream mfIS = mfe1.openStream();
-      Manifest mf = new Manifest(mfIS);
-      Attributes mainAttrs = mf.getMainAttributes();
-      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar1", version);
-      mfIS.close();
-      njfs.close();
-
-      JarEntry jar2 = jf.getJarEntry("jar2.jar");
-      URL jar2URL = new URL(outerJar.toURL(), "jar2.jar");
-      ZipInputStream jis2 = new ZipInputStream(jf.getInputStream(jar2));
-      NestedJarFromStream njfs2 = new NestedJarFromStream(context, null, jis2, jar2URL, jar2);
-      NestedJarFromStream.JarEntryContents e2 = njfs2.getEntry("org/jboss/test/vfs/support/jar2/ClassInJar2.class");
-      assertNotNull(e2);
-      log.info("org/jboss/test/vfs/support/CommonClass.class: "+e2);
-      NestedJarFromStream.JarEntryContents mfe2 = njfs2.getEntry("META-INF/MANIFEST.MF");
-      assertNotNull("jar2!/META-INF/MANIFEST.MF", mfe2);
-      InputStream mf2IS = mfe2.openStream();
-      Manifest mf2 = new Manifest(mf2IS);
-      Attributes mainAttrs2 = mf2.getMainAttributes();
-      String version2 = mainAttrs2.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar2", version2);
-      mf2IS.close();
-      njfs2.close();
-   }
-
-   /**
-    * Basic tests of accessing resources in a jar
-    * @throws Exception
-    */
-   public void testFindResource()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File outerJar = new File("output/lib/outer.jar");
-      URL rootURL = outerJar.getParentFile().toURL();
-      VFS vfs = VFS.getVFS(rootURL);
-      VirtualFile jar = vfs.findChildFromRoot("outer.jar");
-      assertTrue("outer.jar != null", jar != null);
-
-      /*
-      ArrayList<String> searchCtx = new ArrayList<String>();
-      searchCtx.add("outer.jar");
-      VirtualFile metaInf = vfs.resolveFile("META-INF/MANIFEST.MF", searchCtx);
-      */
-      VirtualFile metaInf = jar.findChild("META-INF/MANIFEST.MF");
-      assertTrue("META-INF/MANIFEST.MF != null", metaInf != null);
-      InputStream mfIS = metaInf.openStream();
-      assertTrue("META-INF/MANIFEST.MF.openStream != null", mfIS != null);
-      Manifest mf = new Manifest(mfIS);
-      Attributes mainAttrs = mf.getMainAttributes();
-      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_VERSION);
-      assertEquals("1.0.0.GA", version);
-      mfIS.close();
-   }
-
-   public void testFindResourceUnpackedJar()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File outerJar = new File("output/lib/unpacked-outer.jar");
-      URL rootURL = outerJar.getParentFile().toURL();
-      VFS vfs = VFS.getVFS(rootURL);
-      VirtualFile jar = vfs.findChildFromRoot("unpacked-outer.jar");
-      assertTrue("unpacked-outer.jar != null", jar != null);
-
-      /**
-      ArrayList<String> searchCtx = new ArrayList<String>();
-      searchCtx.add("unpacked-outer.jar");
-      VirtualFile metaInf = vfs.resolveFile("META-INF/MANIFEST.MF", searchCtx);
-      */
-      VirtualFile metaInf = jar.findChild("META-INF/MANIFEST.MF");
-      assertTrue("META-INF/MANIFEST.MF != null", metaInf != null);
-      InputStream mfIS = metaInf.openStream();
-      assertTrue("META-INF/MANIFEST.MF.openStream != null", mfIS != null);
-      Manifest mf = new Manifest(mfIS);
-      Attributes mainAttrs = mf.getMainAttributes();
-      String version = mainAttrs.getValue(Attributes.Name.SPECIFICATION_VERSION);
-      assertEquals("1.0.0.GA", version);
-      mfIS.close();
-   }
-
-   /**
-    * Test simple file resolution without search contexts
-    * @throws Exception
-    */
-   public void testResolveFile()
-      throws Exception
-   {
-      log.info("+++ testResolveFile, cwd="+(new File(".").getCanonicalPath()));
-      // this expects to be run with a working dir of the container root
-      File outerJarFile = new File("output/lib/outer.jar");
-      URL rootURL = outerJarFile.getParentFile().toURL();
-      VFS vfs = VFS.getVFS(rootURL);
-
-      // Check resolving the root file
-      VirtualFile root = vfs.findChildFromRoot("");
-      assertEquals("root name", "lib", root.getName());
-      assertEquals("root path", "", root.getPathName());
-      assertTrue("root isDirectory", root.isDirectory());
-
-      // Find the outer.jar
-      VirtualFile outerJar = vfs.findChildFromRoot("outer.jar");
-      assertNotNull("outer.jar", outerJar);
-      assertEquals("outer.jar name", "outer.jar", outerJar.getName());
-      assertEquals("outer.jar path", "outer.jar", outerJar.getPathName());
-      
-      VirtualFile outerJarMF = vfs.findChildFromRoot("outer.jar/META-INF/MANIFEST.MF");
-      assertNotNull("outer.jar/META-INF/MANIFEST.MF", outerJarMF);
-
-      // Test a non-canonical path
-      outerJarFile = new File("output/resources/../lib/outer.jar");
-      rootURL = outerJarFile.getParentFile().toURL();
-      // Check resolving the root file
-      root = vfs.findChildFromRoot("");
-      assertEquals("root name", "lib", root.getName());
-      assertEquals("root path", "", root.getPathName());
-      assertTrue("root isDirectory", root.isDirectory());
-   }
-
-   /**
-    * Validate resolving a .class file given a set of search contexts in the
-    * vfs that make up a classpath.
-    * 
-    * @throws Exception
-    */
-   public void testResolveClassFileInClassPath()
-      throws Exception
-   {
-      log.info("+++ testResolveFile, cwd="+(new File(".").getCanonicalPath()));
-      // this expects to be run with a working dir of the container root
-      File libFile = new File("output/lib");
-      URL rootURL = libFile.toURL();
-      VFS vfs = VFS.getVFS(rootURL);
-      
-      // Find ClassInJar1.class
-      VirtualFile vf = vfs.findChildFromRoot("jar1.jar"); 
-      VirtualFile c1 = vf.findChild("org/jboss/test/vfs/support/jar1/ClassInJar1.class");
-      assertNotNull("ClassInJar1.class VF", c1);
-      log.debug("Found ClassInJar1.class: "+c1);
-
-      // Find ClassInJar1$InnerClass.class
-      VirtualFile c1i = vf.findChild("org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class");
-      assertNotNull("ClassInJar1$InnerClass.class VF", c1i);
-      log.debug("Found ClassInJar1$InnerClass.class: "+c1i);
-
-      // Find ClassInJar2.class
-      vf = vfs.findChildFromRoot("jar2.jar");
-      VirtualFile c2 = vf.findChild("org/jboss/test/vfs/support/jar2/ClassInJar2.class");
-      assertNotNull("ClassInJar2.class VF", c2);
-      log.debug("Found ClassInJar2.class: "+c2);
-   }
-
-   public void testResolveFileInUnpackedJar()
-      throws Exception
-   {
-      log.info("+++ testResolveFileInUnpackedJar, cwd="+(new File(".").getCanonicalPath()));
-      // this expects to be run with a working dir of the container root
-      File outerJarFile = new File("output/lib/unpacked-outer.jar");
-      URL rootURL = outerJarFile.getParentFile().toURL();
-      VFS vfs = VFS.getVFS(rootURL);
-
-      // Check resolving the root file
-      VirtualFile root = vfs.findChildFromRoot("");
-      assertEquals("root name", "lib", root.getName());
-      assertEquals("root path", "", root.getPathName());
-      assertTrue("root isDirectory", root.isDirectory());
-
-      // Find the outer.jar
-      VirtualFile outerJar = vfs.findChildFromRoot("unpacked-outer.jar");
-      assertNotNull("unpacked-outer.jar", outerJar);
-      assertEquals("unpacked-outer.jar name", "unpacked-outer.jar", outerJar.getName());
-      assertEquals("unpacked-outer.jar path", "unpacked-outer.jar", outerJar.getPathName());
-      
-      VirtualFile outerJarMF = vfs.findChildFromRoot("unpacked-outer.jar/META-INF/MANIFEST.MF");
-      assertNotNull("unpacked-outer.jar/META-INF/MANIFEST.MF", outerJarMF);
-
-      // Test a non-canonical path
-      outerJarFile = new File("output/resources/../lib/unpacked-outer.jar");
-      rootURL = outerJarFile.getParentFile().toURL();
-      // Check resolving the root file
-      root = vfs.findChildFromRoot("");
-      assertEquals("root name", "lib", root.getName());
-      assertEquals("root path", "", root.getPathName());
-      assertTrue("root isDirectory", root.isDirectory());
-   }
-
-   /**
-    * Test file resolution with nested jars
-    * @throws Exception
-    */
-   public void testInnerJar()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File outerJar = new File("output/lib/outer.jar");
-      URL rootURL = outerJar.getParentFile().toURL();
-      VFS vfs = VFS.getVFS(rootURL);
-      VirtualFile inner = vfs.findChildFromRoot("outer.jar/jar1.jar");
-      log.info("IsFile: "+inner.isFile());
-      log.info(inner.getLastModified());
-      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 a scan of the outer.jar vfs to locate all .class files
-    * @throws Exception
-    */
-   public void testClassScan()
-      throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File outerJarFile = new File("output/lib/outer.jar");
-      URL rootURL = outerJarFile.toURL();
-      VFS vfs = VFS.getVFS(rootURL);
-
-      HashSet<String> expectedClasses = new HashSet<String>();
-      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1.class");
-      expectedClasses.add("jar1.jar/org/jboss/test/vfs/support/jar1/ClassInJar1$InnerClass.class");
-      expectedClasses.add("jar2.jar/org/jboss/test/vfs/support/jar2/ClassInJar2.class");
-      expectedClasses.add("org/jboss/test/vfs/support/CommonClass.class");
-      SuffixMatchFilter classVisitor = new SuffixMatchFilter(".class");
-      List<VirtualFile> classes = vfs.getChildren(classVisitor);
-      int count = 0;
-      for (VirtualFile cf : classes)
-      {
-         String path = cf.getPathName();
-         if( path.endsWith(".class") )
-         {
-            assertTrue(path, expectedClasses.contains(path));
-            count ++;
-         }
-      }
-      assertEquals("There were 4 classes", 4, count);
-   }
-
-   /**
-    * Test the serialization of VirtualFiles
-    * @throws Exception
-    */
-   public void testVFSerialization()
-      throws Exception
-   {
-      File tmpRoot = File.createTempFile("vfs", ".root");
-      tmpRoot.delete();
-      tmpRoot.mkdir();
-      tmpRoot.deleteOnExit();
-      File tmp = new File(tmpRoot, "vfs.ser");
-      tmp.createNewFile();
-      tmp.deleteOnExit();
-      log.info("+++ testVFSerialization, tmp="+tmp.getCanonicalPath());
-      URL rootURL = tmpRoot.toURL();
-      VFS vfs = VFS.getVFS(rootURL);
-      VirtualFile tmpVF = vfs.findChildFromRoot("vfs.ser");
-      FileOutputStream fos = new FileOutputStream(tmp);
-      ObjectOutputStream oos = new ObjectOutputStream(fos);
-      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();
-      // 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", 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 parsing of a vfs link properties file. It contains test.classes.url
-    * and test.lib.url system property references that are configured to
-    * point to the CodeSource location of this class and /vfs/sundry/jar/
-    * respectively.
-    * 
-    * @throws Exception
-    */
-   public void testVfsLinkProperties()
-      throws Exception
-   {
-      URL linkURL = super.getResource("/vfs/links/war1.vfslink.properties");
-      assertNotNull("vfs/links/war1.vfslink.properties", linkURL);
-      // Find resources to use as the WEB-INF/{classes,lib} link targets
-      URL classesURL = getClass().getProtectionDomain().getCodeSource().getLocation();
-      assertNotNull("classesURL", classesURL);
-      System.setProperty("test.classes.url", classesURL.toString());
-      URL libURL = super.getResource("/vfs/sundry/jar");
-      assertNotNull("libURL", libURL);      
-      System.setProperty("test.lib.url", libURL.toString());
-
-      assertTrue("isLink", VFSUtils.isLink(linkURL.getPath()));
-      Properties props = new Properties();
-      InputStream linkIS = linkURL.openStream();
-      List<LinkInfo> infos = VFSUtils.readLinkInfo(linkIS, linkURL.getPath(), props);
-      assertEquals("LinkInfo count", 2, infos.size());
-      LinkInfo classesInfo = null;
-      LinkInfo libInfo = null;
-      for(LinkInfo info :infos)
-      {
-         if( info.getName().equals("WEB-INF/classes") )
-            classesInfo = info;
-         else if(info.getName().equals("WEB-INF/lib") )
-            libInfo = info;
-      }
-      assertNotNull("classesInfo", classesInfo);
-      assertEquals("classesInfo.target", classesURL.toURI(), classesInfo.getLinkTarget());
-      assertNotNull("libInfo", libInfo);
-      assertEquals("libInfo.target", libURL.toURI(), libInfo.getLinkTarget());
-   }
-
-   /**
-    * Test the test-link.war link
-    * @throws Exception
-    */
-   public void testWarLink()
-      throws Exception
-   {
-      // Find resources to use as the WEB-INF/{classes,lib} link targets
-      URL classesURL = getClass().getProtectionDomain().getCodeSource().getLocation();
-      assertNotNull("classesURL", classesURL);
-      System.setProperty("test.classes.url", classesURL.toString());
-      URL libURL = super.getResource("/vfs/sundry/jar");
-      assertNotNull("libURL", libURL);      
-      System.setProperty("test.lib.url", libURL.toString());
-
-      // Root the vfs at the link file parent directory
-      URL linkURL = super.getResource("/vfs/links/war1.vfslink.properties");
-      File linkFile = new File(linkURL.toURI());
-      File vfsRoot = linkFile.getParentFile();
-      assertNotNull("vfs/links/war1.vfslink.properties", linkURL);
-      VFS vfs = VFS.getVFS(vfsRoot.toURI());
-
-      // We should find the test-link.war the link represents
-      VirtualFile war = vfs.findChildFromRoot("test-link.war");
-      assertNotNull("war", war);
-
-      // Validate the WEB-INF/classes child link
-      VirtualFile classes = war.findChild("WEB-INF/classes");
-      String classesName = classes.getName();
-      String classesPathName = classes.getPathName();
-      boolean classesIsDirectory = classes.isDirectory();
-      assertEquals("classes.name", "classes", classesName);
-      assertEquals("classes.pathName", "test-link.war/WEB-INF/classes", classesPathName);
-      assertEquals("classes.isDirectory", true, classesIsDirectory);
-      // Should be able to find this class since classes points to out codesource
-      VirtualFile thisClass = classes.findChild("org/jboss/test/virtual/test/TestFileVFS.class");
-      assertEquals("TestFileVFS.class", thisClass.getName());
-
-      // Validate the WEB-INF/lib child link
-      VirtualFile lib = war.findChild("WEB-INF/lib");
-      String libName = lib.getName();
-      String libPathName = lib.getPathName();
-      boolean libIsDirectory = lib.isDirectory();
-      assertEquals("lib.name", "lib", libName);
-      assertEquals("lib.pathName", "test-link.war/WEB-INF/lib", libPathName);
-      assertEquals("lib.isDirectory", true, libIsDirectory);
-      // Should be able to find archive.jar under lib
-      VirtualFile archiveJar = lib.findChild("archive.jar");
-      assertEquals("archive.jar", archiveJar.getName());
-   }
-
-  /**
-    * Test that the URL of a VFS corresponding to a directory ends in '/' so that
-    * URLs created relative to it are under the directory. This requires that
-    * build-test.xml artifacts exist.
-    * 
-    * @throws Exception
-    */
-   public void testDirURLs() throws Exception
-   {
-      // this expects to be run with a working dir of the container root
-      File libFile = new File("output/lib");
-      URL rootURL = libFile.toURL();
-      VFS vfs = VFS.getVFS(rootURL);
-
-      // Use the unpacked-outer.jar in output/lib
-      VirtualFile outerJar = vfs.findChildFromRoot("unpacked-outer.jar");
-      URL outerURL = outerJar.toURL();
-      log.debug("outerURL: "+outerURL);
-      assertTrue(outerURL+" ends in '/'", outerURL.getPath().endsWith("/"));
-      // Validate that jar1 is under unpacked-outer.jar
-      URL jar1URL = JarUtils.createJarURL(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!/"));
-      VirtualFile jar1 = outerJar.findChild("jar1.jar");
-      assertEquals(jar1URL, jar1.toURL());
-   }
-}




More information about the jboss-cvs-commits mailing list