[infinispan-commits] Infinispan SVN: r285 - trunk/core/src/test/java/org/infinispan/tx.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed May 13 12:48:27 EDT 2009


Author: manik.surtani at jboss.com
Date: 2009-05-13 12:48:27 -0400 (Wed, 13 May 2009)
New Revision: 285

Modified:
   trunk/core/src/test/java/org/infinispan/tx/TransactionsSpanningReplicatedCaches.java
Log:
Test putIfAbsent in a replicated tx

Modified: trunk/core/src/test/java/org/infinispan/tx/TransactionsSpanningReplicatedCaches.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/tx/TransactionsSpanningReplicatedCaches.java	2009-05-13 14:23:43 UTC (rev 284)
+++ trunk/core/src/test/java/org/infinispan/tx/TransactionsSpanningReplicatedCaches.java	2009-05-13 16:48:27 UTC (rev 285)
@@ -150,22 +150,46 @@
       c1.put("c1key", "c1value");
       assert c1.get("c1key").equals("c1value");
       assert c1Replica.get("c1key").equals("c1value");
-  }
+   }
 
-  public void testSimpleCommit() throws Exception {
+   public void testSimpleCommit() throws Exception {
       Cache c1 = cm1.getCache("c1");
       Cache c1Replica = cm2.getCache("c1");
 
 
-     assert c1.isEmpty();
-     assert c1Replica.isEmpty();
+      assert c1.isEmpty();
+      assert c1Replica.isEmpty();
 
-     TransactionManager tm = TestingUtil.getTransactionManager(c1);
-     tm.begin();
+      TransactionManager tm = TestingUtil.getTransactionManager(c1);
+      tm.begin();
       c1.put("c1key", "c1value");
-     tm.commit();
+      tm.commit();
 
       assert c1.get("c1key").equals("c1value");
       assert c1Replica.get("c1key").equals("c1value");
-  }
+   }
+
+   public void testPutIfAbsent() throws Exception {
+      Cache c1 = cm1.getCache("c1");
+      Cache c1Replica = cm2.getCache("c1");
+
+
+      assert c1.isEmpty();
+      assert c1Replica.isEmpty();
+
+      TransactionManager tm = TestingUtil.getTransactionManager(c1);
+      tm.begin();
+      c1.put("c1key", "c1value");
+      tm.commit();
+
+      assert c1.get("c1key").equals("c1value");
+      assert c1Replica.get("c1key").equals("c1value");
+
+      tm.begin();
+      c1.putIfAbsent("c1key", "SHOULD_NOT_GET_INSERTED");
+      tm.commit();
+
+      assert c1.get("c1key").equals("c1value");
+      assert c1Replica.get("c1key").equals("c1value");
+   }
 }
\ No newline at end of file




More information about the infinispan-commits mailing list