[jboss-cvs] JBossAS SVN: r97648 - in trunk/testsuite/src/main/org/jboss/test/cluster: testutil and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 9 18:49:37 EST 2009
Author: bstansberry at jboss.com
Date: 2009-12-09 18:49:37 -0500 (Wed, 09 Dec 2009)
New Revision: 97648
Modified:
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationFailoverUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationToPassivatedSessionUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionNotificationPolicyTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ReplicationToPassivatedSessionUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java
Log:
[JBAS-6961] Properly cleanup temp dirs used for passivation
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationFailoverUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationFailoverUnitTestCase.java 2009-12-09 23:35:02 UTC (rev 97647)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationFailoverUnitTestCase.java 2009-12-09 23:49:37 UTC (rev 97648)
@@ -72,8 +72,6 @@
{
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File root = new File(tmpDir, BuddyReplicationFailoverUnitTestCase.class.getSimpleName());
- root.mkdirs();
- root.deleteOnExit();
return CacheConfigTestSetup.getTestSetup(BuddyReplicationFailoverUnitTestCase.class, pojoCaches, false, root.getAbsolutePath(), false, false);
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationToPassivatedSessionUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationToPassivatedSessionUnitTestCase.java 2009-12-09 23:35:02 UTC (rev 97647)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/BuddyReplicationToPassivatedSessionUnitTestCase.java 2009-12-09 23:49:37 UTC (rev 97648)
@@ -51,8 +51,6 @@
{
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File root = new File(tmpDir, BuddyReplicationToPassivatedSessionUnitTestCase.class.getSimpleName());
- root.mkdirs();
- root.deleteOnExit();
return CacheConfigTestSetup.getTestSetup(BuddyReplicationToPassivatedSessionUnitTestCase.class, pojoCaches, false, root.getAbsolutePath(), false, false);
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionNotificationPolicyTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionNotificationPolicyTestCase.java 2009-12-09 23:35:02 UTC (rev 97647)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ClusteredSessionNotificationPolicyTestCase.java 2009-12-09 23:49:37 UTC (rev 97648)
@@ -87,8 +87,6 @@
{
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File root = new File(tmpDir, ClusteredSessionNotificationPolicyTestCase.class.getSimpleName());
- root.mkdirs();
- root.deleteOnExit();
return CacheConfigTestSetup.getTestSetup(ClusteredSessionNotificationPolicyTestCase.class, pojoCaches, false, root.getAbsolutePath(), !useBuddyRepl, false);
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ReplicationToPassivatedSessionUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ReplicationToPassivatedSessionUnitTestCase.java 2009-12-09 23:35:02 UTC (rev 97647)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/ReplicationToPassivatedSessionUnitTestCase.java 2009-12-09 23:49:37 UTC (rev 97648)
@@ -64,8 +64,6 @@
{
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File root = new File(tmpDir, ReplicationToPassivatedSessionUnitTestCase.class.getSimpleName());
- root.mkdirs();
- root.deleteOnExit();
return CacheConfigTestSetup.getTestSetup(ReplicationToPassivatedSessionUnitTestCase.class, pojoCaches, false, root.getAbsolutePath(), true, false);
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java 2009-12-09 23:35:02 UTC (rev 97647)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/SessionCountUnitTestCase.java 2009-12-09 23:49:37 UTC (rev 97648)
@@ -77,8 +77,6 @@
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File root = new File(tmpDir, getClass().getSimpleName());
- root.mkdirs();
- root.deleteOnExit();
tempDir = root.getAbsolutePath();
}
@@ -90,51 +88,52 @@
super.tearDown();
}
finally
- {
- SessionTestUtil.clearDistributedCacheManagerFactory();
-
- // Restore any system properties we set in setUp
- if (jgroupsSupport != null)
+ {
+ try
{
- jgroupsSupport.restoreProperties();
- }
-
- for (PojoCache cache : caches)
- {
- // Try to clean up so we avoid loading sessions
- // from storage in later tests
- try
+ SessionTestUtil.clearDistributedCacheManagerFactory();
+
+ // Restore any system properties we set in setUp
+ if (jgroupsSupport != null)
{
- log.info("Removing /JSESSION from " + cache.getCache().getLocalAddress());
- cache.getCache().removeNode(Fqn.fromString("/JSESSION"));
+ jgroupsSupport.restoreProperties();
}
- catch (Exception e)
- {
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+
+ for (PojoCache cache : caches)
+ {
+ // Try to clean up so we avoid loading sessions
+ // from storage in later tests
+ try
+ {
+ log.info("Removing /JSESSION from " + cache.getCache().getLocalAddress());
+ cache.getCache().removeNode(Fqn.fromString("/JSESSION"));
+ }
+ catch (Exception e)
+ {
+ log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+ }
+
+ try
+ {
+ cache.stop();
+ cache.destroy();
+ }
+ catch (Exception e)
+ {
+ log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
+ }
+
}
- try
+ caches.clear();
+ }
+ finally
+ {
+ if (tempDir != null)
{
- cache.stop();
- cache.destroy();
+ SessionTestUtil.cleanFilesystem(tempDir);
}
- catch (Exception e)
- {
- log.error("Cache " + cache.getCache().getLocalAddress() + ": " + e.getMessage(), e);
- }
-
}
-
- caches.clear();
-
- if (tempDir != null)
- {
- File dir = new File(tempDir);
- if (dir.exists())
- dir.delete();
- if (dir.exists())
- dir.deleteOnExit();
- }
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java 2009-12-09 23:35:02 UTC (rev 97647)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java 2009-12-09 23:49:37 UTC (rev 97648)
@@ -23,6 +23,8 @@
package org.jboss.test.cluster.testutil;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -52,6 +54,7 @@
private boolean local;
private boolean totalReplication;
private boolean marshalling;
+ private final List<String> cleanupPaths = new ArrayList<String>();
/**
* Create a new CacheConfigTestSetup.
@@ -77,10 +80,30 @@
try
{
jgSupport.setUpProperties();
+
+ if (passivationDir != null)
+ {
+ File base = new File(passivationDir);
+ if (!base.exists())
+ {
+ if (!base.mkdir())
+ {
+ throw new RuntimeException("Cannot create base passivation dir " + passivationDir);
+ }
+ else
+ {
+ cleanupPaths.add(base.getAbsolutePath());
+ }
+ }
+ }
long now = System.currentTimeMillis();
for (int i = 0; i < pojoCaches.length; i++)
- {
+ {
String cacheStore = (passivationDir == null ? null : new File(passivationDir, String.valueOf( now + i)).getAbsolutePath());
+ if (cacheStore != null)
+ {
+ cleanupPaths.add(0, cacheStore);
+ }
pojoCaches[i] = SessionTestUtil.createCache(local, cacheStore, totalReplication, marshalling, null);
}
}
@@ -98,23 +121,33 @@
protected void tearDown() throws Exception
{
- if (pojoCaches != null)
+ try
{
- for (int i = 0; i < pojoCaches.length; i++)
+ if (pojoCaches != null)
{
- try
- {
- PojoCache pc = pojoCaches[i];
- pojoCaches[i] = null;
- pc.stop();
- pc.destroy();
- }
- catch (Exception ex)
+ for (int i = 0; i < pojoCaches.length; i++)
{
- log.error("Failed stopping cache " + i);
- }
- }
+ try
+ {
+ PojoCache pc = pojoCaches[i];
+ pojoCaches[i] = null;
+ pc.stop();
+ pc.destroy();
+ }
+ catch (Exception ex)
+ {
+ log.error("Failed stopping cache " + i);
+ }
+ }
+ }
}
+ finally
+ {
+ for (String path : cleanupPaths)
+ {
+ SessionTestUtil.cleanFilesystem(path);
+ }
+ }
}
}
More information about the jboss-cvs-commits
mailing list