Author: manik.surtani(a)jboss.com
Date: 2007-12-21 09:58:06 -0500 (Fri, 21 Dec 2007)
New Revision: 4912
Added:
core/trunk/src/test/java/org/jboss/cache/options/OptimisticMemLeakTest.java
Modified:
core/trunk/pom.xml
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java
core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsReplTest.java
core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsTest.java
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java
core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java
core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelRepeatableReadTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelSerializableTest.java
Log:
Unit test cleanups
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2007-12-21 06:12:32 UTC (rev 4911)
+++ core/trunk/pom.xml 2007-12-21 14:58:06 UTC (rev 4912)
@@ -73,12 +73,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>beanshell</groupId>
<artifactId>bsh</artifactId>
<version>2.0b4</version>
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -1,6 +1,5 @@
package org.jboss.cache.factories;
-import junit.framework.Assert;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
@@ -207,7 +206,7 @@
List<Interceptor> list = getInterceptorChainFactory(cache).asList(next);
Iterator<Interceptor> interceptors = list.iterator();
- Assert.assertEquals(8, list.size());
+ assertEquals(8, list.size());
assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
assertEquals(TxInterceptor.class, interceptors.next().getClass());
@@ -234,7 +233,7 @@
List<Interceptor> list = getInterceptorChainFactory(cache).asList(next);
Iterator<Interceptor> interceptors = list.iterator();
- Assert.assertEquals(9, list.size());
+ assertEquals(9, list.size());
assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
assertEquals(TxInterceptor.class, interceptors.next().getClass());
@@ -262,7 +261,7 @@
List<Interceptor> list = getInterceptorChainFactory(cache).asList(next);
Iterator<Interceptor> interceptors = list.iterator();
- Assert.assertEquals(10, list.size());
+ assertEquals(10, list.size());
assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
assertEquals(TxInterceptor.class, interceptors.next().getClass());
@@ -291,7 +290,7 @@
List<Interceptor> list = getInterceptorChainFactory(cache).asList(next);
Iterator<Interceptor> interceptors = list.iterator();
- Assert.assertEquals(10, list.size());
+ assertEquals(10, list.size());
assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
assertEquals(TxInterceptor.class, interceptors.next().getClass());
@@ -319,7 +318,7 @@
List<Interceptor> list = getInterceptorChainFactory(cache).asList(chain);
Iterator<Interceptor> interceptors = list.iterator();
- Assert.assertEquals(7, list.size());
+ assertEquals(7, list.size());
assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
assertEquals(TxInterceptor.class, interceptors.next().getClass());
@@ -341,7 +340,7 @@
list = getInterceptorChainFactory(cache).asList(chain);
interceptors = list.iterator();
- Assert.assertEquals(7, list.size());
+ assertEquals(7, list.size());
assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
assertEquals(TxInterceptor.class, interceptors.next().getClass());
Modified:
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.invalidation;
-import junit.framework.Assert;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
@@ -62,8 +61,8 @@
cache1.put(fqn, "key", "value");
// test that this has NOT replicated, but rather has been invalidated:
- Assert.assertEquals("value", cache1.get(fqn, "key"));
- Assert.assertNull("Should NOT have replicated!", cache2.getNode(fqn));
+ assertEquals("value", cache1.get(fqn, "key"));
+ assertNull("Should NOT have replicated!", cache2.getNode(fqn));
log.info("***** Node not replicated, as expected.");
@@ -73,11 +72,11 @@
// since the node already exists even PL will not remove it - but will invalidate
it's data
Node n = cache1.getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value", cache2.get(fqn, "key"));
// now test the invalidation:
cache1.put(fqn, "key2", "value2");
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
n = cache2.getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
}
@@ -122,8 +121,8 @@
cache1.put(fqn, "key", "value");
TestingUtil.sleepThread(500);// give it time to broadcast the evict call
// test that this has NOT replicated, but rather has been invalidated:
- Assert.assertEquals("value", cache1.get(fqn, "key"));
- Assert.assertNull("Should NOT have replicated!", cache2.getNode(fqn));
+ assertEquals("value", cache1.get(fqn, "key"));
+ assertNull("Should NOT have replicated!", cache2.getNode(fqn));
// now make sure cache2 is in sync with cache1:
cache2.put(fqn, "key", "value");
@@ -132,11 +131,11 @@
// since the node already exists even PL will not remove it - but will invalidate
it's data
Node n = cache1.getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value", cache2.get(fqn, "key"));
// now test the invalidation:
cache1.put(fqn, "key2", "value2");
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
TestingUtil.sleepThread(500);// give it time to broadcast the evict call
// since the node already exists even PL will not remove it - but will invalidate
it's data
@@ -154,50 +153,50 @@
cache1.put(fqn, "key", "value");
// test that this has NOT replicated, but rather has been invalidated:
- Assert.assertEquals("value", cache1.get(fqn, "key"));
- Assert.assertNull("Should NOT have replicated!", cache2.getNode(fqn));
+ assertEquals("value", cache1.get(fqn, "key"));
+ assertNull("Should NOT have replicated!", cache2.getNode(fqn));
log.info("***** Node not replicated, as expected.");
// now make sure cache2 is in sync with cache1:
// make sure this is in a tx
TransactionManager txm = cache2.getTransactionManager();
- Assert.assertEquals("value", cache1.get(fqn, "key"));
+ assertEquals("value", cache1.get(fqn, "key"));
txm.begin();
cache2.put(fqn, "key", "value");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value", cache2.get(fqn, "key"));
txm.commit();
// since the node already exists even PL will not remove it - but will invalidate
it's data
Node n = cache1.getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value", cache2.get(fqn, "key"));
// now test the invalidation again
txm = cache1.getTransactionManager();
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value", cache2.get(fqn, "key"));
txm.begin();
cache1.put(fqn, "key2", "value2");
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
txm.commit();
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
// since the node already exists even PL will not remove it - but will invalidate
it's data
n = cache2.getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
// test a rollback
txm = cache2.getTransactionManager();
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
txm.begin();
cache2.put(fqn, "key", "value");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value", cache2.get(fqn, "key"));
txm.rollback();
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
n = cache2.getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
}
@@ -211,7 +210,7 @@
Fqn fqn = Fqn.fromString("/a/b");
cache2.put(fqn, "key", "value");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value", cache2.get(fqn, "key"));
Node n = cache1.getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
assertHasBeenInvalidated(cache1.peek(fqn, true, true), "Should have been
invalidated");
@@ -231,22 +230,22 @@
try
{
mgr1.commit();
- Assert.assertTrue("Ought to have succeeded!", true);
+ assertTrue("Ought to have succeeded!", true);
}
catch (RollbackException roll)
{
- Assert.assertTrue("Ought to have succeeded!", false);
+ assertTrue("Ought to have succeeded!", false);
}
mgr2.resume(tx2);
try
{
mgr2.commit();
- Assert.assertTrue("Ought to have failed!", false);
+ assertTrue("Ought to have failed!", false);
}
catch (RollbackException roll)
{
- Assert.assertTrue("Ought to have failed!", true);
+ assertTrue("Ought to have failed!", true);
}
}
@@ -258,8 +257,8 @@
Fqn fqn = Fqn.fromString("/a/b");
cache1.put("/a/b", "key", "value");
- Assert.assertEquals("value", cache1.get(fqn, "key"));
- Assert.assertNull(cache2.getNode(fqn));
+ assertEquals("value", cache1.get(fqn, "key"));
+ assertNull(cache2.getNode(fqn));
// start a tx that cacahe1 will have to send out an evict ...
TransactionManager mgr1 = cache1.getTransactionManager();
@@ -276,22 +275,22 @@
try
{
mgr1.commit();
- Assert.assertTrue("Ought to have failed!", false);
+ assertTrue("Ought to have failed!", false);
}
catch (RollbackException roll)
{
- Assert.assertTrue("Ought to have failed!", true);
+ assertTrue("Ought to have failed!", true);
}
mgr2.resume(tx2);
try
{
mgr2.commit();
- Assert.assertTrue("Ought to have succeeded!", true);
+ assertTrue("Ought to have succeeded!", true);
}
catch (RollbackException roll)
{
- Assert.assertTrue("Ought to have succeeded!", false);
+ assertTrue("Ought to have succeeded!", false);
}
}
@@ -307,8 +306,8 @@
Fqn fqn = Fqn.fromString("/a/b");
cache1.put("/a/b", "key", "value");
- Assert.assertEquals("value", cache1.get(fqn, "key"));
- Assert.assertNull(cache2.getNode(fqn));
+ assertEquals("value", cache1.get(fqn, "key"));
+ assertNull(cache2.getNode(fqn));
// start a tx that cacahe1 will have to send out an evict ...
TransactionManager mgr1 = cache1.getTransactionManager();
@@ -325,22 +324,22 @@
try
{
mgr1.commit();
- Assert.assertTrue("Ought to have succeeded!", true);
+ assertTrue("Ought to have succeeded!", true);
}
catch (RollbackException roll)
{
- Assert.assertTrue("Ought to have succeeded!", false);
+ assertTrue("Ought to have succeeded!", false);
}
mgr2.resume(tx2);
try
{
mgr2.commit();
- Assert.assertTrue("Ought to have succeeded!", true);
+ assertTrue("Ought to have succeeded!", true);
}
catch (RollbackException roll)
{
- Assert.assertTrue("Ought to have succeeded!", false);
+ assertTrue("Ought to have succeeded!", false);
}
}
@@ -482,7 +481,7 @@
dumpVersionInfo(cache1, cache2, fqn);
// test that this has NOT replicated, but rather has been invalidated:
- Assert.assertEquals("value", cache1.get(fqn, "key"));
+ assertEquals("value", cache1.get(fqn, "key"));
Node n2 = cache2.getNode(fqn);
assertHasBeenInvalidated(n2, "Should have been invalidated");
assertHasBeenInvalidated(cache2.peek(fqn, true, true), "Should have been
invalidated");
@@ -496,14 +495,14 @@
assertHasBeenInvalidated(n1, "Should have been invalidated");
assertHasBeenInvalidated(cache1.peek(fqn, true, true), "Should have been
invalidated");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value", cache2.get(fqn, "key"));
// now test the invalidation:
cache1.put(fqn, "key2", "value2");
dumpVersionInfo(cache1, cache2, fqn);
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
n2 = cache2.getNode(fqn);
assertHasBeenInvalidated(n2, "Should have been invalidated");
assertHasBeenInvalidated(cache2.peek(fqn, false, false), "Should have been
invalidated");
@@ -513,25 +512,25 @@
txm.begin();
cache2.put(fqn, "key", "value");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
txm.commit();
n1 = cache1.getNode(fqn);
assertHasBeenInvalidated(n1, "Should have been invalidated");
assertHasBeenInvalidated(cache1.peek(fqn, false, false), "Should have been
invalidated");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value", cache2.get(fqn, "key"));
// now test the invalidation again
txm = cache1.getTransactionManager();
txm.begin();
cache1.put(fqn, "key2", "value2");
- Assert.assertEquals("value", cache2.get(fqn, "key"));
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
txm.commit();
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
n2 = cache2.getNode(fqn);
assertHasBeenInvalidated(n2, "Should have been invalidated");
assertHasBeenInvalidated(cache2.peek(fqn, false, false), "Should have been
invalidated");
@@ -541,11 +540,11 @@
txm.begin();
cache2.put(fqn, "key", "value");
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
- Assert.assertEquals("value", cache2.get(fqn, "key"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value", cache2.get(fqn, "key"));
txm.rollback();
- Assert.assertEquals("value2", cache1.get(fqn, "key2"));
+ assertEquals("value2", cache1.get(fqn, "key2"));
n2 = cache2.getNode(fqn);
assertHasBeenInvalidated(n2, "Should have been invalidated");
assertHasBeenInvalidated(cache2.peek(fqn, false, false), "Should have been
invalidated");
@@ -560,20 +559,20 @@
Fqn fqn = Fqn.fromString("/a/b");
caches.get(0).put(fqn, "key", "value");
- Assert.assertEquals("value", caches.get(0).get(fqn, "key"));
- Assert.assertEquals("value", caches.get(1).get(fqn, "key"));
+ assertEquals("value", caches.get(0).get(fqn, "key"));
+ assertEquals("value", caches.get(1).get(fqn, "key"));
// now make sure cache2 is in sync with cache1:
caches.get(1).put(fqn, "key", "value");
- Assert.assertEquals("value", caches.get(1).get(fqn, "key"));
- Assert.assertEquals("value", caches.get(0).get(fqn, "key"));
+ assertEquals("value", caches.get(1).get(fqn, "key"));
+ assertEquals("value", caches.get(0).get(fqn, "key"));
// now test the invalidation:
caches.get(0).put(fqn, "key2", "value2");
- Assert.assertEquals("value2", caches.get(0).get(fqn, "key2"));
- Assert.assertEquals("value2", caches.get(1).get(fqn, "key2"));
- Assert.assertEquals("value", caches.get(0).get(fqn, "key"));
- Assert.assertEquals("value", caches.get(1).get(fqn, "key"));
+ assertEquals("value2", caches.get(0).get(fqn, "key2"));
+ assertEquals("value2", caches.get(1).get(fqn, "key2"));
+ assertEquals("value", caches.get(0).get(fqn, "key"));
+ assertEquals("value", caches.get(1).get(fqn, "key"));
}
public void testPessimisticTransactionalWithCacheLoader() throws Exception
@@ -584,23 +583,23 @@
Fqn fqn = Fqn.fromString("/a/b");
TransactionManager mgr = caches.get(0).getTransactionManager();
- Assert.assertNull("Should be null", caches.get(0).get(fqn,
"key"));
- Assert.assertNull("Should be null", caches.get(1).get(fqn,
"key"));
+ assertNull("Should be null", caches.get(0).get(fqn, "key"));
+ assertNull("Should be null", caches.get(1).get(fqn, "key"));
mgr.begin();
caches.get(0).put(fqn, "key", "value");
- Assert.assertEquals("value", caches.get(0).get(fqn, "key"));
+ assertEquals("value", caches.get(0).get(fqn, "key"));
mgr.commit();
- Assert.assertEquals("value", caches.get(1).get(fqn, "key"));
- Assert.assertEquals("value", caches.get(0).get(fqn, "key"));
+ assertEquals("value", caches.get(1).get(fqn, "key"));
+ assertEquals("value", caches.get(0).get(fqn, "key"));
mgr.begin();
caches.get(0).put(fqn, "key2", "value2");
- Assert.assertEquals("value2", caches.get(0).get(fqn, "key2"));
+ assertEquals("value2", caches.get(0).get(fqn, "key2"));
mgr.rollback();
- Assert.assertEquals("value", caches.get(1).get(fqn, "key"));
- Assert.assertEquals("value", caches.get(0).get(fqn, "key"));
- Assert.assertNull("Should be null", caches.get(0).get(fqn,
"key2"));
- Assert.assertNull("Should be null", caches.get(1).get(fqn,
"key2"));
+ assertEquals("value", caches.get(1).get(fqn, "key"));
+ assertEquals("value", caches.get(0).get(fqn, "key"));
+ assertNull("Should be null", caches.get(0).get(fqn, "key2"));
+ assertNull("Should be null", caches.get(1).get(fqn, "key2"));
}
public void testOptimisticWithCacheLoader() throws Exception
@@ -611,25 +610,25 @@
Fqn fqn = Fqn.fromString("/a/b");
TransactionManager mgr = caches.get(0).getTransactionManager();
- Assert.assertNull("Should be null", caches.get(0).get(fqn,
"key"));
- Assert.assertNull("Should be null", caches.get(1).get(fqn,
"key"));
+ assertNull("Should be null", caches.get(0).get(fqn, "key"));
+ assertNull("Should be null", caches.get(1).get(fqn, "key"));
mgr.begin();
caches.get(0).put(fqn, "key", "value");
- Assert.assertEquals("value", caches.get(0).get(fqn, "key"));
- Assert.assertNull("Should be null", caches.get(1).get(fqn,
"key"));
+ assertEquals("value", caches.get(0).get(fqn, "key"));
+ assertNull("Should be null", caches.get(1).get(fqn, "key"));
mgr.commit();
- Assert.assertEquals("value", caches.get(1).get(fqn, "key"));
- Assert.assertEquals("value", caches.get(0).get(fqn, "key"));
+ assertEquals("value", caches.get(1).get(fqn, "key"));
+ assertEquals("value", caches.get(0).get(fqn, "key"));
mgr.begin();
caches.get(0).put(fqn, "key2", "value2");
- Assert.assertEquals("value2", caches.get(0).get(fqn, "key2"));
- Assert.assertNull("Should be null", caches.get(1).get(fqn,
"key2"));
+ assertEquals("value2", caches.get(0).get(fqn, "key2"));
+ assertNull("Should be null", caches.get(1).get(fqn, "key2"));
mgr.rollback();
- Assert.assertEquals("value", caches.get(1).get(fqn, "key"));
- Assert.assertEquals("value", caches.get(0).get(fqn, "key"));
- Assert.assertNull("Should be null", caches.get(0).get(fqn,
"key2"));
- Assert.assertNull("Should be null", caches.get(1).get(fqn,
"key2"));
+ assertEquals("value", caches.get(1).get(fqn, "key"));
+ assertEquals("value", caches.get(0).get(fqn, "key"));
+ assertNull("Should be null", caches.get(0).get(fqn, "key2"));
+ assertNull("Should be null", caches.get(1).get(fqn, "key2"));
}
public void testInvalidationWithRegionBasedMarshalling() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java 2007-12-21 06:12:32
UTC (rev 4911)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java 2007-12-21 14:58:06
UTC (rev 4912)
@@ -1,6 +1,5 @@
package org.jboss.cache.jmx;
-import junit.framework.AssertionFailedError;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
@@ -349,7 +348,7 @@
private class MyListener implements NotificationListener
{
private RuntimeException exception;
- private AssertionFailedError failure;
+ private AssertionError failure;
private final String emitterObjectName;
MyListener(ObjectName emitter)
@@ -472,7 +471,7 @@
// Store so the test can rethrow
exception = e;
}
- catch (AssertionFailedError e)
+ catch (AssertionError e)
{
// Store so the test can rethrow
failure = e;
Modified: core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/loader/AsyncFileCacheLoaderTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -1,6 +1,5 @@
package org.jboss.cache.loader;
-import junit.framework.Assert;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
@@ -63,11 +62,11 @@
try
{
loader.remove(Fqn.fromString("/blah"));
- Assert.assertTrue("Should have restricted this entry from being made",
false);
+ assertTrue("Should have restricted this entry from being made",
false);
}
catch (CacheException e)
{
- Assert.assertTrue(true);
+ assertTrue(true);
}
// clean up
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,13 +6,14 @@
*/
package org.jboss.cache.loader;
-import junit.framework.Assert;
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.misc.TestingUtil;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -146,10 +147,10 @@
loader2 = ((CacheSPI<Object, Object>)
cache2).getCacheLoaderManager().getCacheLoader();
// make sure everything is empty...
- Assert.assertNull(loader1.get(fqn));
- Assert.assertNull(loader2.get(fqn));
- Assert.assertNull(cache1.getRoot().getChild(fqn));
- Assert.assertNull(cache2.getRoot().getChild(fqn));
+ assertNull(loader1.get(fqn));
+ assertNull(loader2.get(fqn));
+ assertNull(cache1.getRoot().getChild(fqn));
+ assertNull(cache2.getRoot().getChild(fqn));
mgr1 = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
mgr2 = cache2.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -162,31 +163,31 @@
mgr1.begin();
cache1.put(fqn, key, "value");
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertNull(cache2.get(fqn, key));
- Assert.assertNull(loader1.get(fqn));
- Assert.assertNull(loader2.get(fqn));
+ assertEquals("value", cache1.get(fqn, key));
+ assertNull(cache2.get(fqn, key));
+ assertNull(loader1.get(fqn));
+ assertNull(loader2.get(fqn));
mgr1.commit();
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
mgr1.begin();
cache1.put(fqn, key, "value2");
- Assert.assertEquals("value2", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value2", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
mgr1.rollback();
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
}
@@ -197,35 +198,35 @@
mgr1.begin();
cache1.put(fqn, key, "value");
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertNull(cache2.get(fqn, key));
- Assert.assertNull(loader1.get(fqn));
- Assert.assertNull(loader2.get(fqn));
+ assertEquals("value", cache1.get(fqn, key));
+ assertNull(cache2.get(fqn, key));
+ assertNull(loader1.get(fqn));
+ assertNull(loader2.get(fqn));
mgr1.commit();
TestingUtil.sleepThread(500);
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
mgr1.begin();
cache1.put(fqn, key, "value2");
- Assert.assertEquals("value2", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value2", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
mgr1.rollback();
TestingUtil.sleepThread(500);
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
}
public void testOptSyncRepl() throws Exception
@@ -234,31 +235,31 @@
mgr1.begin();
cache1.put(fqn, key, "value");
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertNull(cache2.get(fqn, key));
- Assert.assertNull(loader1.get(fqn));
- Assert.assertNull(loader2.get(fqn));
+ assertEquals("value", cache1.get(fqn, key));
+ assertNull(cache2.get(fqn, key));
+ assertNull(loader1.get(fqn));
+ assertNull(loader2.get(fqn));
mgr1.commit();
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
mgr1.begin();
cache1.put(fqn, key, "value2");
- Assert.assertEquals("value2", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value2", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
mgr1.rollback();
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
}
public void testOptAsyncRepl() throws Exception
@@ -268,34 +269,34 @@
mgr1.begin();
cache1.put(fqn, key, "value");
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertNull(cache2.get(fqn, key));
- Assert.assertNull(loader1.get(fqn));
- Assert.assertNull(loader2.get(fqn));
+ assertEquals("value", cache1.get(fqn, key));
+ assertNull(cache2.get(fqn, key));
+ assertNull(loader1.get(fqn));
+ assertNull(loader2.get(fqn));
mgr1.commit();
TestingUtil.sleepThread(500);
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
mgr1.begin();
cache1.put(fqn, key, "value2");
- Assert.assertEquals("value2", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value2", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
mgr1.rollback();
TestingUtil.sleepThread(500);
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
}
}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.loader;
-import junit.framework.Assert;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
@@ -16,6 +15,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.misc.TestingUtil;
+import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -103,19 +103,19 @@
log.info("Finished put");
// test that this has propagated.
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertEquals("value", loader2.get(fqn).get(key));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertEquals("value", loader2.get(fqn).get(key));
cache1.evict(fqn);
// now cache 1 should not have this but cache 2 should.
// loader1 looks at cache2 while loader2 looks at cache1
- Assert.assertEquals("value", loader1.get(fqn).get(key));
- Assert.assertNull("Expecting null", loader2.get(fqn));
+ assertEquals("value", loader1.get(fqn).get(key));
+ assertNull("Expecting null", loader2.get(fqn));
// // calling a get on cache1 should cause the loader to retrieve the node
from cache2
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
// // and now loader2 should see it
- // Assert.assertEquals("value", loader2.get(fqn).get(key));
+ // assertEquals("value", loader2.get(fqn).get(key));
}
public void testGet() throws Exception
@@ -124,35 +124,35 @@
// test that this has propagated.
Map map = loader1.get(fqn);
- Assert.assertTrue("Should contain key", map.containsKey(key));
- Assert.assertEquals("value", map.get(key));
- Assert.assertEquals(1, map.size());
+ assertTrue("Should contain key", map.containsKey(key));
+ assertEquals("value", map.get(key));
+ assertEquals(1, map.size());
map = loader2.get(fqn);
- Assert.assertTrue("Should contain key", map.containsKey(key));
- Assert.assertEquals("value", map.get(key));
- Assert.assertEquals(1, map.size());
+ assertTrue("Should contain key", map.containsKey(key));
+ assertEquals("value", map.get(key));
+ assertEquals(1, map.size());
cache1.evict(fqn);
// now cache 1 should not have this but cache 2 should.
// loader1 looks at cache2 while loader2 looks at cache1
map = loader1.get(fqn);
- Assert.assertTrue(map.containsKey(key));
- Assert.assertEquals("value", map.get(key));
- Assert.assertEquals(1, map.size());
+ assertTrue(map.containsKey(key));
+ assertEquals("value", map.get(key));
+ assertEquals(1, map.size());
- Assert.assertNull("Expecting null", loader2.get(fqn));
+ assertNull("Expecting null", loader2.get(fqn));
map = loader2.get(fqn);
- Assert.assertNull("Should be null", map);
+ assertNull("Should be null", map);
// calling a get on cache1 should cause the loader to retrieve the node from
cache2
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
// and now loader2 should see it
map = loader2.get(fqn);
- Assert.assertTrue(map.containsKey(key));
- Assert.assertEquals("value", map.get(key));
- Assert.assertEquals(1, map.size());
+ assertTrue(map.containsKey(key));
+ assertEquals("value", map.get(key));
+ assertEquals(1, map.size());
}
public void testGetChildrenNames() throws Exception
@@ -167,9 +167,9 @@
// test that this has propagated.
Set childNames = loader1.getChildrenNames(fqn);
- Assert.assertEquals(3, childNames.size());
+ assertEquals(3, childNames.size());
childNames = loader2.getChildrenNames(fqn);
- Assert.assertEquals(3, childNames.size());
+ assertEquals(3, childNames.size());
cache1.evict(child1);
cache1.evict(child2);
@@ -179,19 +179,19 @@
// now cache 1 should not have this but cache 2 should.
// loader1 looks at cache2 while loader2 looks at cache1
childNames = loader1.getChildrenNames(fqn);
- Assert.assertEquals(3, childNames.size());
+ assertEquals(3, childNames.size());
childNames = loader2.getChildrenNames(fqn);
- Assert.assertNull("should be null", childNames);
+ assertNull("should be null", childNames);
// calling a get on cache1 should cause the loader to retrieve the node from
cache2
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
// load up children
- Assert.assertEquals("value", cache1.get(child1, key));
- Assert.assertEquals("value", cache1.get(child2, key));
- Assert.assertEquals("value", cache1.get(child3, key));
+ assertEquals("value", cache1.get(child1, key));
+ assertEquals("value", cache1.get(child2, key));
+ assertEquals("value", cache1.get(child3, key));
// and now loader2 should see it
childNames = loader2.getChildrenNames(fqn);
- Assert.assertEquals(3, childNames.size());
+ assertEquals(3, childNames.size());
}
public void testExists() throws Exception
@@ -199,19 +199,19 @@
cache1.put(fqn, key, "value");
// test that this has propagated.
- Assert.assertTrue("should exist", loader1.exists(fqn));
- Assert.assertTrue("should exist", loader2.exists(fqn));
+ assertTrue("should exist", loader1.exists(fqn));
+ assertTrue("should exist", loader2.exists(fqn));
cache1.evict(fqn);
// now cache 1 should not have this but cache 2 should.
// loader1 looks at cache2 while loader2 looks at cache1
- Assert.assertTrue("should exist", loader1.exists(fqn));
- Assert.assertTrue("should not exist", !loader2.exists(fqn));
+ assertTrue("should exist", loader1.exists(fqn));
+ assertTrue("should not exist", !loader2.exists(fqn));
// calling a get on cache1 should cause the loader to retrieve the node from
cache2
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
// and now loader2 should see it
- Assert.assertTrue("should exist", loader2.exists(fqn));
+ assertTrue("should exist", loader2.exists(fqn));
}
public void testCacheLoaderThreadSafety() throws Exception
Modified:
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -1,6 +1,5 @@
package org.jboss.cache.notifications;
-import junit.framework.Assert;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
@@ -12,6 +11,8 @@
import org.jboss.cache.notifications.annotation.*;
import org.jboss.cache.notifications.event.Event;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import static org.testng.AssertJUnit.assertNotSame;
+import static org.testng.AssertJUnit.assertSame;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -209,8 +210,8 @@
try
{
if (sameThreadExpected)
- Assert.assertSame(mainThread, Thread.currentThread());
- else Assert.assertNotSame(mainThread, Thread.currentThread());
+ assertSame(mainThread, Thread.currentThread());
+ else assertNotSame(mainThread, Thread.currentThread());
}
catch (Throwable t)
{
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -1,7 +1,5 @@
package org.jboss.cache.optimistic;
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
@@ -665,23 +663,23 @@
Transaction tx;
TransactionManager mgr =
cache.getConfiguration().getRuntimeConfig().getTransactionManager();
- Assert.assertNull(cache.getNode(fqn));
+ assertNull(cache.getNode(fqn));
mgr.begin();
cache.put(fqn, key, value);
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
tx = mgr.getTransaction();
mgr.suspend();
mgr.begin();
- Assert.assertNull(cache.get(fqn, key));
+ assertNull(cache.get(fqn, key));
mgr.commit();
mgr.resume(tx);
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
mgr.commit();
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
}
@@ -691,26 +689,26 @@
Transaction tx;
TransactionManager mgr =
cache.getConfiguration().getRuntimeConfig().getTransactionManager();
- Assert.assertNull(cache.getNode(fqn));
+ assertNull(cache.getNode(fqn));
cache.put(fqn, key, value);
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
mgr.begin();
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
cache.removeNode(fqn);
- Assert.assertNull(cache.getNode(fqn));
+ assertNull(cache.getNode(fqn));
tx = mgr.getTransaction();
mgr.suspend();
mgr.begin();
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
mgr.commit();
mgr.resume(tx);
- Assert.assertNull(cache.getNode(fqn));
+ assertNull(cache.getNode(fqn));
mgr.commit();
- Assert.assertNull(cache.getNode(fqn));
+ assertNull(cache.getNode(fqn));
}
@@ -720,25 +718,25 @@
Transaction tx;
TransactionManager mgr =
cache.getConfiguration().getRuntimeConfig().getTransactionManager();
- Assert.assertNull(cache.getNode(fqn));
+ assertNull(cache.getNode(fqn));
cache.put(fqn, key, value);
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
mgr.begin();
cache.removeNode(fqn);
- Assert.assertNull(cache.getNode(fqn));
+ assertNull(cache.getNode(fqn));
tx = mgr.getTransaction();
mgr.suspend();
mgr.begin();
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
mgr.commit();
mgr.resume(tx);
- Assert.assertNull(cache.getNode(fqn));
+ assertNull(cache.getNode(fqn));
mgr.commit();
- Assert.assertNull(cache.getNode(fqn));
+ assertNull(cache.getNode(fqn));
}
public void testLoopedPutAndGet() throws Exception
@@ -774,7 +772,7 @@
catch (Exception e)
{
log.debug("Error: ", e);
- Assert.assertFalse("Threw exception!", true);
+ assertFalse("Threw exception!", true);
throw e;
}
}
@@ -815,27 +813,4 @@
destroyCache(cache1);
destroyCache(cache2);
}
-
- private void rollback(TransactionManager tm)
- {
- try
- {
- tm.rollback();
- }
- catch (Exception e)
- {
- log.error(e.getMessage(), e);
- }
-
- }
-
- private class ExceptionHolder
- {
- Exception node1Exception;
- Exception node2Exception;
-
- AssertionFailedError node1Failure;
- AssertionFailedError node2Failure;
- }
-
}
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -1,6 +1,5 @@
package org.jboss.cache.optimistic;
-import junit.framework.Assert;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
@@ -11,6 +10,7 @@
import static org.jboss.cache.lock.NodeLock.LockType.READ;
import static org.jboss.cache.lock.NodeLock.LockType.WRITE;
import org.jboss.cache.misc.TestingUtil;
+import org.testng.AssertJUnit;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -201,7 +201,7 @@
void assertReceivedExpectedLocks()
{
- Assert.assertEquals(expected, actual);
+ AssertJUnit.assertEquals(expected, actual);
}
void expectsReadLock(Fqn f)
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,11 +6,12 @@
*/
package org.jboss.cache.optimistic;
-import junit.framework.Assert;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -55,9 +56,9 @@
DataVersion v1 = ((NodeSPI) cache1.getNode(fqn)).getVersion();
DataVersion v2 = ((NodeSPI) cache2.getNode(fqn)).getVersion();
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("Version info should have propagated", v1, v2);
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("Version info should have propagated", v1, v2);
// change stuff in the node again...
cache1.put(fqn, key, "value2");
@@ -65,9 +66,9 @@
v1 = ((NodeSPI) cache1.getNode(fqn)).getVersion();
v2 = ((NodeSPI) cache2.getNode(fqn)).getVersion();
- Assert.assertEquals("value2", cache1.get(fqn, key));
- Assert.assertEquals("value2", cache2.get(fqn, key));
- Assert.assertEquals("Version info should have propagated", v1, v2);
+ assertEquals("value2", cache1.get(fqn, key));
+ assertEquals("value2", cache2.get(fqn, key));
+ assertEquals("Version info should have propagated", v1, v2);
}
public void testTwoCachesUpdatingSimultaneously() throws Exception
@@ -84,9 +85,9 @@
DataVersion v1 = ((NodeSPI) cache1.getNode(fqn)).getVersion();
DataVersion v2 = ((NodeSPI) cache2.getNode(fqn)).getVersion();
- Assert.assertEquals("value", cache1.get(fqn, key));
- Assert.assertEquals("value", cache2.get(fqn, key));
- Assert.assertEquals("Version info should have propagated", v1, v2);
+ assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
+ assertEquals("Version info should have propagated", v1, v2);
// Start a tx on cache 1
mgr1.begin();
@@ -107,17 +108,17 @@
{
mgr2.resume(tx2);
mgr2.commit();
- Assert.assertTrue("Should have failed", false);
+ assertTrue("Should have failed", false);
}
catch (RollbackException rbe)
{
- Assert.assertTrue("Should have failed", true);
+ assertTrue("Should have failed", true);
}
// data versions should be in sync.
v1 = ((NodeSPI) cache1.getNode(fqn)).getVersion();
v2 = ((NodeSPI) cache2.getNode(fqn)).getVersion();
- Assert.assertEquals("Version info should have propagated", v1, v2);
+ assertEquals("Version info should have propagated", v1, v2);
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithCacheLoaderTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithCacheLoaderTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,12 +6,10 @@
*/
package org.jboss.cache.optimistic;
-import junit.framework.Assert;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.transaction.DummyTransactionManager;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.*;
import javax.transaction.Transaction;
@@ -30,12 +28,12 @@
// test the cache loader independently first ...
loader.remove(fqn);
- Assert.assertNull(loader.get(fqn));
+ assert loader.get(fqn) == null;
loader.put(fqn, key, value);
- Assert.assertEquals(value, loader.get(fqn).get(key));
+ assertEquals(value, loader.get(fqn).get(key));
// clean up
loader.remove(fqn);
- Assert.assertNull(loader.get(fqn));
+ assertNull(loader.get(fqn));
}
public void testCacheLoadOnTree() throws Exception
@@ -90,19 +88,19 @@
cache.put(fqn, key, value);
mgr.commit();
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
//now lets see if the state has been persisted in the cache loader
- Assert.assertEquals(value, loader.get(fqn).get(key));
+ assertEquals(value, loader.get(fqn).get(key));
mgr.begin();
cache.removeNode(fqn);
mgr.commit();
- Assert.assertNull(cache.get(fqn, key));
+ assertNull(cache.get(fqn, key));
//now lets see if the state has been persisted in the cache loader
- Assert.assertNull(loader.get(fqn));
+ assertNull(loader.get(fqn));
mgr.begin();
cache.put(fqn, key, value);
@@ -110,15 +108,15 @@
mgr.suspend();
// lets see what we've got halfway within a tx
- Assert.assertNull(cache.get(fqn, key));
- Assert.assertNull(loader.get(fqn));
+ assertNull(cache.get(fqn, key));
+ assertNull(loader.get(fqn));
mgr.resume(tx);
mgr.commit();
// and after committing...
- Assert.assertEquals(value, cache.get(fqn, key));
- Assert.assertEquals(value, loader.get(fqn).get(key));
+ assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, loader.get(fqn).get(key));
// clean up loader
loader.remove(fqn);
@@ -129,20 +127,20 @@
CacheSPI<Object, Object> cache = createCacheWithLoader();
CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
- Assert.assertNull(cache.get(fqn, key));
+ assertNull(cache.get(fqn, key));
// put something in the loader
loader.put(fqn, key, value);
- Assert.assertEquals(value, loader.get(fqn).get(key));
+ assertEquals(value, loader.get(fqn).get(key));
// test that this can now be accessed by the cache
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
// clean up loader
loader.remove(fqn);
// what's in the cache now? Should not ne null...
- Assert.assertNotNull(cache.get(fqn, key));
+ assertNotNull(cache.get(fqn, key));
}
public void testCacheLoadingWithReplication() throws Exception
@@ -161,39 +159,39 @@
// add something in cache1
cache1.put(fqn, key, value);
- Assert.assertEquals(value, cache1.get(fqn, key));
+ assertEquals(value, cache1.get(fqn, key));
// test that loader1, loader2, cache2 doesnt have entry
- Assert.assertNull(loader1.get(fqn));
- Assert.assertNull(loader2.get(fqn));
- Assert.assertNull(cache2.get(fqn, key));
+ assertNull(loader1.get(fqn));
+ assertNull(loader2.get(fqn));
+ assertNull(cache2.get(fqn, key));
// commit
mgr.commit();
// test that loader1, loader2, cache2 has entry
- Assert.assertEquals(value, cache1.get(fqn, key));
- Assert.assertEquals(value, loader1.get(fqn).get(key));
- Assert.assertEquals(value, loader2.get(fqn).get(key));
- Assert.assertEquals(value, cache2.get(fqn, key));
+ assertEquals(value, cache1.get(fqn, key));
+ assertEquals(value, loader1.get(fqn).get(key));
+ assertEquals(value, loader2.get(fqn).get(key));
+ assertEquals(value, cache2.get(fqn, key));
// cache2 removes entry
mgr.begin();
cache2.removeNode(fqn);
- Assert.assertNull(cache2.get(fqn, key));
+ assertNull(cache2.get(fqn, key));
// test that loader1, loader2 and cache2 have the entry
- Assert.assertEquals(value, cache1.get(fqn, key));
- Assert.assertEquals(value, loader1.get(fqn).get(key));
- Assert.assertEquals(value, loader2.get(fqn).get(key));
+ assertEquals(value, cache1.get(fqn, key));
+ assertEquals(value, loader1.get(fqn).get(key));
+ assertEquals(value, loader2.get(fqn).get(key));
// commit
mgr.commit();
// test that the entry has been removed everywhere.
- Assert.assertNull(cache1.getNode(fqn));
- Assert.assertNull(loader1.get(fqn));
- Assert.assertNull(loader2.get(fqn));
- Assert.assertNull(cache2.getNode(fqn));
+ assertNull(cache1.getNode(fqn));
+ assertNull(loader1.get(fqn));
+ assertNull(loader2.get(fqn));
+ assertNull(cache2.getNode(fqn));
}
@@ -213,40 +211,40 @@
// add something in cache1
cache1.put(fqn, key, value);
- Assert.assertEquals(value, cache1.get(fqn, key));
+ assertEquals(value, cache1.get(fqn, key));
// test that loader1, loader2, cache2 doesnt have entry
System.out.println("*** " + loader1.get(fqn));
- Assert.assertNull(loader1.get(fqn));
- Assert.assertNull(loader2.get(fqn));
- Assert.assertNull(cache2.get(fqn, key));
+ assertNull(loader1.get(fqn));
+ assertNull(loader2.get(fqn));
+ assertNull(cache2.get(fqn, key));
// commit
mgr.commit();
// test that loader1, loader2, cache2 has entry
- Assert.assertEquals(value, cache1.get(fqn, key));
- Assert.assertEquals(value, loader1.get(fqn).get(key));
- Assert.assertEquals(value, loader2.get(fqn).get(key));
- Assert.assertEquals(value, cache2.get(fqn, key));
+ assertEquals(value, cache1.get(fqn, key));
+ assertEquals(value, loader1.get(fqn).get(key));
+ assertEquals(value, loader2.get(fqn).get(key));
+ assertEquals(value, cache2.get(fqn, key));
// cache2 removes entry
mgr.begin();
cache2.removeNode(fqn);
- Assert.assertNull(cache2.get(fqn, key));
+ assertNull(cache2.get(fqn, key));
// test that loader1, loader2 and cache2 have the entry
- Assert.assertEquals(value, cache1.get(fqn, key));
- Assert.assertEquals(value, loader1.get(fqn).get(key));
- Assert.assertEquals(value, loader2.get(fqn).get(key));
+ assertEquals(value, cache1.get(fqn, key));
+ assertEquals(value, loader1.get(fqn).get(key));
+ assertEquals(value, loader2.get(fqn).get(key));
// commit
mgr.commit();
// test that the entry has been removed everywhere.
- Assert.assertNull(cache1.getNode(fqn));
- Assert.assertNull(loader1.get(fqn));
- Assert.assertNull(loader2.get(fqn));
- Assert.assertNull(cache2.getNode(fqn));
+ assertNull(cache1.getNode(fqn));
+ assertNull(loader1.get(fqn));
+ assertNull(loader2.get(fqn));
+ assertNull(cache2.getNode(fqn));
}
}
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,13 +6,14 @@
*/
package org.jboss.cache.optimistic;
-import junit.framework.Assert;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.xml.XmlHelper;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
import org.w3c.dom.Element;
/**
@@ -60,7 +61,7 @@
cache.removeNode(fqn);
loader.remove(fqn);
- Assert.assertNull(loader.get(fqn));
+ assertNull(loader.get(fqn));
DummyTransactionManager mgr = DummyTransactionManager.getInstance();
@@ -70,8 +71,8 @@
mgr.commit();
// should be nothing in the loader
- Assert.assertEquals(value, cache.get(fqn, key));
- Assert.assertNull(loader.get(fqn));
+ assertEquals(value, cache.get(fqn, key));
+ assertNull(loader.get(fqn));
// evict from cache
mgr.begin();
@@ -81,14 +82,14 @@
mgr.begin();
// should now be passivated in the loader
// don't do a cache.get() first as this will activate this node from the loader
again!
- // Assert.assertNull( cache.get( fqn ) );
- Assert.assertEquals(value, loader.get(fqn).get(key));
+ // assertNull( cache.get( fqn ) );
+ assertEquals(value, loader.get(fqn).get(key));
// now do a cache.get()...
- Assert.assertEquals(value, cache.get(fqn, key));
+ assertEquals(value, cache.get(fqn, key));
// and the object should now be removed from the loader
- Assert.assertNull(loader.get(fqn));
+ assertNull(loader.get(fqn));
mgr.commit();
// clean up
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedCacheAccessTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,11 +6,11 @@
*/
package org.jboss.cache.optimistic;
-import junit.framework.Assert;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.AfterMethod;
import javax.transaction.TransactionManager;
@@ -68,7 +68,7 @@
// test results.
for (int i = 0; i < numThreads; i++)
{
- Assert.assertTrue("Thread threw an exception!", threads[i].success);
+ assertTrue("Thread threw an exception!", threads[i].success);
}
}
@@ -96,7 +96,7 @@
catch (Exception e)
{
log.error("Caught Exception!", e);
- Assert.assertTrue("Caught Exception!", false);
+ assertTrue("Caught Exception!", false);
success = false;
try
{
Modified: core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsReplTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsReplTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsReplTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -1,6 +1,5 @@
package org.jboss.cache.options;
-import junit.framework.Assert;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
@@ -9,8 +8,7 @@
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.fail;
+import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -108,12 +106,12 @@
{
mgr.commit();
- Assert.assertTrue("expected to fail", false);
+ assertTrue("expected to fail", false);
}
catch (RollbackException e)
{
// should fail.
- Assert.assertTrue("expected to fail with a nested ClassCastException",
true);
+ assertTrue("expected to fail with a nested ClassCastException",
true);
}
}
@@ -159,12 +157,12 @@
try
{
mgr.commit();
- Assert.assertTrue("expected to fail", false);
+ assertTrue("expected to fail", false);
}
catch (RollbackException e)
{
// should fail.
- Assert.assertTrue("expected to fail with a CacheException to do with a
versioning mismatch", true);
+ assertTrue("expected to fail with a CacheException to do with a versioning
mismatch", true);
}
}
@@ -189,12 +187,12 @@
{
cache[1].put(fqn, key, "value2");
mgr.commit();
- Assert.assertTrue("expected to fail", false);
+ assertTrue("expected to fail", false);
}
catch (Exception e)
{
// should fail.
- Assert.assertTrue("expected to fail", true);
+ assertTrue("expected to fail", true);
}
}
@@ -239,12 +237,12 @@
{
// this call will use implicit versioning and will hence fail.
mgr.commit();
- Assert.assertTrue("expected to fail", false);
+ assertTrue("expected to fail", false);
}
catch (Exception e)
{
// should fail.
- Assert.assertTrue("expected to fail with a CacheException to do with a
versioning mismatch", true);
+ assertTrue("expected to fail with a CacheException to do with a versioning
mismatch", true);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++ core/trunk/src/test/java/org/jboss/cache/options/ExplicitVersionsTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.options;
-import junit.framework.Assert;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
@@ -16,8 +15,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -66,14 +64,14 @@
cache.put(fqn, key, "value");
//now retrieve the data from the cache.
- Assert.assertEquals("value", cache.get(fqn, key));
+ assertEquals("value", cache.get(fqn, key));
// get a hold of the node
NodeSPI<String, String> node = (NodeSPI<String, String>)
cache.getNode(fqn);
DataVersion versionFromCache = node.getVersion();
- Assert.assertEquals(TestVersion.class, versionFromCache.getClass());
- Assert.assertEquals("99", ((TestVersion)
versionFromCache).getInternalVersion());
+ assertEquals(TestVersion.class, versionFromCache.getClass());
+ assertEquals("99", ((TestVersion)
versionFromCache).getInternalVersion());
}
public void testFailingPut() throws Exception
@@ -90,12 +88,12 @@
try
{
mgr.commit();
- Assert.assertTrue("expected to fail", false);
+ assertTrue("expected to fail", false);
}
catch (Exception e)
{
// should fail.
- Assert.assertTrue("expected to fail", true);
+ assertTrue("expected to fail", true);
}
}
@@ -112,12 +110,12 @@
{
// this call will use implicit versioning and will hence fail.
mgr.commit();
- Assert.assertTrue("expected to fail", false);
+ assertTrue("expected to fail", false);
}
catch (Exception e)
{
// should fail.
- Assert.assertTrue("expected to fail", true);
+ assertTrue("expected to fail", true);
}
}
Added: core/trunk/src/test/java/org/jboss/cache/options/OptimisticMemLeakTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/OptimisticMemLeakTest.java
(rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/options/OptimisticMemLeakTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -0,0 +1,90 @@
+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";
+ }
+}
Modified:
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/CacheModeLocalTestBase.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.options.cachemodelocal;
-import junit.framework.Assert;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
@@ -114,46 +113,46 @@
cache1.put(fqn, key, "value");
delay();
// cache1 should still have this
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
// cache 2 should not
- Assert.assertNull("Should be null", cache2.get(fqn, key));
+ assertNull("Should be null", cache2.get(fqn, key));
// now try again with passing the default options
cache1.getInvocationContext().getOptionOverrides().reset();
cache1.put(fqn, key, "value");
delay();
// cache1 should still have this
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
// cache 2 should as well
if (!isInvalidation)
{
- Assert.assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
}
else
{
- Assert.assertNull("should be invalidated", cache2.get(fqn, key));
+ assertNull("should be invalidated", cache2.get(fqn, key));
}
// now cache2
cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache2.put(fqn, key, "value2");
delay();
- Assert.assertEquals("value2", cache2.get(fqn, key));
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value2", cache2.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
cache2.getInvocationContext().getOptionOverrides().reset();
cache2.put(fqn, key, "value2");
delay();
- Assert.assertEquals("value2", cache2.get(fqn, key));
+ assertEquals("value2", cache2.get(fqn, key));
if (!isInvalidation)
{
- Assert.assertEquals("value2", cache1.get(fqn, key));
+ assertEquals("value2", cache1.get(fqn, key));
}
else
{
- Assert.assertNull("should be invalidated", cache1.get(fqn, key));
+ assertNull("should be invalidated", cache1.get(fqn, key));
}
}
@@ -166,24 +165,24 @@
cache1.put(fqn, map);
delay();
// cache1 should still have this
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
// cache 2 should not
- Assert.assertNull("Should be null", cache2.get(fqn, key));
+ assertNull("Should be null", cache2.get(fqn, key));
// now try again with passing the default options
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(false);
cache1.put(fqn, map);
delay();
// cache1 should still have this
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
// cache 2 should as well
if (!isInvalidation)
{
- Assert.assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
}
else
{
- Assert.assertNull("should be invalidated", cache2.get(fqn, key));
+ assertNull("should be invalidated", cache2.get(fqn, key));
}
// now cache2
@@ -191,20 +190,20 @@
cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache2.put(fqn, map);
delay();
- Assert.assertEquals("value2", cache2.get(fqn, key));
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value2", cache2.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
cache2.getInvocationContext().getOptionOverrides().reset();
cache2.put(fqn, key, "value2");
delay();
- Assert.assertEquals("value2", cache2.get(fqn, key));
+ assertEquals("value2", cache2.get(fqn, key));
if (!isInvalidation)
{
- Assert.assertEquals("value2", cache1.get(fqn, key));
+ assertEquals("value2", cache1.get(fqn, key));
}
else
{
- Assert.assertNull("should be invalidated", cache1.get(fqn, key));
+ assertNull("should be invalidated", cache1.get(fqn, key));
}
}
@@ -215,14 +214,14 @@
cache1.getInvocationContext().setOptionOverrides(null);
cache1.put(fqn, key, "value");
delay();
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
if (isInvalidation)
{
- Assert.assertNull("Should be null", cache2.get(fqn, key));
+ assertNull("Should be null", cache2.get(fqn, key));
}
else
{
- Assert.assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
}
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
@@ -230,28 +229,28 @@
delay();
// should be removed in cache1
- Assert.assertNull("should be null", cache1.get(fqn, key));
+ assertNull("should be null", cache1.get(fqn, key));
// Not in cache2
if (isInvalidation)
{
- Assert.assertNull("Should be null", cache2.get(fqn, key));
+ assertNull("Should be null", cache2.get(fqn, key));
}
else
{
- Assert.assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
}
// replace cache entries
cache1.put(fqn, key, "value");
delay();
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
if (isInvalidation)
{
- Assert.assertNull("Should be null", cache2.get(fqn, key));
+ assertNull("Should be null", cache2.get(fqn, key));
}
else
{
- Assert.assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
}
// now try again with passing the default options
@@ -260,8 +259,8 @@
delay();
// both should be null
- Assert.assertNull("should be null", cache1.get(fqn, key));
- Assert.assertNull("should be null", cache2.get(fqn, key));
+ assertNull("should be null", cache1.get(fqn, key));
+ assertNull("should be null", cache2.get(fqn, key));
}
public void testRemoveKey() throws Exception
@@ -270,14 +269,14 @@
cache1.getInvocationContext().setOptionOverrides(null);
cache1.put(fqn, key, "value");
delay();
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
if (isInvalidation)
{
- Assert.assertNull("Should be null", cache2.get(fqn, key));
+ assertNull("Should be null", cache2.get(fqn, key));
}
else
{
- Assert.assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
}
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
@@ -285,28 +284,28 @@
delay();
// should be removed in cache1
- Assert.assertNull("should be null", cache1.get(fqn, key));
+ assertNull("should be null", cache1.get(fqn, key));
// Not in cache2
if (isInvalidation)
{
- Assert.assertNull("Should be null", cache2.get(fqn, key));
+ assertNull("Should be null", cache2.get(fqn, key));
}
else
{
- Assert.assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
}
// replace cache entries
cache1.put(fqn, key, "value");
delay();
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
if (isInvalidation)
{
- Assert.assertNull("Should be null", cache2.get(fqn, key));
+ assertNull("Should be null", cache2.get(fqn, key));
}
else
{
- Assert.assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
}
// now try again with passing the default options
@@ -315,8 +314,8 @@
delay();
// both should be null
- Assert.assertNull("should be null", cache1.get(fqn, key));
- Assert.assertNull("should be null", cache2.get(fqn, key));
+ assertNull("should be null", cache1.get(fqn, key));
+ assertNull("should be null", cache2.get(fqn, key));
}
public void testTransactionalBehaviour() throws Exception
@@ -330,11 +329,11 @@
mgr.commit();
delay();
// cache1 should still have this
- Assert.assertEquals("value2", cache1.get(fqn, key));
+ assertEquals("value2", cache1.get(fqn, key));
if (!isInvalidation)
{
- Assert.assertEquals("value1", cache2.get(fqn, key));
+ assertEquals("value1", cache2.get(fqn, key));
}
else
{
@@ -350,16 +349,16 @@
mgr.commit();
delay();
// cache1 should still have this
- Assert.assertEquals("value", cache1.get(fqn, key));
+ assertEquals("value", cache1.get(fqn, key));
// cache 2 should as well
if (!isInvalidation)
{
- Assert.assertEquals("value", cache2.get(fqn, key));
+ assertEquals("value", cache2.get(fqn, key));
}
else
{
- Assert.assertNull("should be invalidated", cache2.get(fqn, key));
+ assertNull("should be invalidated", cache2.get(fqn, key));
}
// now cache2
@@ -372,7 +371,7 @@
mgr.commit();
delay();
- Assert.assertEquals("value2", cache2.get(fqn, key));
+ assertEquals("value2", cache2.get(fqn, key));
if (!isInvalidation)
{
@@ -390,14 +389,14 @@
cache2.put(fqn, key, "value2");
mgr.commit();
delay();
- Assert.assertEquals("value2", cache2.get(fqn, key));
+ assertEquals("value2", cache2.get(fqn, key));
if (!isInvalidation)
{
- Assert.assertEquals("value2", cache1.get(fqn, key));
+ assertEquals("value2", cache1.get(fqn, key));
}
else
{
- Assert.assertNull("should be invalidated", cache1.get(fqn, key));
+ assertNull("should be invalidated", cache1.get(fqn, key));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileSlaveTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -15,7 +15,6 @@
@Test(groups = "profiling")
public class ProfileSlaveTest extends AbstractProfileTest
{
-
private void waitForTest() throws Exception
{
System.out.println("Slave listening for remote connections. Hit Enter when
done.");
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -38,7 +38,7 @@
protected static final int NUM_THREADS = 10;
protected static final int MAX_RANDOM_SLEEP_MILLIS = 100;
protected static final int MAX_DEPTH = 8;
- protected static final int MAX_OVERALL_NODES = 10000;
+ protected static final int MAX_OVERALL_NODES = 100;
private List<Fqn> fqns = new ArrayList<Fqn>(MAX_OVERALL_NODES);
@@ -137,9 +137,11 @@
{
ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
long end = System.currentTimeMillis() + DURATION;
-
+ int i = 0;
+ long start = System.currentTimeMillis();
while (System.currentTimeMillis() < end)
{
+ i++;
exec.execute(new Runnable()
{
public void run()
@@ -155,8 +157,8 @@
// wait for executors to complete!
exec.shutdown();
exec.awaitTermination(10000, TimeUnit.MILLISECONDS);
-
- System.out.println("Completed Test!");
+ double durationSecs = (System.currentTimeMillis() - start) / 1000;
+ System.out.println("Completed Test! Achieved " + ((double) i /
durationSecs) + " TPS.");
}
private String getRandomString()
Modified:
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.transaction;
-import junit.framework.AssertionFailedError;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
@@ -41,8 +40,8 @@
private volatile boolean writerFailed;
private volatile boolean readerFailed;
- private volatile AssertionFailedError writerError;
- private volatile AssertionFailedError readerError;
+ private volatile AssertionError writerError;
+ private volatile AssertionError readerError;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -112,7 +111,7 @@
// notify the reading thread
secondCanRead.countDown();
}
- catch (AssertionFailedError e)
+ catch (AssertionError e)
{
writerError = e;
}
@@ -167,7 +166,7 @@
// I should still see the value I put
assertEquals("write lock not acquired on " + "creation of
an empty node", VALUE, cache.get(a2, KEY));
}
- catch (AssertionFailedError e)
+ catch (AssertionError e)
{
readerError = e;
}
Modified:
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -1,6 +1,5 @@
package org.jboss.cache.transaction;
-import junit.framework.AssertionFailedError;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
@@ -38,8 +37,8 @@
private volatile boolean writerFailed;
private volatile boolean readerFailed;
- private volatile AssertionFailedError writerError;
- private volatile AssertionFailedError readerError;
+ private volatile AssertionError writerError;
+ private volatile AssertionError readerError;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -122,7 +121,7 @@
// I should still be able to see the "clean" value
assertEquals("Could not read node with expected value!", VALUE,
cache.get(FQN, KEY));
}
- catch (AssertionFailedError e)
+ catch (AssertionError e)
{
readerError = e;
}
@@ -179,7 +178,7 @@
tm.rollback();
}
- catch (AssertionFailedError e)
+ catch (AssertionError e)
{
writerError = e;
}
@@ -260,7 +259,7 @@
mgr.commit();
}
- catch (AssertionFailedError e)
+ catch (AssertionError e)
{
writerError = e;
}
Modified:
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelRepeatableReadTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelRepeatableReadTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelRepeatableReadTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -1,6 +1,5 @@
package org.jboss.cache.transaction;
-import junit.framework.AssertionFailedError;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
@@ -33,7 +32,7 @@
private final String VALUE = "value";
private volatile boolean writerFailed;
- private volatile AssertionFailedError writerError;
+ private volatile AssertionError writerError;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -92,7 +91,7 @@
tm.commit();
}
- catch (AssertionFailedError e)
+ catch (AssertionError e)
{
writerError = e;
}
Modified:
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelSerializableTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelSerializableTest.java 2007-12-21
06:12:32 UTC (rev 4911)
+++
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelSerializableTest.java 2007-12-21
14:58:06 UTC (rev 4912)
@@ -1,6 +1,5 @@
package org.jboss.cache.transaction;
-import junit.framework.AssertionFailedError;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
@@ -35,7 +34,7 @@
private final String VALUE = "value";
private volatile boolean writerFailed;
- private volatile AssertionFailedError writerError;
+ private volatile AssertionError writerError;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -97,7 +96,7 @@
tx.commit();
}
- catch (AssertionFailedError e)
+ catch (AssertionError e)
{
writerError = e;
}