diff --git a/src/test/java/org/jboss/test/virtual/test/HDScannerTestCase.java b/src/test/java/org/jboss/test/virtual/test/HDScannerTestCase.java
index cd7cf8c8..0897a81a 100644
--- a/src/test/java/org/jboss/test/virtual/test/HDScannerTestCase.java
+++ b/src/test/java/org/jboss/test/virtual/test/HDScannerTestCase.java
@@ -39,17 +39,17 @@
* @author Scott.Stark@jboss.org
* @version $Revision:$
*/
-public class HDScannerTestCase extends OSAwareVFSTest
+public class HDScannerTestCase extends AbstractVFSTest
{
public HDScannerTestCase(String name, boolean forceCopy)
{
- super(name, forceCopy, true);
+ super(name, forceCopy, false);
}
public HDScannerTestCase(String name)
{
- super(name, true, true);
+ super(name, true, false);
}
public void testDeleteWhileScanning()
@@ -87,7 +87,8 @@ public void testDeleteWhileScanning()
archive.setLastModified(System.currentTimeMillis());
}
getLog().info("Trying to remove: "+archive.getAbsolutePath());
- assertTrue(archive.delete());
+ assertTrue(archiveVF.delete());
+ assertFalse(archiveVF.exists());
getLog().info("Deleted deployed archive");
scanner.stop();
}
diff --git a/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java b/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java
index 9195268d..b486b5df 100644
--- a/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java
+++ b/src/test/java/org/jboss/test/virtual/test/JARCacheUnitTestCase.java
@@ -39,16 +39,16 @@
* @author Carlo de Wolf
* @version $Revision$
*/
-public class JARCacheUnitTestCase extends OSAwareVFSTest
+public class JARCacheUnitTestCase extends AbstractVFSTest
{
public JARCacheUnitTestCase(String name)
{
- super(name);
+ super(name, false, false);
}
protected JARCacheUnitTestCase(String name, boolean forceCopy)
{
- super(name, forceCopy);
+ super(name, forceCopy, false);
}
public static Test suite()
@@ -69,20 +69,19 @@ public void testJarCache() throws Exception
out.flush();
out.close();
}
-
+
// Verify it via VFS
File root = new File(".");
+ VirtualFile vf = VFS.getVirtualFile(root.toURL(), "test.jar");
{
- VirtualFile vf = VFS.getVirtualFile(root.toURL(), "test.jar");
-// System.err.println("lastModified = " + vf.getLastModified());
VirtualFile manifestFile = vf.findChild("META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(manifestFile.openStream());
String actual = manifest.getMainAttributes().getValue("test");
assertEquals("v1", actual);
}
- // If we don't delete, VFS will give ZIP errors (related issue?)
- assertTrue("test file deleted: " + testFile, testFile.delete() || isWindowsOS());
+ // If we don't delete, we get a corrupt zip entries iterator on linux
+ assertTrue("test file deleted: " + testFile, vf.delete());
// Create a new test.jar with manifest v2
{
@@ -104,11 +103,15 @@ public void testJarCache() throws Exception
// Verify the manifest the VFS way
{
- VirtualFile vf = VFS.getVirtualFile(root.toURL(), "test.jar");
- // Note that the modification date has not changed according to VFS
-// System.err.println("lastModified = " + vf.getLastModified());
-// System.err.println("modified = " + vf.hasBeenModified());
-
+ VirtualFile manifestFile = vf.findChild("META-INF/MANIFEST.MF");
+ Manifest manifest = new Manifest(manifestFile.openStream());
+ String actual = manifest.getMainAttributes().getValue("test");
+ assertEquals("VFS found the wrong manifest", "v2", actual);
+ }
+
+ // Verify again - through new context
+ {
+ vf = VFS.getVirtualFile(root.toURL(), "test.jar");
VirtualFile manifestFile = vf.findChild("META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(manifestFile.openStream());
String actual = manifest.getMainAttributes().getValue("test");
diff --git a/src/test/java/org/jboss/test/virtual/test/JAREntryTestCase.java b/src/test/java/org/jboss/test/virtual/test/JAREntryTestCase.java
index 6394a57e..1088d562 100644
--- a/src/test/java/org/jboss/test/virtual/test/JAREntryTestCase.java
+++ b/src/test/java/org/jboss/test/virtual/test/JAREntryTestCase.java
@@ -37,16 +37,16 @@
*
* @author Ales.Justin@jboss.org
*/
-public class JAREntryTestCase extends OSAwareVFSTest
+public class JAREntryTestCase extends AbstractVFSTest
{
public JAREntryTestCase(String name)
{
- super(name);
+ super(name, false, false);
}
protected JAREntryTestCase(String name, boolean forceCopy)
{
- super(name, forceCopy);
+ super(name, forceCopy, false);
}
public static Test suite()
@@ -78,6 +78,9 @@ public void testEntryModified() throws Exception
List children = metainf.getChildren();
assertEquals(1, children.size());
+ // delete zipFile before recreating it otherwise you get a corrupt entries iterator on linux
+ assertTrue(root.delete());
+
fos = new FileOutputStream(tmp);
jos = new JarOutputStream(fos, mf);
try
diff --git a/src/test/java/org/jboss/test/virtual/test/URLExistsUnitTestCase.java b/src/test/java/org/jboss/test/virtual/test/URLExistsUnitTestCase.java
index 44df3577..93484d6e 100644
--- a/src/test/java/org/jboss/test/virtual/test/URLExistsUnitTestCase.java
+++ b/src/test/java/org/jboss/test/virtual/test/URLExistsUnitTestCase.java
@@ -37,7 +37,7 @@
* @author Scott.Stark@jboss.org
* @version $Revision$
*/
-public class URLExistsUnitTestCase extends OSAwareVFSTest
+public class URLExistsUnitTestCase extends AbstractVFSTest
{
public URLExistsUnitTestCase(String name)
{
@@ -70,7 +70,7 @@ public void testFileURLs() throws Exception
{
in.close();
}
- assertTrue(tmp.getAbsolutePath()+" deleted", tmp.delete() || isWindowsOS());
+ assertTrue(tmp.getAbsolutePath()+" deleted", tmp.delete());
conn = tmpURL.openConnection();
lastModified = conn.getLastModified();
System.out.println("lastModified after delete, "+lastModified);
@@ -94,14 +94,28 @@ public void testJarURLs() throws Exception
URL tmpURL = new URL("jar:"+tmp.toURL()+"!/");
URLConnection conn = tmpURL.openConnection();
+ conn.setUseCaches(false);
+
long lastModified = conn.getLastModified();
+
+ // the following ugly block of code is
+ // the only known way to force jar file lock release on Windows
+ // and it's not even 100% reliable
+ conn = null;
+ tmpURL = null;
+ System.gc();
+ Thread.sleep(500);
+ System.gc();
+
System.out.println("lastModified, "+lastModified);
assertNotSame("lastModified", 0, lastModified);
- assertTrue(tmp.getAbsolutePath()+" deleted", tmp.delete() || isWindowsOS());
+ assertTrue(tmp.getAbsolutePath()+" deleted", tmp.delete());
+
+ tmpURL = new URL("jar:"+tmp.toURL()+"!/");
conn = tmpURL.openConnection();
lastModified = conn.getLastModified();
System.out.println("lastModified after delete, "+lastModified);
// TODO - fix back
- assertTrue("lastModified", 0 == lastModified || isWindowsOS());
+ assertTrue("lastModified", 0 == lastModified);
}
}
diff --git a/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java b/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java
index 2d3b2232..d6cfd15a 100644
--- a/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java
+++ b/src/test/java/org/jboss/test/virtual/test/ZipEntryVFSContextUnitTestCase.java
@@ -89,15 +89,11 @@ public void testRootExists() throws Exception
}
os.close();
- // use noReaper so that the underlying file is not locked
- // when we try to delete it
- String jarUrl = tmpJar.toURL().toString() + "?noReaper=true";
- ZipEntryContext context = new ZipEntryContext(new URL(jarUrl));
+ ZipEntryContext context = new ZipEntryContext(tmpJar.toURL());
assertTrue("context.getRoot().exists()", context.getRoot().exists());
- boolean isDeleted = tmpJar.delete();
+ boolean isDeleted = context.getRoot().delete(1000);
assertTrue("delete tmp file: " + tmpJar, isDeleted);
-
assertFalse("context.getRoot().exists()", context.getRoot().exists());
}