[jboss-cvs] JBossAS SVN: r84400 - in projects/vfs/trunk/src/test: resources/vfs/test/path and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 18 12:27:25 EST 2009
Author: adrian at jboss.org
Date: 2009-02-18 12:27:25 -0500 (Wed, 18 Feb 2009)
New Revision: 84400
Added:
projects/vfs/trunk/src/test/resources/vfs/test/path with spaces/spaces.ear
Modified:
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/URLExistsUnitTestCase.java
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryHandlerUnitTestCase.java
projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java
Log:
toURI() for the tests as well and include a test for failing spaces.ear
Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java 2009-02-18 17:23:37 UTC (rev 84399)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/FileVFSUnitTestCase.java 2009-02-18 17:27:25 UTC (rev 84400)
@@ -48,9 +48,10 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.jboss.test.virtual.support.ClassPathIterator;
+import org.jboss.test.virtual.support.MetaDataMatchFilter;
import org.jboss.test.virtual.support.ClassPathIterator.ClassPathEntry;
-import org.jboss.test.virtual.support.MetaDataMatchFilter;
import org.jboss.virtual.MemoryFileFactory;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
@@ -130,12 +131,12 @@
assertTrue(outerJar.getAbsolutePath()+" exists", outerJar.exists());
JarFile jf = new JarFile(outerJar);
- URL rootURL = outerJar.getParentFile().toURL();
+ URL rootURL = outerJar.getParentFile().toURI().toURL();
VFSContextFactory factory = VFSContextFactoryLocator.getFactory(rootURL);
VFSContext context = factory.getVFS(rootURL);
JarEntry jar1 = jf.getJarEntry("jar1.jar");
- URL jar1URL = new URL(outerJar.toURL(), "jar1.jar");
+ URL jar1URL = new URL(outerJar.toURI().toURL(), "jar1.jar");
VFSContextFactory pf1 = VFSContextFactoryLocator.getFactory(jar1URL);
VFSContext parent1 = pf1.getVFS(jar1URL);
@@ -155,7 +156,7 @@
njfs.close();
JarEntry jar2 = jf.getJarEntry("jar2.jar");
- URL jar2URL = new URL(outerJar.toURL(), "jar2.jar");
+ URL jar2URL = new URL(outerJar.toURI().toURL(), "jar2.jar");
VFSContextFactory pf2 = VFSContextFactoryLocator.getFactory(jar2URL);
VFSContext parent2 = pf2.getVFS(jar2URL);
@@ -778,7 +779,7 @@
tmp.createNewFile();
tmp.deleteOnExit();
log.info("+++ testVFSerialization, tmp="+tmp.getCanonicalPath());
- URL rootURL = tmpRoot.toURL();
+ URL rootURL = tmpRoot.toURI().toURL();
VFS vfs = VFS.getVFS(rootURL);
VirtualFile tmpVF = vfs.findChild("vfs.ser");
FileOutputStream fos = new FileOutputStream(tmp);
@@ -792,7 +793,7 @@
String name = tmp.getName();
String vfsPath = tmp.getPath();
vfsPath = vfsPath.substring(tmpRoot.getPath().length()+1);
- URL url = new URL("vfs" + tmp.toURL());
+ URL url = new URL("vfs" + tmp.toURI().toURL());
log.debug("name: "+name);
log.debug("vfsPath: "+vfsPath);
log.debug("url: "+url);
@@ -860,7 +861,7 @@
String name = tmpJar.getName();
String vfsPath = tmpJar.getPath();
vfsPath = vfsPath.substring(tmpRoot.getPath().length()+1);
- URL url = new URL("vfs" + tmpJar.toURL() + "/");
+ URL url = new URL("vfs" + tmpJar.toURI().toURL() + "/");
//url = JarUtils.createJarURL(url);
log.debug("name: "+name);
log.debug("vfsPath: "+vfsPath);
@@ -1404,13 +1405,39 @@
is.close();
}
- public static void main(String[] args) throws Exception
+ public void testJarWithSpacesInContext() throws Exception
{
- File file = new File("C:\\Documents and Settings");
- System.out.println(file.toURI());
- System.out.println(file.toURL().getHost());
- URI uri = new URI("file", null, "/Document and Settings", null);
- System.out.println(uri);
+ URL rootURL = getResource("/vfs/test/path with spaces");
+ VFS vfs = VFS.getVFS(rootURL);
+ VirtualFile tstear = vfs.getChild("spaces.ear");
+ assertNotNull("spaces.ear != null", tstear);
+ URI uri = tstear.toURI();
+ URI expectedURI = new URI("vfs"+rootURL.toString()+"/spaces.ear/");
+ assertEquals(expectedURI.getPath(), uri.getPath());
+ assertFalse(tstear.isLeaf());
+
+ InputStream is = uri.toURL().openStream();
+ is.close();
+
+ VirtualFile tstjar = tstear.getChild("spaces-ejb.jar");
+ assertNotNull("spaces-ejb.jar != null", tstjar);
+ uri = tstjar.toURI();
+ expectedURI = new URI("vfs"+rootURL.toString()+"/spaces.ear/spaces-ejb.jar/");
+ assertEquals(expectedURI.getPath(), uri.getPath());
+ assertFalse(tstjar.isLeaf());
+
+ is = uri.toURL().openStream();
+ is.close();
+
+ tstjar = tstear.getChild("spaces-lib.jar");
+ assertNotNull("spaces-lib.jar != null", tstjar);
+ uri = tstjar.toURI();
+ expectedURI = new URI("vfs"+rootURL.toString()+"/spaces.ear/spaces-lib.jar/");
+ assertEquals(expectedURI.getPath(), uri.getPath());
+ assertFalse(tstjar.isLeaf());
+
+ is = uri.toURL().openStream();
+ is.close();
}
/**
@@ -1503,7 +1530,7 @@
File tmp = File.createTempFile("testFileExists", null, tmpRoot);
log.info("+++ testFileExists, tmp="+tmp.getCanonicalPath());
- URL rootURL = tmpRoot.toURL();
+ URL rootURL = tmpRoot.toURI().toURL();
VFS vfs = VFS.getVFS(rootURL);
VirtualFile tmpVF = vfs.findChild(tmp.getName());
assertTrue(tmpVF.getPathName()+".exists()", tmpVF.exists());
@@ -1528,7 +1555,7 @@
assertTrue(tmp+".mkdir()", tmp.mkdir());
log.info("+++ testDirFileExists, tmp="+tmp.getCanonicalPath());
- URL rootURL = tmpRoot.toURL();
+ URL rootURL = tmpRoot.toURI().toURL();
VFS vfs = VFS.getVFS(rootURL);
VirtualFile tmpVF = vfs.findChild(tmp.getName());
assertTrue(tmpVF.getPathName()+".exists()", tmpVF.exists());
@@ -1559,7 +1586,7 @@
jos.setLevel(0);
jos.close();
- URL rootURL = tmpRoot.toURL();
+ URL rootURL = tmpRoot.toURI().toURL();
VFS vfs = VFS.getVFS(rootURL);
VirtualFile tmpVF = vfs.findChild(tmpJar.getName());
assertTrue(tmpVF.getPathName()+".exists()", tmpVF.exists());
@@ -1585,7 +1612,7 @@
assertTrue(tmp+".mkdir()", tmp.mkdir());
log.info("+++ testDirJarExists, tmp="+tmp.getCanonicalPath());
- URL rootURL = tmpRoot.toURL();
+ URL rootURL = tmpRoot.toURI().toURL();
VFS vfs = VFS.getVFS(rootURL);
VirtualFile tmpVF = vfs.findChild(tmp.getName());
log.info(tmpVF);
@@ -1604,7 +1631,7 @@
public void testFileDelete() throws Exception
{
File tmpRoot = File.createTempFile("vfs", ".root");
- VFS vfs = VFS.getVFS(tmpRoot.toURL());
+ VFS vfs = VFS.getVFS(tmpRoot.toURI().toURL());
VirtualFile root = vfs.getRoot();
// non-existent directory - exists() not
Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java 2009-02-18 17:23:37 UTC (rev 84399)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java 2009-02-18 17:27:25 UTC (rev 84400)
@@ -72,7 +72,7 @@
// Verify it via VFS
File root = new File(".");
- VirtualFile vf = VFS.getVirtualFile(root.toURL(), "test.jar");
+ VirtualFile vf = VFS.getVirtualFile(root.toURI().toURL(), "test.jar");
{
VirtualFile manifestFile = vf.findChild("META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(manifestFile.openStream());
@@ -111,7 +111,7 @@
// Verify again - through new context
{
- vf = VFS.getVirtualFile(root.toURL(), "test.jar");
+ vf = VFS.getVirtualFile(root.toURI().toURL(), "test.jar");
VirtualFile manifestFile = vf.findChild("META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(manifestFile.openStream());
String actual = manifest.getMainAttributes().getValue("test");
Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/URLExistsUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/URLExistsUnitTestCase.java 2009-02-18 17:23:37 UTC (rev 84399)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/URLExistsUnitTestCase.java 2009-02-18 17:27:25 UTC (rev 84400)
@@ -56,7 +56,7 @@
public void testFileURLs() throws Exception
{
File tmp = File.createTempFile("testFileURLs", null);
- URL tmpURL = tmp.toURL();
+ URL tmpURL = tmp.toURI().toURL();
URLConnection conn = tmpURL.openConnection();
InputStream in = conn.getInputStream();
long lastModified;
@@ -92,7 +92,7 @@
jos.setLevel(0);
jos.close();
- URL tmpURL = new URL("jar:"+tmp.toURL()+"!/");
+ URL tmpURL = new URL("jar:"+tmp.toURI().toURL()+"!/");
URLConnection conn = tmpURL.openConnection();
conn.setUseCaches(false);
@@ -111,7 +111,7 @@
assertNotSame("lastModified", 0, lastModified);
assertTrue(tmp.getAbsolutePath()+" deleted", tmp.delete());
- tmpURL = new URL("jar:"+tmp.toURL()+"!/");
+ tmpURL = new URL("jar:"+tmp.toURI().toURL()+"!/");
conn = tmpURL.openConnection();
lastModified = conn.getLastModified();
System.out.println("lastModified after delete, "+lastModified);
Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryHandlerUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryHandlerUnitTestCase.java 2009-02-18 17:23:37 UTC (rev 84399)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryHandlerUnitTestCase.java 2009-02-18 17:27:25 UTC (rev 84400)
@@ -72,7 +72,7 @@
tmpRoot.mkdir();
File tmp = File.createTempFile("testFileContextZipDelete", ".jar", tmpRoot);
- VFS vfs = VFS.getVFS(tmpRoot.toURL());
+ VFS vfs = VFS.getVFS(tmpRoot.toURI().toURL());
Manifest mf = new Manifest();
mf.getMainAttributes().putValue("Created-By", getClass().getName() + "." + "testEntryModified");
@@ -155,7 +155,7 @@
jos.close();
}
- VFS vfs = VFS.getVFS(tmp.toURL());
+ VFS vfs = VFS.getVFS(tmp.toURI().toURL());
// children() exist
List<VirtualFile> children = vfs.getChildren();
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 2009-02-18 17:23:37 UTC (rev 84399)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java 2009-02-18 17:27:25 UTC (rev 84400)
@@ -87,7 +87,7 @@
OutputStream os = new FileOutputStream(tmpJar);
VFSUtils.copyStreamAndClose(is, os);
- ZipEntryContext context = new ZipEntryContext(tmpJar.toURL());
+ ZipEntryContext context = new ZipEntryContext(tmpJar.toURI().toURL());
assertTrue("context.getRoot().exists()", context.getRoot().exists());
boolean isDeleted = context.getRoot().delete(1000);
Added: projects/vfs/trunk/src/test/resources/vfs/test/path with spaces/spaces.ear
===================================================================
(Binary files differ)
Property changes on: projects/vfs/trunk/src/test/resources/vfs/test/path with spaces/spaces.ear
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the jboss-cvs-commits
mailing list