[jboss-cvs] JBossAS SVN: r74286 - projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Jun 8 09:17:40 EDT 2008
Author: alesj
Date: 2008-06-08 09:17:40 -0400 (Sun, 08 Jun 2008)
New Revision: 74286
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/ZipEntryVFSContextUnitTestCase.java
Log:
Join tests.
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-06-08 12:23:26 UTC (rev 74285)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java 2008-06-08 13:17:40 UTC (rev 74286)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.virtual.test;
+import java.io.InputStream;
import java.net.URL;
import junit.framework.Test;
@@ -30,6 +31,7 @@
import org.jboss.virtual.plugins.context.jar.JarContext;
import org.jboss.virtual.plugins.context.jar.JarUtils;
import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.VirtualFileHandler;
/**
* JARVFSContextUnitTestCase.
@@ -64,6 +66,13 @@
return new FileSystemContext(url);
}
+ protected VFSContext createVSFContext(URL url) throws Exception
+ {
+ if (url.toExternalForm().startsWith("jar") == false)
+ url = JarUtils.createJarURL(url);
+ return new JarContext(url);
+ }
+
protected String getSuffix()
{
return ".jar";
@@ -79,13 +88,13 @@
URL url = getResource("/vfs/context/jar/simple.jar");
URL entry = new URL("jar:" + url.toString() + "!/child");
//entry.openStream().close();
- JarContext context = new JarContext(entry);
+ VFSContext context = createVSFContext(entry);
assertEquals("child", context.getRoot().getName());
url = getResource("/vfs/test/outer.jar");
entry = new URL("jar:" + url.toString() + "!/jar2.jar ");
//entry.openStream().close();
- context = new JarContext(entry);
+ context = createVSFContext(entry);
assertEquals("jar2.jar", context.getRoot().getName());
}
@@ -100,16 +109,48 @@
URL url = getResource("/vfs/context/jar/simple.jar");
URL entry = new URL("jar:" + url.toString() + "!/child");
//entry.openStream().close();
- JarContext context = new JarContext(entry);
+ VFSContext context = createVSFContext(entry);
assertEquals("child", context.getRoot().getName());
assertEquals("", context.getRoot().getPathName());
url = getResource("/vfs/test/outer.jar");
entry = new URL("jar:" + url.toString() + "!/jar2.jar ");
//entry.openStream().close();
- context = new JarContext(entry);
+ context = createVSFContext(entry);
assertEquals("jar2.jar", context.getRoot().getName());
assertEquals("", context.getRoot().getPathName());
}
+
+ /**
+ * Handler representing a directory must return a zero length stream
+ *
+ * @throws Exception for any error
+ */
+ public void testDirectoryZipEntryOpenStream() throws Exception
+ {
+ URL url = getResource("/vfs/context/jar/complex.jar");
+ VFSContext ctx = createVSFContext(url);
+
+ VirtualFileHandler sub = ctx.getRoot().getChild("subfolder");
+ InputStream is = sub.openStream();
+ assertTrue("input stream closed", is.read() == -1);
+ }
+
+ /**
+ * There was a problem with noCopy inner jars returning empty streams
+ *
+ * @throws Exception for any error
+ */
+ public void testInnerJarFileEntryOpenStream() throws Exception
+ {
+ URL url = getResource("/vfs/context/jar/nested.jar");
+ VFSContext ctx = createVSFContext(url);
+
+ VirtualFileHandler nested = ctx.getRoot().getChild("complex.jar");
+ VirtualFileHandler target = nested.getChild("META-INF/MANIFEST.MF");
+
+ InputStream is = target.openStream();
+ assertFalse("input stream closed", is.read() == -1);
+ }
}
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-06-08 12:23:26 UTC (rev 74285)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java 2008-06-08 13:17:40 UTC (rev 74286)
@@ -62,49 +62,12 @@
return new ZipEntryContext(url);
}
- /**
- * Analog to the same test in {@link JARVFSContextUnitTestCase}
- *
- * @throws Exception
- */
- public void testJarEntryAsRoot() throws Exception
+ protected VFSContext createVSFContext(URL url) throws Exception
{
- URL url = getResource("/vfs/context/jar/simple.jar");
- URL entry = new URL("jar:" + url.toString() + "!/child");
- //entry.openStream().close();
- ZipEntryContext context = new ZipEntryContext(entry);
- assertEquals("child", context.getRoot().getName());
-
- url = getResource("/vfs/test/outer.jar");
- entry = new URL("jar:" + url.toString() + "!/jar2.jar ");
- //entry.openStream().close();
- context = new ZipEntryContext(entry);
- assertEquals("jar2.jar", context.getRoot().getName());
+ return new ZipEntryContext(url);
}
/**
- * Analog to the same test in {@link JARVFSContextUnitTestCase}
- *
- * @throws Exception for any error
- */
- public void testPathIsEmptryForJarEntryAsRoot() throws Exception
- {
- URL url = getResource("/vfs/context/jar/simple.jar");
- URL entry = new URL("jar:" + url.toString() + "!/child");
- //entry.openStream().close();
- ZipEntryContext context = new ZipEntryContext(entry);
- assertEquals("child", context.getRoot().getName());
- assertEquals("", context.getRoot().getPathName());
-
- url = getResource("/vfs/test/outer.jar");
- entry = new URL("jar:" + url.toString() + "!/jar2.jar ");
- //entry.openStream().close();
- context = new ZipEntryContext(entry);
- assertEquals("jar2.jar", context.getRoot().getName());
- assertEquals("", context.getRoot().getPathName());
- }
-
- /**
* Test detection of underlying jar file removal through exists()
*
* @throws Exception for any error
@@ -158,36 +121,4 @@
handler = ctx.getRoot().getChild("notanarchive.jar");
assertTrue("is leaf", handler.isLeaf());
}
-
- /**
- * Handler representing a directory must return a zero length stream
- *
- * @throws Exception for any error
- */
- public void testDirectoryZipEntryOpenStream() throws Exception
- {
- URL url = getResource("/vfs/context/jar/complex.jar");
- ZipEntryContext ctx = new ZipEntryContext(url);
-
- VirtualFileHandler sub = ctx.getRoot().getChild("subfolder");
- InputStream is = sub.openStream();
- assertTrue("input stream closed", is.read() == -1);
- }
-
- /**
- * There was a problem with noCopy inner jars returning empty streams
- *
- * @throws Exception for any error
- */
- public void testInnerJarFileEntryOpenStream() throws Exception
- {
- URL url = getResource("/vfs/context/jar/nested.jar");
- ZipEntryContext ctx = new ZipEntryContext(url);
-
- VirtualFileHandler nested = ctx.getRoot().getChild("complex.jar");
- VirtualFileHandler target = nested.getChild("META-INF/MANIFEST.MF");
-
- InputStream is = target.openStream();
- assertFalse("input stream closed", is.read() == -1);
- }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list