[jboss-cvs] container/src/tests/org/jboss/test/vfs ...
Scott Stark
scott.stark at jboss.com
Wed Jul 12 20:21:50 EDT 2006
User: starksm
Date: 06/07/12 20:21:50
Modified: src/tests/org/jboss/test/vfs TestFileVFS.java
Log:
Add support for serialization of VirtualFiles for the file protocol
Revision Changes Path
1.6 +46 -2 container/src/tests/org/jboss/test/vfs/TestFileVFS.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TestFileVFS.java
===================================================================
RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/vfs/TestFileVFS.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- TestFileVFS.java 4 May 2006 14:49:38 -0000 1.5
+++ TestFileVFS.java 13 Jul 2006 00:21:50 -0000 1.6
@@ -7,7 +7,11 @@
package org.jboss.test.vfs;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.net.URL;
@@ -32,7 +36,7 @@
* Tests of the VFS implementation
*
* @author Scott.Stark at jboss.org
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class TestFileVFS extends BaseTestCase
{
@@ -157,7 +161,7 @@
}
/**
- * Test vile resolution with nested jars
+ * Test file resolution with nested jars
* @throws Exception
*/
public void testInnerJar()
@@ -221,4 +225,44 @@
}
assertEquals("There were 3 classes", 3, count);
}
+
+ /**
+ * Test the serialization of VirtualFiles
+ * @throws Exception
+ */
+ public void testVFSerialization()
+ throws Exception
+ {
+ File tmpRoot = File.createTempFile("vfs", ".root");
+ tmpRoot.delete();
+ tmpRoot.mkdir();
+ tmpRoot.deleteOnExit();
+ File tmp = new File(tmpRoot, "vfs.ser");
+ tmp.deleteOnExit();
+ log.info("+++ testVFSerialization, tmp="+tmp.getCanonicalPath());
+ URL rootURL = tmpRoot.toURL();
+ VFSFactory factory = VFSFactoryLocator.getFactory(rootURL);
+ ReadOnlyVFS vfs = factory.getVFS(rootURL);
+ VirtualFile tmpVF = vfs.resolveFile("vfs.ser");
+ FileOutputStream fos = new FileOutputStream(tmp);
+ ObjectOutputStream oos = new ObjectOutputStream(fos);
+ oos.writeObject(tmpVF);
+ oos.close();
+
+ FileInputStream fis = new FileInputStream(tmp);
+ ObjectInputStream ois = new ObjectInputStream(fis);
+ VirtualFile tmpVF2 = (VirtualFile) ois.readObject();
+ ois.close();
+ long lastModified = tmpVF.getLastModified();
+ long size = tmpVF.getSize();
+ String name = tmpVF.getName();
+ String pathName = tmpVF.getPathName();
+ URL url = tmpVF.toURL();
+
+ assertEquals("name", name, tmpVF2.getName());
+ assertEquals("pathName", pathName, tmpVF2.getPathName());
+ assertEquals("lastModified", lastModified, tmpVF2.getLastModified());
+ assertEquals("size", size, tmpVF2.getSize());
+ assertEquals("url", url, tmpVF2.toURL());
+ }
}
More information about the jboss-cvs-commits
mailing list