[jboss-cvs] JBossAS SVN: r73582 - 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
Thu May 22 07:58:12 EDT 2008


Author: alesj
Date: 2008-05-22 07:58:12 -0400 (Thu, 22 May 2008)
New Revision: 73582

Added:
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java
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/VFSAllTestSuite.java
Log:
[JBVFS-26]; Fix possible special token usage #2.
PathTokenizer test.

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-05-22 11:57:38 UTC (rev 73581)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java	2008-05-22 11:58:12 UTC (rev 73582)
@@ -121,6 +121,8 @@
                specialToken = CURRENT_PATH;
             else if (specialToken == CURRENT_PATH && buffer.length() == 0)
                specialToken = REVERSE_PATH;
+            else if (specialToken != null && buffer.length() == 0)
+               throw new IllegalArgumentException("Illegal token in path: " + path);
             else
                buffer.append(ch);
          }

Copied: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java (from rev 72980, projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/PathQueryTestCase.java)
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java	                        (rev 0)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java	2008-05-22 11:58:12 UTC (rev 73582)
@@ -0,0 +1,73 @@
+/*
+* 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 junit.framework.Test;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Test path tokens.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PathTokensTestCase extends AbstractVFSTest
+{
+   public PathTokensTestCase(String s)
+   {
+      super(s);
+   }
+
+   public static Test suite()
+   {
+      return suite(PathTokensTestCase.class);
+   }
+
+   protected void testPath(String path) throws Throwable
+   {
+      try
+      {
+         URL url = getResource("/vfs");
+         VirtualFile vf = VFS.getRoot(url);
+         vf.getChild(path);
+         fail("Should not be here");
+      }
+      catch (Throwable t)
+      {
+         assertInstanceOf(t, IllegalArgumentException.class, false);
+      }
+   }
+
+   public void testSpecialTokens() throws Throwable
+   {
+      testPath("/.../");
+      testPath(".../");
+      testPath("/...");
+      testPath("...");
+      testPath("/..somemorepath/");
+      testPath("..somemorepath/");
+      testPath("/..somemorepath");
+      testPath("..somemorepath");  
+   }
+}
\ No newline at end of file

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-05-22 11:57:38 UTC (rev 73581)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSAllTestSuite.java	2008-05-22 11:58:12 UTC (rev 73582)
@@ -70,8 +70,9 @@
       suite.addTest(AssembledContextTestCase.suite());
       suite.addTest(MemoryTestCase.suite());
       suite.addTest(SundryVFSUnitTestCase.suite());
-      // options / policy
+      // options / policy / path
       suite.addTest(PathQueryTestCase.suite());
+      suite.addTest(PathTokensTestCase.suite());
       // unpack
       suite.addTest(UnpackTestCase.suite());
 




More information about the jboss-cvs-commits mailing list