ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [11/11] incubator-ignite git commit: IGNITE-59 Add test to check cancelling lock.
Date Tue, 27 Jan 2015 15:19:27 GMT
IGNITE-59 Add test to check cancelling 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/3647e88e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3647e88e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3647e88e

Branch: refs/heads/ignite-59
Commit: 3647e88e647d3b7c97920c43f2f0afa22027cb73
Parents: 74b1501
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Tue Jan 27 18:19:02 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Tue Jan 27 18:19:02 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheBasicApiAbstractTest.java    | 62 ++++++++++++--------
 .../near/GridCachePartitionedBasicApiTest.java  |  4 +-
 .../GridCacheReplicatedBasicApiTest.java        |  4 +-
 .../local/GridCacheLocalBasicApiSelfTest.java   |  4 +-
 4 files changed, 45 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3647e88e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
index 4b34bd2..e1d1441 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.testframework.junits.common.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.expiry.*;
+import javax.swing.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
@@ -55,8 +56,8 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
     }
 
     /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration() throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration();
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
 
         TcpDiscoverySpi disco = new TcpDiscoverySpi();
 
@@ -209,40 +210,55 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
     /**
      *
      */
-    public void testInterruptLockWithTimeout() throws InterruptedException {
+    public void testInterruptLockWithTimeout() throws Exception {
         final IgniteCache<Integer, String> cache = ignite.jcache(null);
 
-        Lock lock2 = cache.lock(2);
+        startGrid(1);
 
-        lock2.lock();
+        try {
+            final List<Integer> keys = primaryKeys(grid(1).jcache(null), 2, 1);
 
-        final AtomicBoolean isOk = new AtomicBoolean(false);
+            Lock lock1 = cache.lock(keys.get(1));
 
-        Thread t = new Thread(new Runnable() {
-            @Override public void run() {
-                try {
-                    cache.lockAll(Arrays.asList(1, 2)).tryLock(5000, MILLISECONDS);
-                }
-                catch (InterruptedException ignored) {
-                    isOk.set(true);
+            lock1.lock();
+
+            final AtomicBoolean isOk = new AtomicBoolean(false);
+
+            Thread t = new Thread(new Runnable() {
+                @Override public void run() {
+                    try {
+                        cache.lockAll(Arrays.asList(keys.get(0), keys.get(1))).tryLock(50000,
MILLISECONDS);
+                    }
+                    catch (InterruptedException ignored) {
+                        isOk.set(true);
+                    }
                 }
-            }
-        });
+            });
 
-        t.start();
+            t.start();
 
-        Thread.sleep(100);
+            JOptionPane.showConfirmDialog(null, "wait");
+            Thread.sleep(100);
 
-        t.interrupt();
+            t.interrupt();
 
-        t.join();
+            t.join();
 
-        lock2.unlock();
+            lock1.unlock();
 
-        assertFalse(cache.isLocalLocked(1, false));
-        assertFalse(cache.isLocalLocked(2, false));
+            Thread.sleep(1000);
 
-        assertTrue(isOk.get());
+            assertFalse(cache.isLocalLocked(keys.get(0), false));
+            assertFalse(cache.isLocalLocked(keys.get(1), false));
+
+            assertFalse(grid(1).jcache(null).isLocalLocked(keys.get(0), false));
+            assertFalse(grid(1).jcache(null).isLocalLocked(keys.get(1), false));
+
+            assertTrue(isOk.get());
+        }
+        finally {
+            stopGrid(1);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3647e88e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicApiTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicApiTest.java
index 31621ee..3b471b7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicApiTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicApiTest.java
@@ -30,8 +30,8 @@ import static org.apache.ignite.cache.CacheDistributionMode.*;
  */
 public class GridCachePartitionedBasicApiTest extends GridCacheBasicApiAbstractTest {
     /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration() throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration();
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
 
         CacheConfiguration cacheCfg = defaultCacheConfiguration();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3647e88e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedBasicApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedBasicApiTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedBasicApiTest.java
index fb51586..bfed00f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedBasicApiTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedBasicApiTest.java
@@ -28,8 +28,8 @@ import static org.apache.ignite.cache.CacheMode.*;
  */
 public class GridCacheReplicatedBasicApiTest extends GridCacheBasicApiAbstractTest {
     /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration() throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration();
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
 
         CacheConfiguration cacheCfg = defaultCacheConfiguration();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3647e88e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicApiSelfTest.java
index e04a95d..4f73952 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicApiSelfTest.java
@@ -28,8 +28,8 @@ import static org.apache.ignite.cache.CacheMode.*;
  */
 public class GridCacheLocalBasicApiSelfTest extends GridCacheBasicApiAbstractTest {
     /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration() throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration();
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
 
         CacheConfiguration cacheCfg = defaultCacheConfiguration();
 


Mime
View raw message