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

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Tue May 12 09:51:36 EDT 2009


Author: vblagojevic at jboss.com
Date: 2009-05-12 09:51:36 -0400 (Tue, 12 May 2009)
New Revision: 261

Added:
   trunk/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java
Log:
[ISPN-48] -  Introduce lock() and unlock() API methods
work in progress

Added: trunk/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java	                        (rev 0)
+++ trunk/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java	2009-05-12 13:51:36 UTC (rev 261)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.infinispan.replication;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+
+import javax.transaction.TransactionManager;
+
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.test.MultipleCacheManagersTest;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.transaction.lookup.DummyTransactionManagerLookup;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
+ */
+ at Test(groups = "functional", testName = "replication.SyncReplLockingTest")
+public class SyncReplLockingTest extends MultipleCacheManagersTest {
+   Cache<String,String> cache1, cache2;
+   String k = "key", v = "value";
+
+   protected void createCacheManagers() throws Throwable {
+      Configuration replSync = getDefaultClusteredConfig(Configuration.CacheMode.REPL_SYNC);
+      replSync.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+      createClusteredCaches(2, "replSync", replSync);
+
+      cache1 = manager(0).getCache("replSync");
+      cache2 = manager(1).getCache("replSync");
+   }
+
+   public void testBasicOperation() throws Exception {
+      assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
+
+      assertNull("Should be null", cache1.get(k));
+      assertNull("Should be null", cache2.get(k));
+
+      TransactionManager mgr = TestingUtil.getTransactionManager(cache1);
+      mgr.begin();
+      cache1.getAdvancedCache().lock(k);
+      cache1.put(k, v);
+      cache1.getAdvancedCache().unlock(k);
+      mgr.commit();
+
+      assertEquals(v, cache1.get(k));
+      assertEquals("Should have replicated", v, cache2.get(k));
+
+      cache2.remove(k);
+      assert cache1.isEmpty();
+      assert cache2.isEmpty();
+   }
+}




More information about the infinispan-commits mailing list