[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/notifications ...
Manik Surtani
msurtani at jboss.com
Fri Sep 15 20:23:36 EDT 2006
User: msurtani
Date: 06/09/15 20:23:36
Modified: tests/functional/org/jboss/cache/notifications
CacheListenerTest.java
Log:
Updates to the move() API plus more UTs
Revision Changes Path
1.4 +345 -229 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.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- CacheListenerTest.java 24 Aug 2006 16:30:10 -0000 1.3
+++ CacheListenerTest.java 16 Sep 2006 00:23:36 -0000 1.4
@@ -165,7 +165,118 @@
assertEquals(expected, eventLog.events);
}
- // TODO: Transactional stuff. Test the above is only notified after a commit, and that rollbacks work accordingly as well.
+ public void testMove()
+ {
+ fail("implement me");
+ }
+
+ // -- now the transactional ones
+
+ public void testTxCreation() throws Exception
+ {
+ fail("implement me");
+ assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+ cache.put(fqn, "key", "value");
+ Map data = new HashMap();
+ data.put("key", "value");
+
+ //expected
+ List<Event> expected = new ArrayList<Event>();
+ expected.add(new Event(ListenerMethod.NODE_CREATED, fqn, true, true, null));
+ expected.add(new Event(ListenerMethod.NODE_CREATED, fqn, false, true, null));
+ expected.add(new Event(ListenerMethod.NODE_MODIFIED, fqn, true, true, Collections.emptyMap()));
+ expected.add(new Event(ListenerMethod.NODE_MODIFIED, fqn, false, true, data));
+
+ assertEquals(expected, eventLog.events);
+ assertEquals("value", cache.get(fqn, "key"));
+ }
+
+ public void testTxOnlyModification() throws Exception
+ {
+ fail("implement me");
+ assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+ cache.put(fqn, "key", "value");
+ Map oldData = new HashMap();
+ oldData.put("key", "value");
+
+ // clear event log
+ eventLog.events.clear();
+ assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+
+ // modify existing node
+ cache.put(fqn, "key", "value2");
+ Map newData = new HashMap();
+ newData.put("key", "value2");
+
+ //expected
+ List<Event> expected = new ArrayList<Event>();
+ expected.add(new Event(ListenerMethod.NODE_MODIFIED, fqn, true, true, oldData));
+ expected.add(new Event(ListenerMethod.NODE_MODIFIED, fqn, false, true, newData));
+
+ assertEquals(expected, eventLog.events);
+ }
+
+
+ public void testTxOnlyRemoval() throws Exception
+ {
+ fail("implement me");
+ assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+ cache.put(fqn, "key", "value");
+ Map oldData = new HashMap();
+ oldData.put("key", "value");
+
+ assertEquals("value", cache.get(fqn, "key"));
+
+ // clear event log
+ eventLog.events.clear();
+ assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+
+ // modify existing node
+ cache.removeNode(fqn);
+
+ //expected
+ List<Event> expected = new ArrayList<Event>();
+ expected.add(new Event(ListenerMethod.NODE_REMOVED, fqn, true, true, oldData));
+ expected.add(new Event(ListenerMethod.NODE_REMOVED, fqn, false, true, null));
+
+ assertEquals(expected, eventLog.events);
+
+ // test that the node has in fact been removed.
+ assertNull("Should be null", cache.getChild(fqn));
+ }
+
+
+ public void testTxRemoveData() throws Exception
+ {
+ fail("implement me");
+ assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+ cache.put(fqn, "key", "value");
+ cache.put(fqn, "key2", "value2");
+ Map oldData = new HashMap();
+ oldData.put("key", "value");
+ oldData.put("key2", "value2");
+
+ // clear event log
+ eventLog.events.clear();
+ assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+
+ // modify existing node
+ cache.remove(fqn, "key2");
+ Map newData = new HashMap();
+ newData.put("key", "value");
+
+ //expected
+ List<Event> expected = new ArrayList<Event>();
+ expected.add(new Event(ListenerMethod.NODE_MODIFIED, fqn, true, true, oldData));
+ expected.add(new Event(ListenerMethod.NODE_MODIFIED, fqn, false, true, newData));
+
+ assertEquals(expected, eventLog.events);
+ }
+
+ public void testTxMove()
+ {
+ fail("implement me");
+ }
// ============= supporting classes and enums =======================
@@ -207,6 +318,7 @@
}
}
+
public static class Event
{
ListenerMethod methodName;
@@ -263,5 +375,9 @@
}
}
- public enum ListenerMethod {NODE_CREATED, NODE_REMOVED, NODE_VISITED, NODE_MODIFIED};
+ public enum ListenerMethod
+ {
+ NODE_CREATED, NODE_REMOVED, NODE_VISITED, NODE_MODIFIED}
+
+ ;
}
More information about the jboss-cvs-commits
mailing list