[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/replicated ...
Manik Surtani
manik at jboss.org
Thu Jun 28 12:53:39 EDT 2007
User: msurtani
Date: 07/06/28 12:53:39
Modified: tests/functional/org/jboss/cache/replicated
SyncCacheListenerTest.java SyncReplTxTest.java
Log:
Notification changes
Revision Changes Path
1.17 +20 -22 JBossCache/tests/functional/org/jboss/cache/replicated/SyncCacheListenerTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SyncCacheListenerTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/replicated/SyncCacheListenerTest.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- SyncCacheListenerTest.java 8 Feb 2007 14:52:42 -0000 1.16
+++ SyncCacheListenerTest.java 28 Jun 2007 16:53:39 -0000 1.17
@@ -12,13 +12,15 @@
import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.AbstractCacheListener;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheImpl;
import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.NodeEvent;
import org.jboss.cache.transaction.DummyTransactionManager;
import javax.naming.Context;
@@ -32,7 +34,7 @@
/**
* Test out the TreeCacheListener
*
- * @version $Revision: 1.16 $
+ * @version $Revision: 1.17 $
*/
public class SyncCacheListenerTest extends TestCase
{
@@ -201,7 +203,8 @@
}
- class Listener extends AbstractCacheListener
+ @CacheListener
+ class Listener
{
Object key_ = null;
@@ -219,16 +222,16 @@
cache1.put(fqn, map);
}
-
- public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType modType, Map data)
+ @NodeModified
+ public void nodeModified(NodeEvent ne)
{
- if (!pre)
+ if (!ne.isPre())
{
- log_.debug("nodeModified visited with fqn: " + fqn);
+ log_.debug("nodeModified visited with fqn: " + ne.getFqn());
try
{
// test out if we can get the read lock since there is a write lock going as well.
- cache1.get(fqn, key_);
+ cache1.get(ne.getFqn(), key_);
}
catch (CacheException e)
{
@@ -240,23 +243,18 @@
}
- class RemoteListener extends AbstractCacheListener
+ @CacheListener
+ class RemoteListener
{
- public void nodeRemoved(Fqn fqn, boolean isPre, boolean isLocal, Map data)
+ @NodeRemoved
+ @NodeModified
+ public void callback(NodeEvent e)
{
- System.out.println("nodeRemove visited with fqn: " + fqn + ", isPre: " + isPre + ", isLocal " + isLocal);
- log_.debug("nodeRemove visited with fqn: " + fqn + ", isPre: " + isPre + ", isLocal " + isLocal);
- assertFalse("node was removed on remote cache so isLocal should be false", isLocal);
+ System.out.println("Callback got event " + e);
+ log_.debug("Callback got event " + e);
+ assertFalse("node was removed on remote cache so isLocal should be false", e.isOriginLocal());
}
-
- public void nodeModified(Fqn fqn, boolean isPre, boolean isLocal, ModificationType modType, Map data)
- {
- System.out.println("nodeModify visited with fqn: " + fqn + ", isPre: " + isPre + ", isLocal " + isLocal);
- log_.debug("nodeModify visited with fqn: " + fqn + ", isPre: " + isPre + ", isLocal " + isLocal);
- assertFalse("node was modified on remote cache so isLocal should be false", isLocal);
- }
-
}
public static Test suite()
1.23 +22 -16 JBossCache/tests/functional/org/jboss/cache/replicated/SyncReplTxTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SyncReplTxTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/replicated/SyncReplTxTest.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- SyncReplTxTest.java 8 Jun 2007 16:44:25 -0000 1.22
+++ SyncReplTxTest.java 28 Jun 2007 16:53:39 -0000 1.23
@@ -12,7 +12,6 @@
import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.AbstractCacheListener;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheImpl;
@@ -22,6 +21,9 @@
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.event.NodeEvent;
import org.jboss.cache.transaction.DummyTransactionManager;
import javax.naming.Context;
@@ -34,7 +36,6 @@
import javax.transaction.TransactionManager;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.Semaphore;
/**
@@ -42,7 +43,7 @@
* Note: we use DummyTransactionManager for Tx purpose instead of relying on
* jta.
*
- * @version $Revision: 1.22 $
+ * @version $Revision: 1.23 $
*/
public class SyncReplTxTest extends TestCase
{
@@ -1263,7 +1264,8 @@
}
}
- static class CallbackListener extends AbstractCacheListener
+ @CacheListener
+ static class CallbackListener
{
CacheImpl callbackCache;
@@ -1278,9 +1280,10 @@
cache.getNotifier().addCacheListener(this);
}
- public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType modType, Map data)
+ @NodeModified
+ public void nodeModified(NodeEvent e)
{
- if (!pre)
+ if (!e.isPre())
{
// Lock on a mutex so test can't check for an exception
// until the get call completes
@@ -1288,12 +1291,12 @@
{
try
{
- callbackCache.get(fqn, callbackKey);
+ callbackCache.get(e.getFqn(), callbackKey);
}
- catch (CacheException e)
+ catch (CacheException exc)
{
- e.printStackTrace();
- ex = e;
+ exc.printStackTrace();
+ ex = exc;
}
}
}
@@ -1320,9 +1323,10 @@
callbackTM = callbackCache.getTransactionManager();
}
- public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType modType, Map data)
+ @NodeModified
+ public void nodeModified(NodeEvent ne)
{
- if (!pre)
+ if (!ne.isPre())
{
try
{
@@ -1334,7 +1338,7 @@
}
else
{
- super.nodeModified(fqn, pre, isLocal, modType, data);
+ super.nodeModified(ne);
}
}
@@ -1351,7 +1355,8 @@
}
- static class TransactionAborterListener extends AbstractCacheListener
+ @CacheListener
+ static class TransactionAborterListener
{
TransactionManager callbackTM;
@@ -1364,9 +1369,10 @@
cache.getNotifier().addCacheListener(this);
}
- public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType modType, Map data)
+ @NodeModified
+ public void nodeModified(NodeEvent ne)
{
- if (!pre)
+ if (!ne.isPre())
{
synchronized (mutex)
{
More information about the jboss-cvs-commits
mailing list