[jboss-cvs] JBossCache/tests/functional/org/jboss/cache ...
Manik Surtani
msurtani at belmont.prod.atl2.jboss.com
Wed Aug 30 15:09:57 EDT 2006
User: msurtani
Date: 06/08/30 15:09:57
Modified: tests/functional/org/jboss/cache CallbackTest.java
Log:
removed unnenessary (IDE-generated) TODOs that were becoming noisy
refactored identity lock constructors
Revision Changes Path
1.12 +103 -90 JBossCache/tests/functional/org/jboss/cache/CallbackTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CallbackTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/CallbackTest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- CallbackTest.java 16 Aug 2006 10:52:52 -0000 1.11
+++ CallbackTest.java 30 Aug 2006 19:09:57 -0000 1.12
@@ -3,53 +3,54 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.transaction.DummyTransactionManager;
-import org.jboss.cache.config.Configuration;
import javax.transaction.NotSupportedException;
import javax.transaction.Transaction;
/**
* Tests whether modifications within callbacks (TreeCacheListener) are handled correctly
+ *
* @author Bela Ban
- * @version $Id: CallbackTest.java,v 1.11 2006/08/16 10:52:52 msurtani Exp $
+ * @version $Id: CallbackTest.java,v 1.12 2006/08/30 19:09:57 msurtani Exp $
*/
-public class CallbackTest extends TestCase {
- TreeCache cache=null, cache2;
- Transaction tx=null;
- final Fqn FQN_A=Fqn.fromString("/a");
- final Fqn FQN_B=Fqn.fromString("/b");
- final String KEY="key";
- final String VALUE="value";
-
+public class CallbackTest extends TestCase
+{
+ TreeCache cache = null, cache2;
+ Transaction tx = null;
+ final Fqn FQN_A = Fqn.fromString("/a");
+ final Fqn FQN_B = Fqn.fromString("/b");
+ final String KEY = "key";
+ final String VALUE = "value";
-
-
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception
+ {
super.setUp();
}
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
super.tearDown();
- if(cache != null) {
+ if (cache != null)
+ {
cache.stopService();
cache.destroyService();
- cache=null;
+ cache = null;
}
- if(tx != null) {
+ if (tx != null)
+ {
tx.commit();
- tx=null;
+ tx = null;
}
}
-
-
-
- public void testLocalPutCallbackWithoutTransaction() throws Exception, NotSupportedException {
- cache=createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
+ public void testLocalPutCallbackWithoutTransaction() throws Exception, NotSupportedException
+ {
+ cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
cache.getNotifier().addCacheListener(new PutListener(cache));
cache.put(FQN_A, null);
@@ -60,8 +61,9 @@
assertEquals(0, cache.getNumberOfLocksHeld());
}
- public void testLocalGetCallbackSameFqnWithoutTransaction() throws Exception, NotSupportedException {
- cache=createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
+ public void testLocalGetCallbackSameFqnWithoutTransaction() throws Exception, NotSupportedException
+ {
+ cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
cache.getNotifier().addCacheListener(new GetListener(cache, FQN_A));
cache.put(FQN_A, null);
@@ -71,8 +73,9 @@
assertEquals(0, cache.getNumberOfLocksHeld());
}
- public void testLocalGetCallbackDifferentFqnWithoutTransaction() throws Exception, NotSupportedException {
- cache=createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
+ public void testLocalGetCallbackDifferentFqnWithoutTransaction() throws Exception, NotSupportedException
+ {
+ cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
cache.put(FQN_B, null);
cache.getNotifier().addCacheListener(new GetListener(cache, FQN_B));
@@ -85,11 +88,11 @@
}
-
- public void testLocalCallbackWithTransaction() throws Exception, NotSupportedException {
- cache=createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
+ public void testLocalCallbackWithTransaction() throws Exception, NotSupportedException
+ {
+ cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
cache.getNotifier().addCacheListener(new PutListener(cache));
- tx=startTransaction();
+ tx = startTransaction();
cache.put(FQN_A, null);
tx.commit();
assertTrue(cache.exists(FQN_A));
@@ -97,15 +100,18 @@
}
- public void testLocalCallbackWithException() throws Exception, NotSupportedException {
- cache=createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
+ public void testLocalCallbackWithException() throws Exception, NotSupportedException
+ {
+ cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
cache.getNotifier().addCacheListener(new ExceptionListener());
- tx=startTransaction();
- try {
+ tx = startTransaction();
+ try
+ {
cache.put(FQN_A, null);
tx.rollback();
}
- catch(RuntimeException ex) {
+ catch (RuntimeException ex)
+ {
tx.rollback();
}
assertFalse(cache.exists(FQN_A));
@@ -120,9 +126,6 @@
cache.setSyncCommitPhase(true);
cache2.setSyncCommitPhase(true);
- // cache.setSyncReplTimeout(60000); // todo: remove again, just for debugging
- // cache2.setSyncReplTimeout(60000); // todo: remove again, just for debugging
-
assertEquals(2, cache.getMembers().size());
System.out.println("view is correct: " + cache.getMembers() + " (2 members)");
cache2.addTreeCacheListener(new PutListener(cache2));
@@ -151,8 +154,6 @@
assertEquals(0, tx_table2.getNumGlobalTransactions());
}*/
-
-
/* public static void main(String[] args) {
try {
new CallbackTest().testSyncReplicationWith2Caches();
@@ -160,11 +161,12 @@
catch(Exception e) {
e.printStackTrace();
}
- }*/
+}*/
- TreeCache createCache(Configuration.CacheMode mode, IsolationLevel level) throws Exception {
- TreeCache c=new TreeCache();
+ TreeCache createCache(Configuration.CacheMode mode, IsolationLevel level) throws Exception
+ {
+ TreeCache c = new TreeCache();
c.getConfiguration().setCacheMode(mode);
c.getConfiguration().setIsolationLevel(level);
c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
@@ -173,20 +175,23 @@
return c;
}
- Transaction startTransaction() {
- DummyTransactionManager mgr=DummyTransactionManager.getInstance();
- try {
+ Transaction startTransaction()
+ {
+ DummyTransactionManager mgr = DummyTransactionManager.getInstance();
+ try
+ {
mgr.begin();
return mgr.getTransaction();
}
- catch(Throwable t) {
+ catch (Throwable t)
+ {
return null;
}
}
-
- class ExceptionListener extends AbstractCacheListener {
+ class ExceptionListener extends AbstractCacheListener
+ {
public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
{
if (pre) throw new RuntimeException("this will cause the TX to rollback");
@@ -199,20 +204,22 @@
TreeCache c;
Fqn my_fqn;
- public GetListener(TreeCache c, Fqn my_fqn) {
- this.c=c;
- this.my_fqn=my_fqn;
+ public GetListener(TreeCache c, Fqn my_fqn)
+ {
+ this.c = c;
+ this.my_fqn = my_fqn;
}
- public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal) {
+ public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
+ {
if (!pre)
{
try
{
- TreeNode n=c.get(this.my_fqn);
+ TreeNode n = c.get(this.my_fqn);
assertNotNull(n);
}
- catch(CacheException e)
+ catch (CacheException e)
{
fail("listener was unable to do a get(" + my_fqn + ") during callback: " + e);
}
@@ -221,25 +228,30 @@
}
- class PutListener extends AbstractCacheListener {
+ class PutListener extends AbstractCacheListener
+ {
TreeCache c;
- public PutListener(TreeCache c) {
- this.c=c;
+ public PutListener(TreeCache c)
+ {
+ this.c = c;
}
public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
{
if (!pre)
{
- try {
- if(!c.exists(FQN_B)) {
+ try
+ {
+ if (!c.exists(FQN_B))
+ {
System.out.println("PutListener: creating node " + FQN_B);
c.put(FQN_B, KEY, VALUE);
System.out.println("PutListener: created node " + FQN_B);
}
}
- catch(CacheException e) {
+ catch (CacheException e)
+ {
fail("listener was unable to update cache during callback: " + e);
}
}
@@ -247,7 +259,8 @@
}
- public static Test suite() {
+ public static Test suite()
+ {
return new TestSuite(CallbackTest.class);
}
More information about the jboss-cvs-commits
mailing list