Author: clebert.suconic(a)jboss.com
Date: 2011-11-02 16:13:40 -0400 (Wed, 02 Nov 2011)
New Revision: 11642
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/LargeMessageCompressTest.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
Fixing windows test
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/LargeMessageCompressTest.java
===================================================================
---
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/LargeMessageCompressTest.java 2011-11-02
17:18:31 UTC (rev 11641)
+++
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/LargeMessageCompressTest.java 2011-11-02
20:13:40 UTC (rev 11642)
@@ -159,8 +159,10 @@
msg1.setOutputStream(output);
- msg1.waitOutputStreamCompletion(0);
+ msg1.waitOutputStreamCompletion(0);
+ output.close();
+
msg1.acknowledge();
session.commit();
@@ -176,7 +178,7 @@
byte b = (byte)input.read();
assertEquals("position = " + i, getSamplebyte(i), b);
}
-
+ input.close();
testFile.delete();
validateNoFilesOnLargeDir();
}
@@ -239,6 +241,8 @@
msg1.saveToOutputStream(output);
msg1.acknowledge();
+
+ output.close();
session.commit();
@@ -253,6 +257,7 @@
byte b = (byte)input.read();
assertEquals("position = " + i, getSamplebyte(i), b);
}
+ input.close();
testFile.delete();
validateNoFilesOnLargeDir();
@@ -358,6 +363,7 @@
byte b = (byte)input.read();
assertEquals("position = " + i, msgs[i], b);
}
+ input.close();
testFile.delete();
validateNoFilesOnLargeDir();
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-11-02
17:18:31 UTC (rev 11641)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-11-02
20:13:40 UTC (rev 11642)
@@ -111,8 +111,10 @@
// Attributes ----------------------------------------------------
- private static final String testDir = System.getProperty("java.io.tmpdir",
"/tmp") + File.separator + "hornetq-unit-test";
+ private final String baseDir = System.getProperty("java.io.tmpdir",
"/tmp") + File.separator + "hornetq-unit-test";
+ private final String testDir = baseDir + File.separator + System.currentTimeMillis();
+
// There is a verification about thread leakages. We only fail a single thread when
this happens
private static Set<Thread> alreadyFailedThread = new HashSet<Thread>();
@@ -617,7 +619,7 @@
{
// Need to delete the root
- File file = new File(testDir);
+ File file = new File(baseDir);
deleteDirectory(file);
file.mkdirs();
@@ -627,8 +629,6 @@
recreateDirectory(getLargeMessagesDir(testDir));
recreateDirectory(getClientLargeMessagesDir(testDir));
recreateDirectory(getTemporaryDir(testDir));
-
- System.out.println("deleted " + testDir);
}
/**
@@ -899,7 +899,7 @@
OperationContextImpl.clearContext();
- deleteDirectory(new File(getTestDir()));
+ deleteDirectory(new File(baseDir));
InVMRegistry.instance.clear();
@@ -914,7 +914,10 @@
protected void tearDown() throws Exception
{
cleanupPools();
+
+ deleteDirectory(new File(baseDir));
+
Map<Thread, StackTraceElement[]> threadMap = Thread.getAllStackTraces();
for (Thread thread : threadMap.keySet())
{
@@ -1162,6 +1165,11 @@
protected boolean deleteDirectory(final File directory)
{
+ if (!directory.exists())
+ {
+ return true;
+ }
+ else
if (directory.isDirectory())
{
String[] files = directory.list();
@@ -1175,8 +1183,18 @@
if (!deleteDirectory(fileTmp))
{
// This is because of Windows is dumb on releasing files
- log.warn("Couldn't delete " + fileTmp);
+ log.warn("could not delete " + fileTmp);
forceGC();
+ if (!deleteDirectory(fileTmp))
+ {
+
log.warn("**************************************************************");
+ log.warn("could not delete " + fileTmp + " even afer
a retry on GC");
+
log.warn("**************************************************************");
+ }
+ else
+ {
+ log.info(fileTmp + " was deleted without a problem after a
retry on GC");
+ }
return false;
}
}
Show replies by date