ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: Added test for cache.lock.
Date Fri, 21 Aug 2015 13:44:23 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/master 0283580c3 -> 653d411ca


Added test for cache.lock.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/653d411c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/653d411c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/653d411c

Branch: refs/heads/master
Commit: 653d411ca243494cc5e2ff09cf879103856d5a8a
Parents: 0283580
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Aug 21 16:44:15 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Aug 21 16:44:15 2015 +0300

----------------------------------------------------------------------
 .../GridCacheMultiNodeLockAbstractTest.java     | 41 +++++++++++++++++++-
 ...idCachePartitionedMultiNodeLockSelfTest.java |  8 +---
 ...ridCacheReplicatedMultiNodeLockSelfTest.java |  8 +---
 3 files changed, 44 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/653d411c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
index 8f107e4..013dd74 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
@@ -41,6 +41,12 @@ import static org.apache.ignite.events.EventType.*;
  * Test cases for multi-threaded tests.
  */
 public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstractTest {
+    /** */
+    private static final String CACHE1 = null;
+
+    /** */
+    private static final String CACHE2 = "cache2";
+
     /** Grid 1. */
     private static Ignite ignite1;
 
@@ -70,12 +76,20 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
 
         cfg.setDiscoverySpi(disco);
 
-        cfg.setCacheConfiguration(defaultCacheConfiguration());
+        CacheConfiguration ccfg1 = cacheConfiguration().setName(CACHE1);
+        CacheConfiguration ccfg2 = cacheConfiguration().setName(CACHE2);
+
+        cfg.setCacheConfiguration(ccfg1, ccfg2);
 
         return cfg;
     }
 
     /**
+     * @return Cache configuration.
+     */
+    protected abstract CacheConfiguration cacheConfiguration();
+
+    /**
      * @return {@code True} for partitioned caches.
      */
     protected boolean partitioned() {
@@ -529,6 +543,31 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testTwoCaches() throws Exception {
+        IgniteCache<Integer, String> cache1 = ignite1.cache(CACHE1);
+        IgniteCache<Integer, String> cache2 = ignite1.cache(CACHE2);
+
+        final Integer key = primaryKey(cache1);
+
+        Lock lock = cache1.lock(key);
+
+        lock.lock();
+
+        try {
+            assertTrue(cache1.isLocalLocked(key, true));
+            assertTrue(cache1.isLocalLocked(key, false));
+
+            assertFalse(cache2.isLocalLocked(key, true));
+            assertFalse(cache2.isLocalLocked(key, false));
+        }
+        finally {
+            lock.unlock();
+        }
+    }
+
+    /**
      * Cache unlock listener.
      */
     private class UnlockListener implements IgnitePredicate<Event> {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/653d411c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java
index a782aec..bbc56e4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java
@@ -29,9 +29,7 @@ import static org.apache.ignite.cache.CacheMode.*;
  */
 public class GridCachePartitionedMultiNodeLockSelfTest extends GridCacheMultiNodeLockAbstractTest
{
     /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
-        IgniteConfiguration c = super.getConfiguration(gridName);
-
+    @Override protected CacheConfiguration cacheConfiguration() {
         CacheConfiguration cc = defaultCacheConfiguration();
 
         cc.setCacheMode(PARTITIONED);
@@ -39,9 +37,7 @@ public class GridCachePartitionedMultiNodeLockSelfTest extends GridCacheMultiNod
         cc.setAtomicityMode(TRANSACTIONAL);
         cc.setNearConfiguration(new NearCacheConfiguration());
 
-        c.setCacheConfiguration(cc);
-
-        return c;
+        return cc;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/653d411c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeLockSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeLockSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeLockSelfTest.java
index 70e0ad6..bf3620b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeLockSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeLockSelfTest.java
@@ -32,15 +32,11 @@ public class GridCacheReplicatedMultiNodeLockSelfTest extends GridCacheMultiNode
     }
 
     /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration() throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration();
-
+    @Override protected CacheConfiguration cacheConfiguration() {
         CacheConfiguration cacheCfg = defaultCacheConfiguration();
 
         cacheCfg.setCacheMode(REPLICATED);
 
-        cfg.setCacheConfiguration(cacheCfg);
-
-        return cfg;
+        return cacheCfg;
     }
 }


Mime
View raw message