[jboss-cvs] JBossAS SVN: r72244 - in projects/vfs/trunk: src/test/java and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 15 12:39:58 EDT 2008


Author: alesj
Date: 2008-04-15 12:39:58 -0400 (Tue, 15 Apr 2008)
New Revision: 72244

Added:
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyFileVFSUnitTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyJARCacheUnitTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyJARSerializationUnitTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARSerializationUnitTestCase.java
Removed:
   projects/vfs/trunk/src/test/java/META-INF/
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/NoCopyJarsUnitTestCase.java
Modified:
   projects/vfs/trunk/pom.xml
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/support/OptionsAwareURI.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AbstractVFSTest.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AssembledContextTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/OSAwareVFSTest.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/SundryVFSUnitTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
Log:
Update junit to 4.4.
Creating some 'force copy' tests.

Modified: projects/vfs/trunk/pom.xml
===================================================================
--- projects/vfs/trunk/pom.xml	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/pom.xml	2008-04-15 16:39:58 UTC (rev 72244)
@@ -32,7 +32,7 @@
     <version.jboss.common.core>2.2.5.GA</version.jboss.common.core>
     <version.jboss.logging>2.0.5.GA</version.jboss.logging>
     <version.jboss.test>1.1.0.GA</version.jboss.test>
-    <version.junit>3.8.1</version.junit>
+    <version.junit>4.4</version.junit>
   </properties>
 
   <build>

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/support/OptionsAwareURI.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/support/OptionsAwareURI.java	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/support/OptionsAwareURI.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -26,44 +26,51 @@
 import java.net.URISyntaxException;
 import java.io.IOException;
 
+import org.jboss.virtual.VFSUtils;
+
 /**
+ * Flag holder.
+ * 
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
 public class OptionsAwareURI
 {
-   private static final String Copy = "useCopyJarHandler=true";
+   private static final String Copy = VFSUtils.USE_COPY_QUERY + "=true";
 
-   private static ThreadLocal<Boolean> flag = new ThreadLocal<Boolean>()
+   private static ThreadLocal<Boolean> flag = new InheritableThreadLocal<Boolean>()
    {
       protected Boolean initialValue()
       {
          return Boolean.FALSE;
       }
+
+      public String toString()
+      {
+         Boolean value = get();
+         return String.valueOf(value);
+      }
    };
 
    public static void set()
    {
-      flag.set(true);
+      flag.set(Boolean.TRUE);
    }
 
+   public static boolean get()
+   {
+      return flag.get();
+   }
+
    public static void clear()
    {
-      flag.set(false);
+      flag.set(Boolean.FALSE);
    }
 
    public static URL toURL(URL url) throws IOException
    {
-      if (flag.get())
+      if (get())
       {
-         try
-         {
-            URI uri = toURI(url.toURI());
-            return uri.toURL();
-         }
-         catch (URISyntaxException e)
-         {
-            throw new IOException(e.getReason());
-         }
+         return new URL(url.toExternalForm() + "?" + Copy);
       }
       else
          return url;
@@ -71,12 +78,11 @@
 
    public static URI toURI(URI uri) throws IOException
    {
-      if (flag.get())
+      if (get())
       {
          try
          {
-            return new URI(uri.toString() + "?" + Copy);
-//            return new URI(uri.getScheme(), uri.getUserInfo(), uri.getPath(), NoCopy, uri.getFragment());
+            return new URI(uri.getScheme(), uri.getUserInfo(), uri.getPath(), Copy, uri.getFragment());
          }
          catch (URISyntaxException e)
          {
@@ -86,4 +92,9 @@
       else
          return uri;
    }
+
+   public String toString()
+   {
+      return "flag=" + get();
+   }
 }

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AbstractVFSTest.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AbstractVFSTest.java	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AbstractVFSTest.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -21,17 +21,22 @@
 */
 package org.jboss.test.virtual.test;
 
+import java.io.IOException;
 import java.net.URL;
 import java.util.Map;
-import java.io.IOException;
 
 import junit.framework.AssertionFailedError;
 import org.jboss.test.BaseTestCase;
+import org.jboss.test.virtual.support.OptionsAwareURI;
+import org.jboss.test.virtual.support.FileOAContextFactory;
+import org.jboss.test.virtual.support.JarOAContextFactory;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VirtualFileHandler;
+import org.jboss.virtual.spi.VFSContextFactoryLocator;
+import org.jboss.virtual.spi.VFSContextFactory;
 
 /**
  * AbstractVFSTest.
@@ -41,11 +46,49 @@
  */
 public abstract class AbstractVFSTest extends BaseTestCase
 {
+   private static final VFSContextFactory fileFactory = new FileOAContextFactory();
+   private static final VFSContextFactory jarFactory = new JarOAContextFactory();
+
+   private boolean forceCopy;
+
    public AbstractVFSTest(String name)
    {
       super(name);
    }
-   
+
+   public AbstractVFSTest(String name, boolean forceCopy)
+   {
+      super(name);
+      this.forceCopy = forceCopy;
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      VFSContextFactoryLocator.registerFactory(fileFactory);
+      VFSContextFactoryLocator.registerFactory(jarFactory);
+
+      getLog().info("Force copy: " + forceCopy);
+      if (forceCopy)
+      {
+         OptionsAwareURI.set();
+      }
+   }
+
+   protected void tearDown() throws Exception
+   {
+      VFSContextFactoryLocator.unregisterFactory(jarFactory);
+      VFSContextFactoryLocator.unregisterFactory(fileFactory);
+
+      if (forceCopy)
+      {
+         OptionsAwareURI.clear();
+      }
+
+      super.tearDown();
+   }
+
    // TODO move to AbstractTestCase
    public URL getResource(String name)
    {

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AssembledContextTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AssembledContextTestCase.java	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AssembledContextTestCase.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -26,7 +26,6 @@
 import java.util.regex.Pattern;
 
 import junit.framework.Test;
-import org.jboss.test.BaseTestCase;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.plugins.context.vfs.AssembledContextFactory;
 import org.jboss.virtual.plugins.context.vfs.AssembledDirectory;
@@ -38,7 +37,7 @@
  * @author Scott.Stark at jboss.org
  * @version $Revision: 1.1 $
  */
-public class AssembledContextTestCase extends BaseTestCase
+public class AssembledContextTestCase extends AbstractVFSTest
 {
    public AssembledContextTestCase(String name)
    {

Copied: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyFileVFSUnitTestCase.java (from rev 72234, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java)
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyFileVFSUnitTestCase.java	                        (rev 0)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyFileVFSUnitTestCase.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests of the VFS implementation
+ *
+ * @author ales.justin at jboss.org
+ */
+public class CopyFileVFSUnitTestCase extends FileVFSUnitTestCase
+{
+   public CopyFileVFSUnitTestCase(String name)
+   {
+      super(name, true);
+   }
+
+   public static Test suite()
+   {
+      return new TestSuite(CopyFileVFSUnitTestCase.class);
+   }
+}
\ No newline at end of file

Copied: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyJARCacheUnitTestCase.java (from rev 72209, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java)
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyJARCacheUnitTestCase.java	                        (rev 0)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyJARCacheUnitTestCase.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Test the caching strategy of VFS with jar files.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CopyJARCacheUnitTestCase extends JARCacheUnitTestCase
+{
+   public CopyJARCacheUnitTestCase(String name)
+   {
+      super(name, true);
+   }
+
+   public static Test suite()
+   {
+      return suite(CopyJARCacheUnitTestCase.class);
+   }
+}
\ No newline at end of file

Added: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyJARSerializationUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyJARSerializationUnitTestCase.java	                        (rev 0)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/CopyJARSerializationUnitTestCase.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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 junit.framework.Test;
+
+/**
+ * Tests of copy nested jars
+ *
+ * @author ales.justin at jboss.org
+ */
+public class CopyJARSerializationUnitTestCase extends JARSerializationUnitTestCase
+{
+   public CopyJARSerializationUnitTestCase(String name)
+   {
+      super(name, true);
+   }
+
+   public static Test suite()
+   {
+      return suite(CopyJARSerializationUnitTestCase.class);
+   }
+}
\ No newline at end of file

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -72,6 +72,11 @@
       super(name);
    }
    
+   protected FileVFSUnitTestCase(String name, boolean forceCopy)
+   {
+      super(name, forceCopy);
+   }
+
    public static Test suite()
    {
       return new TestSuite(FileVFSUnitTestCase.class);

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -30,7 +30,6 @@
 import java.util.jar.Manifest;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 
@@ -47,8 +46,19 @@
       super(name);
    }
 
-   public void test1() throws Exception
+   protected JARCacheUnitTestCase(String name, boolean forceCopy)
    {
+      super(name, forceCopy);
+   }
+
+   public static Test suite()
+   {
+      VFS.init();
+      return suite(JARCacheUnitTestCase.class);
+   }
+
+   public void testJarCache() throws Exception
+   {
       // Create a test.jar with v1 in manifest
       File testFile = new File("test.jar");
       {
@@ -105,10 +115,4 @@
          assertEquals("VFS found the wrong manifest", "v2", actual);
       }
    }
-
-   public static Test suite()
-   {
-      VFS.init();
-      return new TestSuite(JARCacheUnitTestCase.class);
-   }
 }

Added: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARSerializationUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARSerializationUnitTestCase.java	                        (rev 0)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARSerializationUnitTestCase.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -0,0 +1,224 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import junit.framework.Test;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Tests of no copy nested jars
+ *
+ * @author ales.justin at jboss.org
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 72234 $
+ */
+public class JARSerializationUnitTestCase extends AbstractVFSTest
+{
+   public JARSerializationUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected JARSerializationUnitTestCase(String name, boolean forceCopy)
+   {
+      super(name, forceCopy);
+   }
+
+   public static Test suite()
+   {
+      return suite(JARSerializationUnitTestCase.class);
+   }
+
+   /**
+    * Test reading the contents of nested jar entries.
+    * @throws Exception
+    */
+   public void testInnerJarFile() throws Exception
+   {
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile outerjar = vfs.findChild("outer.jar");
+      assertTrue("outer.jar != null", outerjar != null);
+      VirtualFile jar1 = outerjar.findChild("jar1.jar");
+      assertTrue("outer.jar/jar1.jar != null", jar1 != null);
+      VirtualFile jar2 = outerjar.findChild("jar2.jar");
+      assertTrue("outer.jar/jar2.jar != null", jar2 != null);
+
+      VirtualFile jar1MF = jar1.findChild("META-INF/MANIFEST.MF");
+      assertNotNull("jar1!/META-INF/MANIFEST.MF", jar1MF);
+      InputStream mfIS = jar1MF.openStream();
+      Manifest mf1 = new Manifest(mfIS);
+      Attributes mainAttrs1 = mf1.getMainAttributes();
+      String title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals("jar1", title1);
+      jar1MF.close();
+
+      VirtualFile jar2MF = jar2.findChild("META-INF/MANIFEST.MF");
+      assertNotNull("jar2!/META-INF/MANIFEST.MF", jar2MF);
+      InputStream mfIS2 = jar2MF.openStream();
+      Manifest mf2 = new Manifest(mfIS2);
+      Attributes mainAttrs2 = mf2.getMainAttributes();
+      String title2 = mainAttrs2.getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals("jar2", title2);
+      jar2MF.close();
+   }
+
+   public void testInnerJarFileSerialization() throws Exception
+   {
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile outerjar = vfs.findChild("outer.jar");
+      assertTrue("outer.jar != null", outerjar != null);
+      log.info("outer.jar: "+outerjar);
+      VirtualFile jar1 = outerjar.findChild("jar1.jar");
+      assertTrue("outer.jar/jar1.jar != null", jar1 != null);
+      VirtualFile jar2 = outerjar.findChild("jar2.jar");
+      assertTrue("outer.jar/jar2.jar != null", jar2 != null);
+
+      VirtualFile jar1MF = jar1.findChild("META-INF/MANIFEST.MF");
+      assertNotNull("jar1!/META-INF/MANIFEST.MF", jar1MF);
+      InputStream mfIS = jar1MF.openStream();
+      Manifest mf1 = new Manifest(mfIS);
+      Attributes mainAttrs1 = mf1.getMainAttributes();
+      String title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals("jar1", title1);
+      jar1MF.close();
+
+      VirtualFile jar1DS = serializeDeserialize(jar1, VirtualFile.class);
+      assertNotNull("jar1 deserialized", jar1DS);
+      VirtualFile jar1DSMF = jar1.findChild("META-INF/MANIFEST.MF");
+      mfIS = jar1DSMF.openStream();
+      mf1 = new Manifest(mfIS);
+      mainAttrs1 = mf1.getMainAttributes();
+      title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals("jar1", title1);
+      jar1DSMF.close();
+   }
+   /**
+    * JBVFS-17 test
+    * @throws Exception
+    */
+   public void testInnerJarFilesOnlyFileSerialization() throws Exception
+   {
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile outerjar = vfs.findChild("outer.jar");
+      assertTrue("outer.jar != null", outerjar != null);
+      log.info("outer.jar: "+outerjar);
+      VirtualFile jar1 = outerjar.findChild("jar1-filesonly.jar");
+      assertTrue("outer.jar/jar1-filesonly.jar != null", jar1 != null);
+
+      VirtualFile jar1MF = jar1.findChild("META-INF/MANIFEST.MF");
+      assertNotNull("jar1-filesonly!/META-INF/MANIFEST.MF", jar1MF);
+      InputStream mfIS = jar1MF.openStream();
+      Manifest mf1 = new Manifest(mfIS);
+      Attributes mainAttrs1 = mf1.getMainAttributes();
+      String title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals("jar1-filesonly", title1);
+      jar1MF.close();
+
+      VirtualFile jar1DS = serializeDeserialize(jar1, VirtualFile.class);
+      assertNotNull("jar1 deserialized", jar1DS);
+      VirtualFile jar1DSMF = jar1DS.getChild("META-INF/MANIFEST.MF");
+      assertNotNull("jar1-filesonly!/META-INF/MANIFEST.MF", jar1DSMF);
+      mfIS = jar1DSMF.openStream();
+      mf1 = new Manifest(mfIS);
+      mainAttrs1 = mf1.getMainAttributes();
+      title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals("jar1-filesonly", title1);
+      jar1DSMF.close();
+   }
+
+   public void testLevelZips() throws Exception
+   {
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile one = vfs.findChild("level1.zip");
+      VirtualFile textOne = one.findChild("test1.txt");
+      testText(textOne);
+      VirtualFile two = one.findChild("level2.zip");
+      VirtualFile textTwo = two.findChild("test2.txt");
+      testText(textTwo);
+      VirtualFile three = two.findChild("level3.zip");
+      VirtualFile textThree = three.findChild("test3.txt");
+      testText(textThree);
+
+      three = serializeDeserialize(three, VirtualFile.class);
+      textThree = three.findChild("test3.txt");
+      testText(textThree);
+
+      two = serializeDeserialize(two, VirtualFile.class);
+      textTwo = two.findChild("test2.txt");
+      testText(textTwo);
+      three = two.findChild("level3.zip");
+      textThree = two.findChild("level3.zip/test3.txt");
+      testText(textThree);
+      textThree = three.findChild("test3.txt");
+      testText(textThree);
+
+      one = serializeDeserialize(one, VirtualFile.class);
+      textOne = one.findChild("test1.txt");
+      testText(textOne);
+      two = one.findChild("level2.zip");
+      textTwo = one.findChild("level2.zip/test2.txt");
+      testText(textTwo);
+      textTwo = two.findChild("test2.txt");
+      testText(textTwo);
+      three = one.findChild("level2.zip/level3.zip");
+      textThree = three.findChild("test3.txt");
+      testText(textThree);
+      textThree = one.findChild("level2.zip/level3.zip/test3.txt");
+      testText(textThree);
+      three = two.findChild("level3.zip");
+      textThree = three.findChild("test3.txt");
+      testText(textThree);
+      textThree = two.findChild("level3.zip/test3.txt");
+      testText(textThree);
+   }
+
+   protected void testText(VirtualFile file) throws Exception
+   {
+      InputStream in = file.openStream();
+      try
+      {
+         BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+         String line;
+         while ((line = reader.readLine()) != null)
+         {
+            assertEquals("Some test.", line);
+         }
+      }
+      finally
+      {
+         in.close();
+      }
+   }
+
+}
\ No newline at end of file

Deleted: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/NoCopyJarsUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/NoCopyJarsUnitTestCase.java	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/NoCopyJarsUnitTestCase.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -1,242 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * 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.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.jboss.test.BaseTestCase;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Tests of no copy nested jars
- * 
- * @author ales.justin at jboss.org
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision$
- */
-public class NoCopyJarsUnitTestCase extends BaseTestCase
-{
-   private String forceCopy;
-
-   public NoCopyJarsUnitTestCase(String name)
-   {
-      super(name);
-   }
-   
-   public static Test suite()
-   {
-      return new TestSuite(NoCopyJarsUnitTestCase.class);
-   }
-
-   @Override
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-      forceCopy = System.getProperty(VFSUtils.FORCE_COPY_KEY, "false");
-      System.setProperty(VFSUtils.FORCE_COPY_KEY, "true");
-   }
-
-   @Override
-   protected void tearDown() throws Exception
-   {
-      System.setProperty(VFSUtils.FORCE_COPY_KEY, forceCopy);
-      super.tearDown();
-   }
-
-   /**
-    * Test reading the contents of nested jar entries.
-    * @throws Exception
-    */
-   public void testInnerJarFile() throws Exception
-   {
-      URL rootURL = getResource("/vfs/test");
-      VFS vfs = VFS.getVFS(rootURL);
-      VirtualFile outerjar = vfs.findChild("outer.jar");
-      assertTrue("outer.jar != null", outerjar != null);
-      VirtualFile jar1 = outerjar.findChild("jar1.jar");
-      assertTrue("outer.jar/jar1.jar != null", jar1 != null);
-      VirtualFile jar2 = outerjar.findChild("jar2.jar");
-      assertTrue("outer.jar/jar2.jar != null", jar2 != null);
-
-      VirtualFile jar1MF = jar1.findChild("META-INF/MANIFEST.MF");
-      assertNotNull("jar1!/META-INF/MANIFEST.MF", jar1MF);
-      InputStream mfIS = jar1MF.openStream();
-      Manifest mf1 = new Manifest(mfIS);
-      Attributes mainAttrs1 = mf1.getMainAttributes();
-      String title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar1", title1);
-      jar1MF.close();
-
-      VirtualFile jar2MF = jar2.findChild("META-INF/MANIFEST.MF");
-      assertNotNull("jar2!/META-INF/MANIFEST.MF", jar2MF);
-      InputStream mfIS2 = jar2MF.openStream();
-      Manifest mf2 = new Manifest(mfIS2);
-      Attributes mainAttrs2 = mf2.getMainAttributes();
-      String title2 = mainAttrs2.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar2", title2);
-      jar2MF.close();
-   }
-
-   public void testInnerJarFileSerialization() throws Exception
-   {
-      URL rootURL = getResource("/vfs/test");
-      VFS vfs = VFS.getVFS(rootURL);
-      VirtualFile outerjar = vfs.findChild("outer.jar");
-      assertTrue("outer.jar != null", outerjar != null);
-      log.info("outer.jar: "+outerjar);
-      VirtualFile jar1 = outerjar.findChild("jar1.jar");
-      assertTrue("outer.jar/jar1.jar != null", jar1 != null);
-      VirtualFile jar2 = outerjar.findChild("jar2.jar");
-      assertTrue("outer.jar/jar2.jar != null", jar2 != null);
-   
-      VirtualFile jar1MF = jar1.findChild("META-INF/MANIFEST.MF");
-      assertNotNull("jar1!/META-INF/MANIFEST.MF", jar1MF);
-      InputStream mfIS = jar1MF.openStream();
-      Manifest mf1 = new Manifest(mfIS);
-      Attributes mainAttrs1 = mf1.getMainAttributes();
-      String title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar1", title1);
-      jar1MF.close();
-   
-      VirtualFile jar1DS = serializeDeserialize(jar1, VirtualFile.class);
-      assertNotNull("jar1 deserialized", jar1DS);
-      VirtualFile jar1DSMF = jar1.findChild("META-INF/MANIFEST.MF");
-      mfIS = jar1DSMF.openStream();
-      mf1 = new Manifest(mfIS);
-      mainAttrs1 = mf1.getMainAttributes();
-      title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar1", title1);
-      jar1DSMF.close();
-   }
-   /**
-    * JBVFS-17 test
-    * @throws Exception
-    */
-   public void testInnerJarFilesOnlyFileSerialization() throws Exception
-   {
-      URL rootURL = getResource("/vfs/test");
-      VFS vfs = VFS.getVFS(rootURL);
-      VirtualFile outerjar = vfs.findChild("outer.jar");
-      assertTrue("outer.jar != null", outerjar != null);
-      log.info("outer.jar: "+outerjar);
-      VirtualFile jar1 = outerjar.findChild("jar1-filesonly.jar");
-      assertTrue("outer.jar/jar1-filesonly.jar != null", jar1 != null);
-   
-      VirtualFile jar1MF = jar1.findChild("META-INF/MANIFEST.MF");
-      assertNotNull("jar1-filesonly!/META-INF/MANIFEST.MF", jar1MF);
-      InputStream mfIS = jar1MF.openStream();
-      Manifest mf1 = new Manifest(mfIS);
-      Attributes mainAttrs1 = mf1.getMainAttributes();
-      String title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar1-filesonly", title1);
-      jar1MF.close();
-   
-      VirtualFile jar1DS = serializeDeserialize(jar1, VirtualFile.class);
-      assertNotNull("jar1 deserialized", jar1DS);
-      VirtualFile jar1DSMF = jar1DS.getChild("META-INF/MANIFEST.MF");
-      assertNotNull("jar1-filesonly!/META-INF/MANIFEST.MF", jar1DSMF);
-      mfIS = jar1DSMF.openStream();
-      mf1 = new Manifest(mfIS);
-      mainAttrs1 = mf1.getMainAttributes();
-      title1 = mainAttrs1.getValue(Attributes.Name.SPECIFICATION_TITLE);
-      assertEquals("jar1-filesonly", title1);
-      jar1DSMF.close();
-   }
-
-   public void testLevelZips() throws Exception
-   {
-/*
-      URL rootURL = getResource("/vfs/test");
-      VFS vfs = VFS.getVFS(rootURL);
-      VirtualFile one = vfs.findChild("level1.zip");
-      VirtualFile textOne = one.findChild("test1.txt");
-      testText(textOne);
-      VirtualFile two = one.findChild("level2.zip");
-      VirtualFile textTwo = two.findChild("test2.txt");
-      testText(textTwo);
-      VirtualFile three = two.findChild("level3.zip");
-      VirtualFile textThree = three.findChild("test3.txt");
-      testText(textThree);
-
-      three = serializeDeserialize(three, VirtualFile.class);
-      textThree = three.findChild("test3.txt");
-      testText(textThree);
-
-      two = serializeDeserialize(two, VirtualFile.class);
-      textTwo = two.findChild("test2.txt");
-      testText(textTwo);
-      three = two.findChild("level3.zip");
-      textThree = two.findChild("level3.zip/test3.txt");
-      testText(textThree);
-      textThree = three.findChild("test3.txt");
-      testText(textThree);
-
-      one = serializeDeserialize(one, VirtualFile.class);
-      textOne = one.findChild("test1.txt");
-      testText(textOne);
-      two = one.findChild("level2.zip");
-      textTwo = one.findChild("level2.zip/test2.txt");
-      testText(textTwo);
-      textTwo = two.findChild("test2.txt");
-      testText(textTwo);
-      three = one.findChild("level2.zip/level3.zip");
-      textThree = three.findChild("test3.txt");
-      testText(textThree);
-      textThree = one.findChild("level2.zip/level3.zip/test3.txt");
-      testText(textThree);
-      three = two.findChild("level3.zip");
-      textThree = three.findChild("test3.txt");
-      testText(textThree);
-      textThree = two.findChild("level3.zip/test3.txt");
-      testText(textThree);
-*/
-   }
-
-   protected void testText(VirtualFile file) throws Exception
-   {
-      InputStream in = file.openStream();
-      try
-      {
-         BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-         String line;
-         while ((line = reader.readLine()) != null)
-         {
-            assertEquals("Some test.", line);
-         }
-      }
-      finally
-      {
-         in.close();
-      }
-   }
-
-}

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/OSAwareVFSTest.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/OSAwareVFSTest.java	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/OSAwareVFSTest.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -42,6 +42,11 @@
       super(name);
    }
 
+   protected OSAwareVFSTest(String name, boolean forceCopy)
+   {
+      super(name, forceCopy);
+   }
+
    /**
     * Are we running Windows.
     *

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/SundryVFSUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/SundryVFSUnitTestCase.java	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/SundryVFSUnitTestCase.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -25,8 +25,6 @@
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
-
-import org.jboss.test.BaseTestCase;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.plugins.context.jar.JarUtils;
@@ -37,7 +35,7 @@
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
-public class SundryVFSUnitTestCase extends BaseTestCase
+public class SundryVFSUnitTestCase extends AbstractVFSTest
 {
    public SundryVFSUnitTestCase(String name)
    {

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java	2008-04-15 16:37:47 UTC (rev 72243)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java	2008-04-15 16:39:58 UTC (rev 72244)
@@ -21,11 +21,10 @@
 */
 package org.jboss.test.virtual.test;
 
-import org.jboss.virtual.VFS;
-
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
+import org.jboss.virtual.VFS;
 
 /**
  * VFS All Test Suite.
@@ -44,7 +43,7 @@
    public static Test suite()
    {
       VFS.init();
-      TestSuite suite = new TestSuite("VFS Tests");
+      TestSuite suite = new TestSuite("VFS Tests default");
 
       // vfs / spi
       suite.addTest(VFSUnitTestCase.suite());
@@ -55,12 +54,16 @@
       suite.addTest(URLConnectionUnitTestCase.suite());
       // files
       suite.addTest(FileVFSUnitTestCase.suite());
+      suite.addTest(CopyFileVFSUnitTestCase.suite());
       suite.addTest(FileVFSContextUnitTestCase.suite());
       suite.addTest(FileVirtualFileHandlerUnitTestCase.suite());
       // jars
       suite.addTest(JARCacheUnitTestCase.suite());
+      suite.addTest(CopyJARCacheUnitTestCase.suite());
       suite.addTest(JARVFSContextUnitTestCase.suite());
       suite.addTest(JARVirtualFileHandlerUnitTestCase.suite());
+      suite.addTest(JARSerializationUnitTestCase.suite());
+      suite.addTest(CopyJARSerializationUnitTestCase.suite());
       // contexts
       suite.addTest(AssembledContextTestCase.suite());
       suite.addTest(MemoryTestCase.suite());




More information about the jboss-cvs-commits mailing list