[jbosscache-commits] JBoss Cache SVN: r5040 - in core/trunk/src: test/java/org/jboss/cache/notifications and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Jan 7 19:26:23 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-01-07 19:26:22 -0500 (Mon, 07 Jan 2008)
New Revision: 5040

Modified:
   core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
   core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerOptimisticTest.java
   core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
   core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
Log:
Added tests for notifications on removal on nonexistent node and fixed typo

Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-01-07 18:09:53 UTC (rev 5039)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-01-08 00:26:22 UTC (rev 5040)
@@ -464,7 +464,7 @@
       if (f.size() == 1)
       {
          GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
-         return getOrCreateChild(f.getLastElement(), gtx, notify, notify);
+         return getOrCreateChild(f.getLastElement(), gtx, true, notify);
       }
       else
       {

Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerOptimisticTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerOptimisticTest.java	2008-01-07 18:09:53 UTC (rev 5039)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerOptimisticTest.java	2008-01-08 00:26:22 UTC (rev 5040)
@@ -6,6 +6,9 @@
  */
 package org.jboss.cache.notifications;
 
+import org.testng.annotations.Test;
+
+ at Test(groups = "functional")
 public class CacheListenerOptimisticTest extends CacheListenerTest
 {
    public CacheListenerOptimisticTest()

Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java	2008-01-07 18:09:53 UTC (rev 5039)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java	2008-01-08 00:26:22 UTC (rev 5040)
@@ -38,7 +38,7 @@
  *
  * @since 2.0.0
  */
- at Test(groups = {"functional"})
+ at Test(groups = "functional")
 public class CacheListenerTest
 {
    protected boolean optLocking = false;
@@ -165,6 +165,20 @@
       assertNull("Should be null", cache.getRoot().getChild(fqn));
    }
 
+   public void testNonexistentRemove() throws Exception
+   {
+      cache.removeNode("/does/not/exist");
+      List<Event> expected = new ArrayList<Event>();
+
+      if (optLocking)
+      {
+         expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
+         expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
+         eventLog.scrubImplicitTransactions();
+      }
+      assertEquals(expected, eventLog.events);
+   }
+
    public void testRemoveData() throws Exception
    {
       assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
@@ -262,6 +276,18 @@
 
    // -- now the transactional ones
 
+   public void testTxNonexistentRemove() throws Exception
+   {
+      tm.begin();
+      Transaction tx = tm.getTransaction();
+      cache.removeNode("/does/not/exist");
+      tm.commit();
+      List<Event> expected = new ArrayList<Event>();
+      expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+      expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
+      assertEquals(expected, eventLog.events);
+   }
+
    public void testTxCreationCommit() throws Exception
    {
       assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);

Modified: core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java	2008-01-07 18:09:53 UTC (rev 5039)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java	2008-01-08 00:26:22 UTC (rev 5040)
@@ -160,6 +160,25 @@
       assertEquals("value", cache1.get(fqn, "key"));
    }
 
+   public void testNonexistentRemove() throws Exception
+   {
+      cache1.removeNode("/does/not/exist");
+      List<Event> expected = new ArrayList<Event>();
+
+      if (optLocking)
+      {
+         expected.add(new EventImpl(false, cache1, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
+         expected.add(new EventImpl(false, cache1, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
+         eventLog1.scrubImplicitTransactions();
+         eventLog2.scrubImplicitTransactions();
+      }
+      assertEquals(expected, eventLog1.events);
+      setCache(cache2, expected);
+      markOriginRemote(expected);
+      assertEquals(expected, eventLog2.events);
+   }
+
+
    public void testOnlyModification() throws Exception
    {
       assertNull(cache1.get(fqn, "key"));
@@ -405,6 +424,23 @@
       assertEquals("value", cache2.get(fqn, "key"));
    }
 
+   public void testTxNonexistentRemove() throws Exception
+   {
+      tm1.begin();
+      Transaction tx = tm1.getTransaction();
+      cache1.removeNode("/does/not/exist");
+      tm1.commit();
+      List<Event> expected = new ArrayList<Event>();
+      expected.add(new EventImpl(false, cache1, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+      expected.add(new EventImpl(false, cache1, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
+      assertEquals(expected, eventLog1.events);
+      setCache(cache2, expected);
+      markOriginRemote(expected);
+      scrubTransactions(expected);
+      eventLog2.scrubImplicitTransactions();
+      assertEquals(expected, eventLog2.events);
+   }
+
    public void testTxCreationRollback() throws Exception
    {
       assertEquals("Event log should be empty", Collections.emptyList(), eventLog2.events);




More information about the jbosscache-commits mailing list