[jboss-cvs] JBossAS SVN: r59103 - in projects/microcontainer/trunk/container/src: main/org/jboss/virtual/plugins/context/jar resources/tests/vfs/test tests/org/jboss/test/virtual/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Dec 18 18:17:39 EST 2006


Author: scott.stark at jboss.org
Date: 2006-12-18 18:17:33 -0500 (Mon, 18 Dec 2006)
New Revision: 59103

Added:
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/filesonly.mf
   projects/microcontainer/trunk/container/src/resources/tests/vfs/test/filesonly.war
Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
Log:
JBMICROCONT-137, handle the case of SynthenticDirEntryHandler having multiple children, some of which are added after the first createChildHandler call.

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java	2006-12-18 23:16:17 UTC (rev 59102)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/virtual/plugins/context/jar/SynthenticDirEntryHandler.java	2006-12-18 23:17:33 UTC (rev 59103)
@@ -74,8 +74,14 @@
       {
          URL parentVfsUrl = parent.toVfsUrl();
          String vfsParentUrl = parentVfsUrl.toString();
-         if (vfsParentUrl.endsWith("/")) vfsUrl = new URL(vfsParentUrl + entryName);
-         else vfsUrl = new URL(vfsParentUrl + "/" + entryName + "/");
+         if (vfsParentUrl.endsWith("/"))
+         {
+            vfsUrl = new URL(vfsParentUrl + entryName);
+         }
+         else
+         {
+            vfsUrl = new URL(vfsParentUrl + "/" + entryName + "/");
+         }
       }
       catch (URISyntaxException e)
       {
@@ -88,11 +94,13 @@
     * Add a child to an entry
     * @param child
     */
-   public void addChild(VirtualFileHandler child)
+   public synchronized void addChild(VirtualFileHandler child)
    {
       if( entryChildren == null )
          entryChildren = new ArrayList<VirtualFileHandler>();
       entryChildren.add(child);
+      if( entryMap != null )
+         entryMap.put(child.getName(), child);
    }
 
    @Override
@@ -139,9 +147,15 @@
    }
 
    /**
-    * TODO: synchronization on lazy entryMap creation
+    * Create a child handler for the given name. This looks to the entryMap
+    * for an existing child.
+    * @param name - the simple name of an immeadiate child.
+    * @return the VirtualFileHandler previously added via addChild.
+    * @throws IOException - thrown if there are no children or the
+    *  name does not match a child
     */
-   public VirtualFileHandler createChildHandler(String name) throws IOException
+   public synchronized VirtualFileHandler createChildHandler(String name)
+      throws IOException
    {
       if( entryChildren == null )
          throw new FileNotFoundException(this+" has no children");

Added: projects/microcontainer/trunk/container/src/resources/tests/vfs/test/filesonly.mf
===================================================================
--- projects/microcontainer/trunk/container/src/resources/tests/vfs/test/filesonly.mf	2006-12-18 23:16:17 UTC (rev 59102)
+++ projects/microcontainer/trunk/container/src/resources/tests/vfs/test/filesonly.mf	2006-12-18 23:17:33 UTC (rev 59103)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: ${java.runtime.version} (${java.vendor})
+Specification-Title: filesonly-war
+Specification-Version: 1.0.0.GA
+Specification-Vendor: JBoss Inc.
+Implementation-Title: filesonly-war
+Implementation-URL: http://www.jboss.org
+Implementation-Version: 1.0.0.GA-jboss
+Implementation-Vendor: JBoss Inc.
+

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


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

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java	2006-12-18 23:16:17 UTC (rev 59102)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/virtual/test/FileVFSUnitTestCase.java	2006-12-18 23:17:33 UTC (rev 59103)
@@ -1,3 +1,4 @@
+
 /*
  * JBoss, Home of Professional Open Source
  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
@@ -278,6 +279,43 @@
       mfIS.close();
    }
 
+   /**
+    * Basic tests of accessing resources in a war that does not
+    * have parent directory entries.
+    * @throws Exception
+    */
+   public void testFindResourceInFilesOnlyWar()
+      throws Exception
+   {
+      URL rootURL = getResource("/vfs/test");
+      VFS vfs = VFS.getVFS(rootURL);
+      VirtualFile war = vfs.findChild("filesonly.war");
+      assertTrue("filesonly.war != null", war != null);
+
+      VirtualFile classes = war.findChild("WEB-INF/classes");
+      assertTrue("WEB-INF/classes != null", classes != null);
+      assertTrue("WEB-INF/classes is not a leaf", classes.isLeaf()==false);
+
+      VirtualFile jar1 = war.findChild("WEB-INF/lib/jar1.jar");
+      assertTrue("WEB-INF/lib/jar1.jar != null", jar1 != null);
+      assertTrue("WEB-INF/lib/jar1.jar is not a leaf", jar1.isLeaf()==false);
+      VirtualFile ClassInJar1 = jar1.findChild("org/jboss/test/vfs/support/jar1/ClassInJar1.class");
+      assertTrue("ClassInJar1.class != null", ClassInJar1 != null);
+      assertTrue("ClassInJar1.class is a leaf", ClassInJar1.isLeaf());
+
+      VirtualFile metaInf = war.findChild("META-INF/MANIFEST.MF");
+      assertTrue("META-INF/MANIFEST.MF != null", metaInf != null);
+      InputStream mfIS = metaInf.toURL().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);
+      String title = mf.getMainAttributes().getValue(Attributes.Name.SPECIFICATION_TITLE);
+      assertEquals("filesonly-war", title);
+      mfIS.close();
+   }
+
    public void testFindResourceUnpackedJar()
       throws Exception
    {




More information about the jboss-cvs-commits mailing list