IGNITE-51 - Fixed tests.

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

Branch: refs/heads/ignite-211
Commit: df777c3a27569280181e19ea1417b34486cbf788
Parents: dfba5bf
Author: Alexey Goncharuk <agoncha...@gridgain.com>
Authored: Mon Feb 9 18:21:06 2015 -0800
Committer: Alexey Goncharuk <agoncha...@gridgain.com>
Committed: Mon Feb 9 18:21:06 2015 -0800

----------------------------------------------------------------------
 .../GridCachePartitionExchangeManager.java      | 18 +++++++++--
 .../cache/GridCacheAffinityMapperSelfTest.java  | 17 ++++++++++
 .../dht/GridCacheAtomicFullApiSelfTest.java     | 18 +++++++++++
 .../near/GridCachePartitionedLockSelfTest.java  | 34 --------------------
 4 files changed, 51 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/df777c3a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 8f9fb92..42fcb4b 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -273,14 +273,28 @@ public class GridCachePartitionExchangeManager<K, V> 
extends GridCacheSharedMana
 
         U.join(exchWorker, log);
 
-        exchFuts = null;
-
         ResendTimeoutObject resendTimeoutObj = pendingResend.getAndSet(null);
 
         if (resendTimeoutObj != null)
             cctx.time().removeTimeoutObject(resendTimeoutObj);
     }
 
+    /** {@inheritDoc} */
+    @SuppressWarnings("LockAcquiredButNotSafelyReleased")
+    @Override protected void stop0(boolean cancel) {
+        super.stop0(cancel);
+
+        // Do not allow any activity in exchange manager after stop.
+        busyLock.writeLock().lock();
+
+        exchFuts = null;
+    }
+
+    /**
+     * @param cacheId Cache ID.
+     * @param exchId Exchange ID.
+     * @return Topology.
+     */
     public GridDhtPartitionTopology<K, V> clientTopology(int cacheId, 
GridDhtPartitionExchangeId exchId) {
         GridClientPartitionTopology<K, V> top = clientTops.get(cacheId);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/df777c3a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
index 89baa85..060491a 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 
 import java.util.*;
@@ -26,6 +27,16 @@ import java.util.*;
  * Test affinity mapper.
  */
 public class GridCacheAffinityMapperSelfTest extends GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrid();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
     /**
      *
      */
@@ -33,6 +44,8 @@ public class GridCacheAffinityMapperSelfTest extends 
GridCommonAbstractTest {
         CacheAffinityKeyMapper mapper =
             new GridCacheDefaultAffinityKeyMapper();
 
+        GridTestUtils.setFieldValue(mapper, "ignite", grid());
+
         List<CacheAffinityKey<Integer>> keys = new ArrayList<>();
 
         for (int i = 1; i <= 10; i++)
@@ -57,6 +70,8 @@ public class GridCacheAffinityMapperSelfTest extends 
GridCommonAbstractTest {
         CacheAffinityKeyMapper mapper =
             new GridCacheDefaultAffinityKeyMapper();
 
+        GridTestUtils.setFieldValue(mapper, "ignite", grid());
+
         List<FieldAffinityKey<Integer>> keys = new ArrayList<>();
 
         for (int i = 1; i <= 10; i++)
@@ -81,6 +96,8 @@ public class GridCacheAffinityMapperSelfTest extends 
GridCommonAbstractTest {
         CacheAffinityKeyMapper mapper =
             new GridCacheDefaultAffinityKeyMapper();
 
+        GridTestUtils.setFieldValue(mapper, "ignite", grid());
+
         FieldNoAffinityKey key = new FieldNoAffinityKey();
         Object mapped = mapper.affinityKey(key);
         assertEquals(key, mapped);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/df777c3a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java
index 0b4f048..cbbaeeb 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
 import org.apache.ignite.testframework.*;
 
+import javax.cache.*;
 import java.util.*;
 import java.util.concurrent.*;
 
@@ -71,6 +72,23 @@ public class GridCacheAtomicFullApiSelfTest extends 
GridCachePartitionedFullApiS
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testLock() throws Exception {
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                return jcache().lock("1").tryLock(Long.MAX_VALUE, 
TimeUnit.MILLISECONDS);
+            }
+        }, CacheException.class, "Locks are not supported");
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                return 
jcache().lockAll(Collections.singleton("1")).tryLock(Long.MAX_VALUE, 
TimeUnit.MILLISECONDS);
+            }
+        }, CacheException.class, "Locks are not supported");
+    }
+
+    /**
      * @throws Exception In case of error.
      */
     @Override public void testGetAll() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/df777c3a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java
index 5a79a5b..04934ce 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java
@@ -17,19 +17,12 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.near;
 
-import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.distributed.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.testframework.*;
 import org.apache.log4j.*;
 
-import javax.cache.*;
-import java.util.*;
-import java.util.concurrent.*;
-
 import static org.apache.ignite.cache.CacheMode.*;
 
 /**
@@ -56,31 +49,4 @@ public class GridCachePartitionedLockSelfTest extends 
GridCacheLockAbstractTest
     @Override protected boolean isPartitioned() {
         return true;
     }
-
-    /**
-     * @throws IgniteCheckedException If failed.
-     */
-    public void testLockAtomicCache() throws Exception {
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setGridName(getTestGridName(0));
-        cfg.setClientConnectionConfiguration(null);
-        cfg.setCacheConfiguration(new CacheConfiguration());
-
-        final Ignite g0 = G.start(cfg);
-
-        final IgniteCache<Object, Object> cache = g0.jcache(null);
-
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                return cache.lock(1).tryLock(Long.MAX_VALUE, 
TimeUnit.MILLISECONDS);
-            }
-        }, CacheException.class, "Locks are not supported");
-
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                return 
cache.lockAll(Collections.singleton(1)).tryLock(Long.MAX_VALUE, 
TimeUnit.MILLISECONDS);
-            }
-        }, CacheException.class, "Locks are not supported");
-    }
 }

Reply via email to