[jboss-cvs] JBossAS SVN: r66211 - 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
Wed Oct 17 03:04:22 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-10-17 03:04:22 -0400 (Wed, 17 Oct 2007)
New Revision: 66211

Modified:
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/MemoryTestCase.java
Log:
Add some VirtualFile method tests

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/MemoryTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/MemoryTestCase.java	2007-10-17 06:17:00 UTC (rev 66210)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/MemoryTestCase.java	2007-10-17 07:04:22 UTC (rev 66211)
@@ -32,6 +32,7 @@
 import org.jboss.virtual.spi.VFSContext;
 import org.jboss.virtual.spi.VFSContextFactory;
 import org.jboss.virtual.spi.VFSContextFactoryLocator;
+import org.jboss.virtual.spi.VirtualFileHandler;
 
 import junit.framework.TestCase;
 
@@ -71,13 +72,23 @@
       URL root = new URL("vfsmemory://aopdomain");
       try
       {
+         long now = System.currentTimeMillis();
          VFSContext ctx = mfactory.createRoot(root);
          URL url = new URL("vfsmemory://aopdomain/org/acme/test/Test.class");
          mfactory.putFile(url,  new byte[] {'a', 'b', 'c'});
          
          String read = readURL(url);
          assertEquals("abc", read);
-         
+
+         VirtualFile classFile = VFS.getVirtualFile(new URL("vfsmemory://aopdomain"), "org/acme/test/Test.class");
+         InputStream bis = classFile.openStream();
+         read = readIS(bis);
+         assertEquals("abc", read);
+         assertEquals(3, classFile.getSize());
+         assertTrue(classFile.exists());
+         assertTrue(classFile.isLeaf());
+         assertTrue(classFile.getLastModified() >= now);
+
          assertTrue(mfactory.delete(url));
          try
          {
@@ -153,13 +164,23 @@
          mfactory.deleteRoot(root);
       }
    }
-   
+
+   protected void setUp()
+   {
+      VFS.init();
+      System.out.println("java.protocol.handler.pkgs: " + System.getProperty("java.protocol.handler.pkgs"));
+   }
    private String readURL(URL url) throws IOException
    {
-      InputStream is = null;
+      InputStream is = url.openStream();
+      String s = readIS(is);
+      return s;
+   }
+   private String readIS(InputStream is)
+      throws IOException
+   {
       try
       {
-         is = url.openStream();
          StringBuffer sb = new StringBuffer();
          while (is.available() != 0)
          {
@@ -179,7 +200,7 @@
             {
             }
          }
-      }
+      }      
    }
    
 }




More information about the jboss-cvs-commits mailing list