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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 20 05:14:32 EDT 2008


Author: alesj
Date: 2008-08-20 05:14:31 -0400 (Wed, 20 Aug 2008)
New Revision: 77231

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContext.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/MemoryTestCase.java
Log:
Revert url path check move.
TODO for Marko - fix failing link tests.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContext.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContext.java	2008-08-20 08:58:56 UTC (rev 77230)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContext.java	2008-08-20 09:14:31 UTC (rev 77231)
@@ -112,7 +112,7 @@
             URL localUrl = new URL(path.toString());
             if (current.getContents() != null)
             {
-               throw new IllegalStateException("Cannot add a child to " + current + " it already has contents");
+               throw new IllegalStateException("Cannot add a child to " + current + ", it already has contents");
             }
             current = new MemoryContextHandler(this, current, localUrl, token);
          }

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java	2008-08-20 08:58:56 UTC (rev 77230)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/memory/MemoryContextFactory.java	2008-08-20 09:14:31 UTC (rev 77231)
@@ -99,14 +99,14 @@
    {
       try
       {
+         String urlPath = url.getPath();
+         if (urlPath != null && urlPath.length() > 0)
+            throw new IllegalArgumentException("Root url cannot contain path - " + urlPath);
+
          String rootName = url.getHost();
          MemoryContext ctx = registry.get(rootName);
          if (ctx == null)
          {
-            String urlPath = url.getPath();
-            if (urlPath != null && urlPath.length() > 0)
-               throw new IllegalArgumentException("Root can not contain '/' - " + urlPath);
-
             URL ctxURL = new URL("vfsmemory://" + rootName);
             ctx = new MemoryContext(ctxURL);
             registry.put(rootName, ctx);

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/MemoryTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/MemoryTestCase.java	2008-08-20 08:58:56 UTC (rev 77230)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/MemoryTestCase.java	2008-08-20 09:14:31 UTC (rev 77231)
@@ -41,7 +41,8 @@
 import org.jboss.virtual.spi.VirtualFileHandler;
 
 /**
- * 
+ * Memory vfs tests.
+ *
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @version $Revision: 1.1 $
@@ -58,6 +59,24 @@
       return suite(MemoryTestCase.class);
    }
 
+   public void testRootCreation() throws Exception
+   {
+      URL dynamicClassRoot = new URL("vfsmemory", new GUID().toString(), "");
+      MemoryFileFactory.createRoot(dynamicClassRoot);
+      URL classesURL = new URL(dynamicClassRoot, "classes");
+      VirtualFile classes = MemoryFileFactory.createDirectory(classesURL);
+      URL url = classes.toURL();
+      try
+      {
+         VFS.getRoot(url);
+         fail("Should not be here");
+      }
+      catch (Exception e)
+      {
+         assertInstanceOf(e, IllegalArgumentException.class);
+      }      
+   }
+
    public void testSerializable() throws Exception
    {
       URI uri = new URI("vfsmemory://aopdomain");




More information about the jboss-cvs-commits mailing list