[jboss-cvs] JBossAS SVN: r81088 - in projects/vfs/trunk/src/test: resources/vfs/context/file and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Nov 15 03:10:23 EST 2008


Author: alesj
Date: 2008-11-15 03:10:22 -0500 (Sat, 15 Nov 2008)
New Revision: 81088

Added:
   projects/vfs/trunk/src/test/resources/vfs/context/file/nested/
   projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/
   projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/
   projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/subchild
   projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/subsubfolder/
   projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/subsubfolder/subsubchild
Modified:
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AbstractVFSContextTest.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSContextUnitTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java
Log:
Add vfs context test for real url - commented.

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AbstractVFSContextTest.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AbstractVFSContextTest.java	2008-11-14 19:50:04 UTC (rev 81087)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/AbstractVFSContextTest.java	2008-11-15 08:10:22 UTC (rev 81088)
@@ -23,12 +23,14 @@
 
 import java.io.IOException;
 import java.net.URI;
+import java.net.URL;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
 import org.jboss.test.virtual.support.MockVirtualFileHandlerVisitor;
 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;
@@ -52,12 +54,79 @@
 
    protected abstract String getSuffix();
 
+   protected abstract String getRealProtocol();
+
+   protected abstract String getRealURLEnd();
+
+   protected abstract String transformExpectedEnd(String expecetedEnd);
+
    /* TODO URI testing
    public void testRootURI() throws Exception
    {
    }
    */
-   
+
+
+/*
+   TODO - test diff structures
+
+   public void testRealURL() throws Exception
+   {
+      assertRealURL("children", null, null);
+      assertRealURL("children", "child1", null);
+      assertRealURL("complex", null, null);
+      assertRealURL("complex", "subfolder", null);
+      assertRealURL("complex", "subfolder/subchild", null);
+      assertRealURL("complex", "subfolder/subsubfolder", null);
+      assertRealURL("complex", "subfolder/subsubfolder/subsubchild", null);
+      assertRealURL("nested", null, null);
+      assertRealURL("nested", "complex.jar", null);
+      assertRealURL("nested", "complex.jar/subfolder", "complex.jar");
+      assertRealURL("nested", "complex.jar/subfolder/subchild", "complex.jar");
+      assertRealURL("nested", "complex.jar/subfolder/subsubfolder", "complex.jar");
+      assertRealURL("nested", "complex.jar/subfolder/subsubfolder/subsubchild", "complex.jar");
+   }
+*/
+
+   @SuppressWarnings("deprecation")
+   public void assertRealURL(String name, String path, String expectedEnd) throws Exception
+   {
+      VFSContext context = getVFSContext(name);
+      VirtualFile root = context.getRoot().getVirtualFile();
+      VirtualFile file = root;
+      if (path != null && path.length() > 0)
+         file = root.findChild(path);
+
+      URL realURL = VFSUtils.getRealURL(file);
+      String realURLString = realURL.toExternalForm();
+
+      URL rootURL = root.toURL();
+      String rootURLString = rootURL.toExternalForm();
+      int p = rootURLString.indexOf(":/");
+      int l = rootURLString.length() - 1;
+      if (rootURLString.charAt(l - 1) == '!')
+         l--;
+      String middle = rootURLString.substring(p, l);
+      String end;
+      expectedEnd = transformExpectedEnd(expectedEnd);
+      if (expectedEnd == null)
+      {
+         end = (path != null) ? path : "";
+      }
+      else
+      {
+         end = expectedEnd;
+      }
+
+      String expectedRealURL = getRealProtocol() + middle + getRealURLEnd() + end;
+      if (expectedRealURL.endsWith("/") && realURLString.endsWith("/") == false)
+         realURLString += "/";
+      if (expectedRealURL.endsWith("/") == false && realURLString.endsWith("/"))
+         expectedRealURL += "/";
+
+      assertEquals(expectedRealURL, realURLString);
+   }
+
    public void testGetVFS() throws Exception
    {
       VFSContext context = getVFSContext("simple");

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSContextUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSContextUnitTestCase.java	2008-11-14 19:50:04 UTC (rev 81087)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSContextUnitTestCase.java	2008-11-15 08:10:22 UTC (rev 81088)
@@ -63,4 +63,19 @@
    {
       return "";
    }
+
+   protected String getRealProtocol()
+   {
+      return "file";
+   }
+
+   protected String getRealURLEnd()
+   {
+      return "/";
+   }
+
+   protected String transformExpectedEnd(String expecetedEnd)
+   {
+      return null;
+   }
 }

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java	2008-11-14 19:50:04 UTC (rev 81087)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java	2008-11-15 08:10:22 UTC (rev 81088)
@@ -94,6 +94,21 @@
       return ".jar";
    }
 
+   protected String getRealProtocol()
+   {
+      return "jar:file";
+   }
+
+   protected String getRealURLEnd()
+   {
+      return "!/";
+   }
+
+   protected String transformExpectedEnd(String expecetedEnd)
+   {
+      return expecetedEnd;
+   }
+
    /**
     * Was having problems with a jar entry as root of VFS.
     *

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java	2008-11-14 19:50:04 UTC (rev 81087)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java	2008-11-15 08:10:22 UTC (rev 81088)
@@ -155,9 +155,9 @@
    /**
     * Real URL test
     *
-    * @throws Exception
+    * @throws Exception for any error
     */
-   public void testRealURL() throws Exception
+   public void testCustomRealURL() throws Exception
    {
       URL url = getResource("/vfs/context/jar/");
       FileSystemContext ctx = new FileSystemContext(url);

Added: projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/subchild
===================================================================
--- projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/subchild	                        (rev 0)
+++ projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/subchild	2008-11-15 08:10:22 UTC (rev 81088)
@@ -0,0 +1 @@
+empty
\ No newline at end of file

Added: projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/subsubfolder/subsubchild
===================================================================
--- projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/subsubfolder/subsubchild	                        (rev 0)
+++ projects/vfs/trunk/src/test/resources/vfs/context/file/nested/complex.jar/subfolder/subsubfolder/subsubchild	2008-11-15 08:10:22 UTC (rev 81088)
@@ -0,0 +1 @@
+complex/subsubfolder/subsubchild
\ No newline at end of file




More information about the jboss-cvs-commits mailing list