[jboss-cvs] JBossAS SVN: r74532 - 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
Fri Jun 13 08:47:59 EDT 2008


Author: alesj
Date: 2008-06-13 08:47:59 -0400 (Fri, 13 Jun 2008)
New Revision: 74532

Modified:
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java
Log:
Close streams.

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-13 12:41:40 UTC (rev 74531)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/JARVFSContextUnitTestCase.java	2008-06-13 12:47:59 UTC (rev 74532)
@@ -129,6 +129,16 @@
       assertEquals("", context.getRoot().getPathName());
    }
 
+   protected static void safeClose(InputStream is)
+   {
+      try
+      {
+         is.close();
+      }
+      catch (Throwable ignore)
+      {
+      }
+   }
 
    /**
     * Handler representing a directory must return a zero length stream
@@ -142,7 +152,14 @@
 
       VirtualFileHandler sub = ctx.getRoot().getChild("subfolder");
       InputStream is = sub.openStream();
-      assertTrue("input stream closed", is.read() == -1);
+      try
+      {
+         assertTrue("input stream closed", is.read() == -1);
+      }
+      finally
+      {
+         safeClose(is);
+      }
    }
 
    /**
@@ -159,7 +176,14 @@
       VirtualFileHandler target = nested.getChild("META-INF/MANIFEST.MF");
 
       InputStream is = target.openStream();
-      assertFalse("input stream closed", is.read() == -1);
+      try
+      {
+         assertFalse("input stream closed", is.read() == -1);
+      }
+      finally
+      {
+         safeClose(is);
+      }
    }
 
    public void testInnerJarOverURL() throws Exception
@@ -168,7 +192,14 @@
       String urlString = url.toExternalForm();
       URL vfsURL = new URL(getProtocol() + urlString.substring(4) + "/complex.jar");
       InputStream is = vfsURL.openStream();
-      assertNotNull(is);
+      try
+      {
+         assertFalse("cannot read input stream", is.read() == -1);
+      }
+      finally
+      {
+         safeClose(is);
+      }
    }
 
    // we need to make sure this doesn't get touched before




More information about the jboss-cvs-commits mailing list