[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/notifications ...
Manik Surtani
msurtani at jboss.com
Wed Jan 3 12:50:30 EST 2007
User: msurtani
Date: 07/01/03 12:50:30
Modified: tests/functional/org/jboss/cache/notifications
RemoteCacheListenerTest.java CacheListenerTest.java
Added: tests/functional/org/jboss/cache/notifications
NodeMapDiffTest.java
Log:
added more rich nodeModified callback
Revision Changes Path
1.7 +1 -1 JBossCache/tests/functional/org/jboss/cache/notifications/RemoteCacheListenerTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RemoteCacheListenerTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/notifications/RemoteCacheListenerTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- RemoteCacheListenerTest.java 2 Jan 2007 18:26:05 -0000 1.6
+++ RemoteCacheListenerTest.java 3 Jan 2007 17:50:30 -0000 1.7
@@ -378,7 +378,7 @@
events.add(e);
}
- public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
+ public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType modType, Map data)
{
RemoteCacheListenerTest.Event e = new RemoteCacheListenerTest.Event(RemoteCacheListenerTest.ListenerMethod.NODE_MODIFIED, fqn, pre, isLocal, data);
events.add(e);
1.15 +4 -4 JBossCache/tests/functional/org/jboss/cache/notifications/CacheListenerTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheListenerTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/notifications/CacheListenerTest.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- CacheListenerTest.java 3 Jan 2007 15:33:09 -0000 1.14
+++ CacheListenerTest.java 3 Jan 2007 17:50:30 -0000 1.15
@@ -158,13 +158,13 @@
// modify existing node
cache.remove(fqn, "key2");
- Map newData = new HashMap();
- newData.put("key", "value");
+ Map removedData = new HashMap();
+ removedData.put("key2", "value2");
//expected
List<CacheListenerEvent> expected = new ArrayList<CacheListenerEvent>();
expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, true, true, oldData));
- expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, false, true, newData));
+ expected.add(new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, false, true, removedData));
assertEquals(expected, eventLog.events);
}
@@ -362,7 +362,7 @@
events.add(e);
}
- public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
+ public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType modType, Map data)
{
CacheListenerEvent e = new CacheListenerEvent(CacheListenerEvent.ListenerMethod.NODE_MODIFIED, fqn, pre, isLocal, data);
events.add(e);
1.1 date: 2007/01/03 17:50:30; author: msurtani; state: Exp;JBossCache/tests/functional/org/jboss/cache/notifications/NodeMapDiffTest.java
Index: NodeMapDiffTest.java
===================================================================
package org.jboss.cache.notifications;
import junit.framework.TestCase;
import org.jboss.cache.util.Util;
import java.util.HashMap;
import java.util.Map;
/**
* Tests the diffs between maps.
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
public class NodeMapDiffTest extends TestCase
{
public void testDataAdded()
{
Util.MapModifications expected = new Util.MapModifications();
expected.addedEntries.put("key", "value");
expected.addedEntries.put("key1", "value1");
Map pre = new HashMap();
pre.put("oldKey", "oldValue");
Map post = new HashMap();
post.putAll(pre);
post.put("key", "value");
post.put("key1", "value1");
assertEquals(expected, Util.diffNodeData(pre, post));
}
public void testDataRemoved()
{
Util.MapModifications expected = new Util.MapModifications();
expected.removedEntries.put("key", "value");
expected.removedEntries.put("key1", "value1");
Map post = new HashMap();
post.put("oldKey", "oldValue");
Map pre = new HashMap();
pre.putAll(post);
pre.put("key", "value");
pre.put("key1", "value1");
assertEquals(expected, Util.diffNodeData(pre, post));
}
public void testDataChanged()
{
Util.MapModifications expected = new Util.MapModifications();
expected.modifiedEntries.put("key", "value");
expected.modifiedEntries.put("key1", "value1");
Map pre = new HashMap();
pre.put("oldKey", "oldValue");
pre.put("key", "valueOLD");
pre.put("key1", "value1OLD");
Map post = new HashMap();
post.putAll(pre);
post.put("key", "value");
post.put("key1", "value1");
assertEquals(expected, Util.diffNodeData(pre, post));
}
public void testNullMaps()
{
try
{
Util.diffNodeData(null, null);
fail("Expected NPE");
}
catch (NullPointerException npe)
{
// expected
}
try
{
Util.diffNodeData(new HashMap(), null);
fail("Expected NPE");
}
catch (NullPointerException npe)
{
// expected
}
try
{
Util.diffNodeData(null, new HashMap());
fail("Expected NPE");
}
catch (NullPointerException npe)
{
// expected
}
}
public void testEmptyMaps()
{
Util.MapModifications expected = new Util.MapModifications();
Map pre = new HashMap();
Map post = new HashMap();
assertEquals(expected, Util.diffNodeData(pre, post));
}
public void testNoChange()
{
Util.MapModifications expected = new Util.MapModifications();
Map pre = new HashMap();
pre.put("a", "b");
pre.put("c", "d");
pre.put("e", "f");
Map post = new HashMap();
post.put("a", "b");
post.put("c", "d");
post.put("e", "f");
assertEquals(expected, Util.diffNodeData(pre, post));
}
public void testMultipleChanges()
{
Util.MapModifications expected = new Util.MapModifications();
expected.modifiedEntries.put("key", "value");
expected.modifiedEntries.put("key1", "value1");
expected.addedEntries.put("key2", "value2");
expected.addedEntries.put("key3", "value3");
expected.removedEntries.put("key4", "value4");
expected.removedEntries.put("key5", "value5");
Map pre = new HashMap();
pre.put("oldKey", "oldValue");
pre.put("key", "valueOLD");
pre.put("key1", "value1OLD");
pre.put("key4", "value4");
pre.put("key5", "value5");
Map post = new HashMap();
post.put("oldKey", "oldValue");
post.put("key", "value");
post.put("key1", "value1");
post.put("key2", "value2");
post.put("key3", "value3");
assertEquals(expected, Util.diffNodeData(pre, post));
}
}
More information about the jboss-cvs-commits
mailing list