[jboss-cvs] JBossAS SVN: r76128 - 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 Jul 23 07:12:23 EDT 2008


Author: alesj
Date: 2008-07-23 07:12:23 -0400 (Wed, 23 Jul 2008)
New Revision: 76128

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java
Log:
[JBVFS-47]; collapse repeated slashes.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java	2008-07-23 10:18:50 UTC (rev 76127)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java	2008-07-23 11:12:23 UTC (rev 76128)
@@ -103,7 +103,7 @@
             if (index > 0)
             {
                if (buffer.length() == 0 && specialToken == null)
-                  throw new IllegalArgumentException("A path element is empty: " + path);
+                  continue;
 
                if (specialToken != null)
                   list.add(specialToken);

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java	2008-07-23 10:18:50 UTC (rev 76127)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java	2008-07-23 11:12:23 UTC (rev 76128)
@@ -22,6 +22,7 @@
 package org.jboss.test.virtual.test;
 
 import java.net.URL;
+import java.io.IOException;
 
 import junit.framework.Test;
 import org.jboss.virtual.VFS;
@@ -44,13 +45,23 @@
       return suite(PathTokensTestCase.class);
    }
 
-   protected void testPath(String path) throws Throwable
+   protected VirtualFile testPath(String path) throws IOException
    {
+      URL url = getResource("/vfs");
+      VirtualFile vf = VFS.getRoot(url);
+      return vf.getChild(path);
+   }
+
+   protected void testValidPath(String path) throws Throwable
+   {
+      assertNotNull(testPath(path));      
+   }
+
+   protected void testBrokenPath(String path) throws Throwable
+   {
       try
       {
-         URL url = getResource("/vfs");
-         VirtualFile vf = VFS.getRoot(url);
-         vf.getChild(path);
+         testPath(path);
          fail("Should not be here");
       }
       catch (Throwable t)
@@ -61,18 +72,30 @@
 
    public void testSpecialTokens() throws Throwable
    {
-      testPath("/.../");
-      testPath(".../");
-      testPath("/...");
-      testPath("...");
-      testPath("/..somemorepath/");
-      testPath("..somemorepath/");
-      testPath("/..somemorepath");
-      testPath("..somemorepath");
-      testPath("path//morepath");
-      testPath("//morepath");
-      // we need 3 '/', since by default we always remove the last one
-      testPath("///"); 
-      testPath("morepath///");
+      testBrokenPath("/.../");
+      testBrokenPath(".../");
+      testBrokenPath("/...");
+      testBrokenPath("...");
+      testBrokenPath("/..somemorepath/");
+      testBrokenPath("..somemorepath/");
+      testBrokenPath("/..somemorepath");
+      testBrokenPath("..somemorepath");
+      }
+
+   public void testRepeatedSlashes() throws Throwable
+   {
+      testValidPath("/");
+      testValidPath("//");
+      testValidPath("///");
+      testValidPath("////");
+      testValidPath("//context");
+      testValidPath("//context//");
+      testValidPath("context//file");
+      testValidPath("context///file");
+      testValidPath("//context//file");
+      testValidPath("//context///file");
+      testValidPath("//context////file");
+      testValidPath("//context///jar//");
+      testValidPath("//context///jar///");
    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list