Author: manik.surtani(a)jboss.com
Date: 2007-12-21 11:33:16 -0500 (Fri, 21 Dec 2007)
New Revision: 4913
Removed:
core/trunk/src/test/java/org/jboss/cache/options/OptimisticMemLeakTest.java
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
Log:
Updated mem leak test
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2007-12-21
14:58:06 UTC (rev 4912)
+++
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2007-12-21
16:33:16 UTC (rev 4913)
@@ -328,6 +328,8 @@
*/
public void testMemLeakOnSuspendedTransactions() throws Exception
{
+ Fqn fqn2 = Fqn.fromString("/fqn/two");
+
tm1.begin();
cache1.putForExternalRead(fqn, key, value);
tm1.commit();
@@ -338,6 +340,43 @@
assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1
should have no stale local TXs";
assert cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2
should have no stale global TXs";
assert cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2
should have no stale local TXs";
+
+ tm1.begin();
+ cache1.putForExternalRead(fqn, key, value);
+ cache1.put(fqn2, key, value);
+ tm1.commit();
+
+ asyncWait();
+
+ assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1
should have no stale global TXs";
+ assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1
should have no stale local TXs";
+ assert cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2
should have no stale global TXs";
+ assert cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2
should have no stale local TXs";
+
+ tm1.begin();
+ cache1.put(fqn2, key, value);
+ cache1.putForExternalRead(fqn, key, value);
+ tm1.commit();
+
+ asyncWait();
+
+ assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1
should have no stale global TXs";
+ assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1
should have no stale local TXs";
+ assert cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2
should have no stale global TXs";
+ assert cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2
should have no stale local TXs";
+
+ tm1.begin();
+ cache1.put(fqn2, key, value);
+ cache1.putForExternalRead(fqn, key, value);
+ cache1.put(fqn2, key, value);
+ tm1.commit();
+
+ asyncWait();
+
+ assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1
should have no stale global TXs";
+ assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1
should have no stale local TXs";
+ assert cache2.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 2
should have no stale global TXs";
+ assert cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2
should have no stale local TXs";
}
/**
Deleted: core/trunk/src/test/java/org/jboss/cache/options/OptimisticMemLeakTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/OptimisticMemLeakTest.java 2007-12-21
14:58:06 UTC (rev 4912)
+++ core/trunk/src/test/java/org/jboss/cache/options/OptimisticMemLeakTest.java 2007-12-21
16:33:16 UTC (rev 4913)
@@ -1,90 +0,0 @@
-package org.jboss.cache.options;
-
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.transaction.DummyTransactionManagerLookup;
-import org.jboss.cache.transaction.TransactionTable;
-import org.testng.annotations.Test;
-
-import javax.transaction.TransactionManager;
-
-/**
- * To test memory leak reported in
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112143#...
- *
- * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
- */
-@Test(groups = "functional")
-public class OptimisticMemLeakTest
-{
- private Cache<Object, Object> cache;
- private TransactionManager tm;
- private TransactionTable tt;
- private Fqn fqn = Fqn.fromString("/a/b/c");
- private Fqn fqn1 = Fqn.fromString("/c/d/e");
- private String key = "key", value = "value";
-
- protected void tearDown()
- {
- cache.stop();
- }
-
- protected void setUp() throws Exception
- {
- cache = new DefaultCacheFactory<Object, Object>().createCache(false);
-
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
-
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cache.start();
- tm = ((CacheSPI) cache).getTransactionManager();
- tt = ((CacheSPI) cache).getTransactionTable();
- }
-
- public void testLeakWithFailSilently() throws Exception
- {
- tm.begin();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.put(fqn, key, value);
- tm.commit();
-
- int gtxCnt = tt.getNumGlobalTransactions();
- int txCnt = tt.getNumLocalTransactions();
- assert gtxCnt == 0 : "Global transaction count is > 0";
- assert txCnt == 0 : "Local transaction count is > 0";
-
- tm.begin();
- cache.put(fqn1, key, value);
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.put(fqn, key, value);
- tm.commit();
-
- gtxCnt = tt.getNumGlobalTransactions();
- txCnt = tt.getNumLocalTransactions();
- assert gtxCnt == 0 : "Global transaction count is > 0";
- assert txCnt == 0 : "Local transaction count is > 0";
-
- tm.begin();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.put(fqn, key, value);
- cache.put(fqn1, key, value);
- tm.commit();
-
- gtxCnt = tt.getNumGlobalTransactions();
- txCnt = tt.getNumLocalTransactions();
- assert gtxCnt == 0 : "Global transaction count is > 0";
- assert txCnt == 0 : "Local transaction count is > 0";
-
- tm.begin();
- cache.put(fqn1, key, value);
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.put(fqn, key, value);
- cache.put(fqn1, key, value);
- tm.commit();
-
- gtxCnt = tt.getNumGlobalTransactions();
- txCnt = tt.getNumLocalTransactions();
- assert gtxCnt == 0 : "Global transaction count is > 0";
- assert txCnt == 0 : "Local transaction count is > 0";
- }
-}