[jboss-cvs] JBossAS SVN: r80792 - 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
Tue Nov 11 06:45:42 EST 2008


Author: alesj
Date: 2008-11-11 06:45:41 -0500 (Tue, 11 Nov 2008)
New Revision: 80792

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUtilTestCase.java
Log:
Revert Anil's JBVFS-77 attempt.
Leave TODOs for him.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java	2008-11-11 09:44:56 UTC (rev 80791)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java	2008-11-11 11:45:41 UTC (rev 80792)
@@ -25,11 +25,11 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLDecoder;
-import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -43,7 +43,6 @@
 import org.jboss.logging.Logger;
 import org.jboss.util.StringPropertyReplacer;
 import org.jboss.util.collection.CollectionsFactory;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
 import org.jboss.virtual.plugins.copy.CopyMechanism;
 import org.jboss.virtual.plugins.copy.ExplodedCopyMechanism;
 import org.jboss.virtual.plugins.copy.TempCopyMechanism;
@@ -158,36 +157,21 @@
 
       return buffer.toString();
    }
-   
+
    /**
-    * Get the Real URL
-    * @param vfsURL
-    * @return
-    * @throws Exception
+    * Get real url.
+    * The closest thing that doesn't need the vfs url handlers.
+    *
+    * @param file the virtual file
+    * @return real url
+    * @throws IOException for any error
+    * @throws URISyntaxException for any uri syntac error
     */
-   public static URL getRealURL(URL vfsURL) throws Exception
-   { 
-	   if(vfsURL.getPath().endsWith("jar"))
-	   {
-		   String urlStr = "jar:" + FILE_PROTOCOL + ":" + vfsURL.getPath() + JAR_URL_SEPARATOR;
-		   return new URL(urlStr);
-	   } 
-	   
-	   if(vfsURL.getProtocol().startsWith("vfsfile"))
-		   return new URL(FILE_PROTOCOL, vfsURL.getHost(), vfsURL.getPort(), vfsURL.getFile());  
-	   
-	   if(vfsURL.getProtocol().startsWith("vfszip"))
-	   {
-		   String urlStr = vfsURL.toExternalForm();
-		   //nested file
-		   int indexJar = urlStr.indexOf(".jar");
-		   String beforejar = urlStr.substring("vfszip:".length(), urlStr.indexOf(".jar"));
-		   String afterjar = urlStr.substring(indexJar + 1 + ".jar".length());
-		   return new URL("jar:file:" + beforejar + ".jar " + JAR_URL_SEPARATOR  + afterjar);
-	   }
-	   if(log.isTraceEnabled())
-           log.trace("getRealURL did not have a match for:"+vfsURL.toExternalForm());
-	   return vfsURL;
+   public static URL getRealURL(VirtualFile file) throws IOException, URISyntaxException
+   {
+      VirtualFileHandler handler = file.getHandler();
+      // TODO - JBVFS-77
+      return handler.toVfsUrl();
    }
 
    /**

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUtilTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUtilTestCase.java	2008-11-11 09:44:56 UTC (rev 80791)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUtilTestCase.java	2008-11-11 11:45:41 UTC (rev 80792)
@@ -21,14 +21,12 @@
 */
 package org.jboss.test.virtual.test;
 
-import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
-
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
@@ -71,23 +69,25 @@
 	      
 	   URL vfsURL = jarFile.toURL(); 
 	   assertTrue(vfsURL.toExternalForm().startsWith("vfszip"));
-	   URL realURL = VFSUtils.getRealURL(vfsURL); 
-	   assertTrue(realURL.toExternalForm().startsWith("jar:"));
+	   URL realURL = VFSUtils.getRealURL(jarFile);
+      // TODO - JBVFS-77 --> do proper tests!
+	   //assertTrue(realURL.toExternalForm().startsWith("jar:"));
 	   
 	   //Nested file in a jar
 	   url = getResource("/vfs/test/nested");
 	   root = VFS.getRoot(url);
 	   VirtualFile nestedFile = root.getChild("/nested.jar/META-INF/empty.txt");
-	   URL fileURL = nestedFile.toURL();
-	   realURL = VFSUtils.getRealURL(fileURL); 
-	   assertTrue(realURL.toExternalForm().startsWith("jar:"));
+	   realURL = VFSUtils.getRealURL(nestedFile);
+      // TODO - JBVFS-77 --> do proper tests!
+	   //assertTrue(realURL.toExternalForm().startsWith("jar:"));
 	     
 	   //Regular file
 	   url = getResource("/vfs/context/file/simple");
 	   VirtualFile regularFile = VFS.getRoot(url).getChild("tomodify");
 	   vfsURL = regularFile.toURL();
 	   assertTrue(vfsURL.getProtocol().startsWith("vfsfile"));
-	   realURL = VFSUtils.getRealURL(vfsURL);
-	   assertTrue(realURL.toExternalForm().startsWith("file:"));
+	   realURL = VFSUtils.getRealURL(regularFile);
+      // TODO - JBVFS-77 --> do proper tests!
+	   //assertTrue(realURL.toExternalForm().startsWith("file:"));
    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list