# IGNITE-56 Use IgniteCache instead of GridCache in the 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/0100a50c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0100a50c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0100a50c

Branch: refs/heads/ignite-51
Commit: 0100a50cd85fa46ff0a7127ec3e5f10769df7721
Parents: cd72342
Author: sevdokimov <sergey.evdoki...@jetbrains.com>
Authored: Sun Feb 8 13:39:03 2015 +0300
Committer: sevdokimov <sergey.evdoki...@jetbrains.com>
Committed: Sun Feb 8 13:39:03 2015 +0300

----------------------------------------------------------------------
 .../dht/GridCacheDhtInternalEntrySelfTest.java  |  2 +-
 .../GridCacheDhtPreloadDisabledSelfTest.java    | 16 ++++----
 .../dht/GridCacheDhtPreloadSelfTest.java        | 38 +++++++++----------
 .../GridCacheDhtPreloadStartStopSelfTest.java   | 26 ++++++-------
 ...ridCachePartitionedUnloadEventsSelfTest.java |  2 +-
 .../near/GridCacheNearReadersSelfTest.java      | 40 ++++++++++----------
 .../GridCachePartitionedAffinitySelfTest.java   |  2 +-
 .../GridCachePartitionedEvictionSelfTest.java   |  8 ++--
 ...achePartitionedMultiNodeFullApiSelfTest.java |  4 +-
 .../junits/common/GridCommonAbstractTest.java   | 38 ++++++++++++++++---
 10 files changed, 100 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
index d407ea2..0a0f6f6 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
@@ -173,7 +173,7 @@ public class GridCacheDhtInternalEntrySelfTest extends 
GridCommonAbstractTest {
      * @return DHT entry.
      */
     private GridDhtCacheEntry<Object, Object> peekDhtEntry(ClusterNode node) {
-        return (GridDhtCacheEntry<Object, 
Object>)dht(grid(node).cache(null)).peekEx(
+        return (GridDhtCacheEntry<Object, 
Object>)dht(grid(node).jcache(null)).peekEx(
             new GridCacheInternalKeyImpl(ATOMIC_LONG_NAME));
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
index 5981d07..6aa7639 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.junits.common.*;
 
+import javax.cache.*;
 import java.util.*;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.*;
@@ -115,7 +116,7 @@ public class GridCacheDhtPreloadDisabledSelfTest extends 
GridCommonAbstractTest
      * @return Topology.
      */
     private GridDhtPartitionTopology<Integer, String> topology(int i) {
-        return near(grid(i).<Integer, String>cache(null)).dht().topology();
+        return near(grid(i).<Integer, String>jcache(null)).dht().topology();
     }
 
     /** @throws Exception If failed. */
@@ -172,7 +173,7 @@ public class GridCacheDhtPreloadDisabledSelfTest extends 
GridCommonAbstractTest
         try {
             Ignite ignite1 = startGrid(0);
 
-            GridCache<Integer, String> cache1 = ignite1.cache(null);
+            IgniteCache<Integer, String> cache1 = ignite1.jcache(null);
 
             int keyCnt = 10;
 
@@ -182,12 +183,12 @@ public class GridCacheDhtPreloadDisabledSelfTest extends 
GridCommonAbstractTest
                 assertNull(near(cache1).peekEx(i));
                 assertNotNull((dht(cache1).peekEx(i)));
 
-                assertEquals(Integer.toString(i), cache1.peek(i));
+                assertEquals(Integer.toString(i), cache1.localPeek(i, 
CachePeekMode.ONHEAP));
             }
 
             int nodeCnt = 3;
 
-            List<Ignite> ignites = new ArrayList<>(nodeCnt);
+            Collection<Ignite> ignites = new ArrayList<>(nodeCnt);
 
             startGrids(nodeCnt, 1, ignites);
 
@@ -202,7 +203,7 @@ public class GridCacheDhtPreloadDisabledSelfTest extends 
GridCommonAbstractTest
             Collection<Integer> keys = new LinkedList<>();
 
             for (int i = 0; i < keyCnt; i++)
-                if 
(cache1.affinity().mapKeyToNode(i).equals(ignite1.cluster().localNode()))
+                if 
(ignite1.affinity(null).mapKeyToNode(i).equals(ignite1.cluster().localNode()))
                     keys.add(i);
 
             info(">>> Finished checking nodes [keyCnt=" + keyCnt + ", 
nodeCnt=" + nodeCnt + ", grids=" +
@@ -225,7 +226,7 @@ public class GridCacheDhtPreloadDisabledSelfTest extends 
GridCommonAbstractTest
             }
 
             for (Integer i : keys)
-                assertEquals(i.toString(), cache1.peek(i));
+                assertEquals(i.toString(), cache1.localPeek(i, 
CachePeekMode.ONHEAP));
         }
         catch (Error | Exception e) {
             error("Test failed.", e);
@@ -269,9 +270,8 @@ public class GridCacheDhtPreloadDisabledSelfTest extends 
GridCommonAbstractTest
     /**
      * @param c Cache.
      * @param cnt Key count.
-     * @throws IgniteCheckedException If failed.
      */
-    private void putKeys(GridCache<Integer, String> c, int cnt) throws 
IgniteCheckedException {
+    private void putKeys(Cache<Integer, String> c, int cnt) {
         for (int i = 0; i < cnt; i++)
             c.put(i, Integer.toString(i));
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java
index 74cdfb9..d75d971 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java
@@ -35,10 +35,10 @@ import org.apache.ignite.testframework.junits.common.*;
 
 import java.util.*;
 
-import static org.apache.ignite.configuration.CacheConfiguration.*;
 import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.cache.CachePreloadMode.*;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+import static org.apache.ignite.configuration.CacheConfiguration.*;
 import static org.apache.ignite.configuration.DeploymentMode.*;
 import static org.apache.ignite.events.EventType.*;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.*;
@@ -145,8 +145,8 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
      * @return Affinity.
      */
     @SuppressWarnings({"unchecked"})
-    private CacheAffinity<Integer> affinity(GridCache<Integer, ?> cache) {
-        return cache.affinity();
+    private CacheAffinity<Integer> affinity(IgniteCache<Integer, ?> cache) {
+        return cache.unwrap(Ignite.class).affinity(cache.getName());
     }
 
     /**
@@ -223,7 +223,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
         try {
             Ignite ignite1 = startGrid(0);
 
-            GridCache<Integer, String> cache1 = ignite1.cache(null);
+            IgniteCache<Integer, String> cache1 = ignite1.jcache(null);
 
             putKeys(cache1, keyCnt);
             checkKeys(cache1, keyCnt, F.asList(ignite1));
@@ -234,7 +234,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
 
             // Check all nodes.
             for (Ignite g : ignites) {
-                GridCache<Integer, String> c = g.cache(null);
+                IgniteCache<Integer, String> c = g.jcache(null);
 
                 checkKeys(c, keyCnt, ignites);
             }
@@ -309,7 +309,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
 
             assert last != null;
 
-            GridCache<Integer, String> lastCache = last.cache(null);
+            IgniteCache<Integer, String> lastCache = last.jcache(null);
 
             GridDhtCacheAdapter<Integer, String> dht = dht(lastCache);
 
@@ -350,7 +350,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
     private void checkActiveState(Iterable<Ignite> grids) {
         // Check that nodes don't have non-active information about other 
nodes.
         for (Ignite g : grids) {
-            GridCache<Integer, String> c = g.cache(null);
+            IgniteCache<Integer, String> c = g.jcache(null);
 
             GridDhtCacheAdapter<Integer, String> dht = dht(c);
 
@@ -493,7 +493,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
         try {
             Ignite ignite1 = startGrid(0);
 
-            GridCache<Integer, String> cache1 = ignite1.cache(null);
+            IgniteCache<Integer, String> cache1 = ignite1.jcache(null);
 
             putKeys(cache1, keyCnt);
             checkKeys(cache1, keyCnt, F.asList(ignite1));
@@ -504,7 +504,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
 
             // Check all nodes.
             for (Ignite g : ignites) {
-                GridCache<Integer, String> c = g.cache(null);
+                IgniteCache<Integer, String> c = g.jcache(null);
 
                 checkKeys(c, keyCnt, ignites);
             }
@@ -567,7 +567,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
 
                 // Check all left nodes.
                 for (Ignite gg : ignites) {
-                    GridCache<Integer, String> c = gg.cache(null);
+                    IgniteCache<Integer, String> c = gg.jcache(null);
 
                     checkKeys(c, keyCnt, ignites);
                 }
@@ -575,7 +575,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
 
             assert last != null;
 
-            GridCache<Integer, String> lastCache = last.cache(null);
+            IgniteCache<Integer, String> lastCache = last.jcache(null);
 
             GridDhtCacheAdapter<Integer, String> dht = dht(lastCache);
 
@@ -609,9 +609,8 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
     /**
      * @param c Cache.
      * @param cnt Key count.
-     * @throws IgniteCheckedException If failed.
      */
-    private void putKeys(GridCache<Integer, String> c, int cnt) throws 
IgniteCheckedException {
+    private void putKeys(IgniteCache<Integer, String> c, int cnt) {
         for (int i = 0; i < cnt; i++)
             c.put(i, Integer.toString(i));
     }
@@ -620,16 +619,15 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
      * @param cache Cache.
      * @param cnt Key count.
      * @param grids Grids.
-     * @throws IgniteCheckedException If failed.
      */
-    private void checkKeys(GridCache<Integer, String> cache, int cnt, 
Iterable<Ignite> grids) throws IgniteCheckedException {
+    private void checkKeys(IgniteCache<Integer, String> cache, int cnt, 
Iterable<Ignite> grids) {
         CacheAffinity<Integer> aff = affinity(cache);
 
-        Ignite ignite = cache.gridProjection().ignite();
+        Ignite ignite = cache.unwrap(Ignite.class);
 
         ClusterNode loc = ignite.cluster().localNode();
 
-        boolean sync = cache.configuration().getPreloadMode() == SYNC;
+        boolean sync = 
cache.getConfiguration(CacheConfiguration.class).getPreloadMode() == SYNC;
 
         for (int i = 0; i < cnt; i++) {
             Collection<ClusterNode> nodes = ignite.cluster().nodes();
@@ -639,7 +637,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
             assert !affNodes.isEmpty();
 
             if (affNodes.contains(loc)) {
-                String val = sync ? cache.peek(i) : cache.get(i);
+                String val = sync ? cache.localPeek(i, CachePeekMode.ONHEAP) : 
cache.get(i);
 
                 ClusterNode primaryNode = F.first(affNodes);
 
@@ -648,7 +646,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
                 boolean primary = primaryNode.equals(loc);
 
                 assert Integer.toString(i).equals(val) : "Key check failed 
[grid=" + ignite.name() +
-                    ", cache=" + cache.name() + ", key=" + i + ", expected=" + 
i + ", actual=" + val +
+                    ", cache=" + cache.getName() + ", key=" + i + ", 
expected=" + i + ", actual=" + val +
                     ", part=" + aff.partition(i) + ", primary=" + primary + ", 
affNodes=" + U.nodeIds(affNodes) +
                     ", locId=" + loc.id() + ", allNodes=" + U.nodeIds(nodes) + 
", allParts=" + top2string(grids) + ']';
             }
@@ -664,7 +662,7 @@ public class GridCacheDhtPreloadSelfTest extends 
GridCommonAbstractTest {
         Map<String, String> map = new HashMap<>();
 
         for (Ignite g : grids) {
-            GridCache<Integer, String> c = g.cache(null);
+            IgniteCache<Integer, String> c = g.jcache(null);
 
             GridDhtCacheAdapter<Integer, String> dht = dht(c);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java
index 17d3dda..cc788ed 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java
@@ -33,9 +33,9 @@ import org.apache.ignite.testframework.junits.common.*;
 import java.util.*;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.configuration.CacheConfiguration.*;
 import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.cache.CachePreloadMode.*;
+import static org.apache.ignite.configuration.CacheConfiguration.*;
 import static org.apache.ignite.configuration.DeploymentMode.*;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.*;
 
@@ -134,16 +134,16 @@ public class GridCacheDhtPreloadStartStopSelfTest extends 
GridCommonAbstractTest
      * @param cache Cache.
      * @return Affinity.
      */
-    private CacheAffinity<Integer> affinity(GridCache<Integer, ?> cache) {
-        return cache.affinity();
+    private CacheAffinity<Integer> affinity(IgniteCache<Integer, ?> cache) {
+        return cache.unwrap(Ignite.class).affinity(null);
     }
 
     /**
      * @param c Cache.
      * @return {@code True} if synchronoous preloading.
      */
-    private boolean isSync(GridCache<?, ?> c) {
-        return c.configuration().getPreloadMode() == SYNC;
+    private boolean isSync(IgniteCache<?, ?> c) {
+        return c.getConfiguration(CacheConfiguration.class).getPreloadMode() 
== SYNC;
     }
 
     /**
@@ -187,7 +187,7 @@ public class GridCacheDhtPreloadStartStopSelfTest extends 
GridCommonAbstractTest
         try {
             Ignite g1 = startGrid(0);
 
-            GridCache<Integer, String> c1 = g1.cache(null);
+            IgniteCache<Integer, String> c1 = g1.jcache(null);
 
             putKeys(c1, keyCnt);
             checkKeys(c1, keyCnt);
@@ -198,7 +198,7 @@ public class GridCacheDhtPreloadStartStopSelfTest extends 
GridCommonAbstractTest
 
             // Check all nodes.
             for (Ignite g : ignites) {
-                GridCache<Integer, String> c = g.cache(null);
+                IgniteCache<Integer, String> c = g.jcache(null);
 
                 checkKeys(c, keyCnt);
             }
@@ -237,9 +237,8 @@ public class GridCacheDhtPreloadStartStopSelfTest extends 
GridCommonAbstractTest
     /**
      * @param c Cache.
      * @param cnt Key count.
-     * @throws IgniteCheckedException If failed.
      */
-    private void putKeys(GridCache<Integer, String> c, int cnt) throws 
IgniteCheckedException {
+    private void putKeys(IgniteCache<Integer, String> c, int cnt) {
         for (int i = 0; i < cnt; i++)
             c.put(i, Integer.toString(i));
     }
@@ -247,20 +246,19 @@ public class GridCacheDhtPreloadStartStopSelfTest extends 
GridCommonAbstractTest
     /**
      * @param c Cache.
      * @param cnt Key count.
-     * @throws IgniteCheckedException If failed.
      */
-    private void checkKeys(GridCache<Integer, String> c, int cnt) throws 
IgniteCheckedException {
+    private void checkKeys(IgniteCache<Integer, String> c, int cnt) {
         CacheAffinity<Integer> aff = affinity(c);
 
         boolean sync = isSync(c);
 
-        Ignite ignite = c.gridProjection().ignite();
+        Ignite ignite = c.unwrap(Ignite.class);
 
         for (int i = 0; i < cnt; i++) {
             if 
(aff.mapPartitionToPrimaryAndBackups(aff.partition(i)).contains(ignite.cluster().localNode()))
 {
-                String val = sync ? c.peek(i) : c.get(i);
+                String val = sync ? c.localPeek(i, CachePeekMode.ONHEAP) : 
c.get(i);
 
-                assertEquals("Key check failed [grid=" + ignite.name() + ", 
cache=" + c.name() + ", key=" + i + ']',
+                assertEquals("Key check failed [grid=" + ignite.name() + ", 
cache=" + c.getName() + ", key=" + i + ']',
                     Integer.toString(i), val);
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java
index 28ba265..dd78950 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java
@@ -100,7 +100,7 @@ public class GridCachePartitionedUnloadEventsSelfTest 
extends GridCommonAbstract
         Collection <Event> partEvts =
             g1.events().localQuery(F.<Event>alwaysTrue(), 
EVT_CACHE_PRELOAD_PART_UNLOADED);
 
-        checkPartitionUnloadEvents(partEvts, g1, 
dht(g2.cache(null)).topology().localPartitions());
+        checkPartitionUnloadEvents(partEvts, g1, 
dht(g2.jcache(null)).topology().localPartitions());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
index 8b2a651..c52a27f 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
@@ -140,12 +140,12 @@ public class GridCacheNearReadersSelfTest extends 
GridCommonAbstractTest {
         Ignite g1 = grid(n1.id());
         Ignite g2 = grid(n2.id());
 
-        GridCache<Integer, String> cache1 = g1.cache(null);
-        GridCache<Integer, String> cache2 = g2.cache(null);
+        IgniteCache<Integer, String> cache1 = g1.jcache(null);
+        IgniteCache<Integer, String> cache2 = g2.jcache(null);
 
         // Store some values in cache.
-        assertNull(cache1.put(1, "v1"));
-        assertNull(cache1.put(2, "v2"));
+        assertNull(cache1.getAndPut(1, "v1"));
+        assertNull(cache1.getAndPut(2, "v2"));
 
         GridDhtCacheEntry<Integer, String> e1 = (GridDhtCacheEntry<Integer, 
String>)dht(cache1).entryEx(1);
         GridDhtCacheEntry<Integer, String> e2 = (GridDhtCacheEntry<Integer, 
String>)dht(cache2).entryEx(2);
@@ -180,7 +180,7 @@ public class GridCacheNearReadersSelfTest extends 
GridCommonAbstractTest {
         assertTrue(e1.readers().contains(n2.id()));
 
         // Evict locally from cache2.
-        assertTrue(cache2.evict(1));
+        cache2.localEvict(Collections.singleton(1));
 
         assertNull(near(cache2).peek(1));
         assertNull(dht(cache2).peek(1));
@@ -188,7 +188,7 @@ public class GridCacheNearReadersSelfTest extends 
GridCommonAbstractTest {
         // Node 1 still has node2 in readers map.
         assertTrue(e1.readers().contains(n2.id()));
 
-        assertNotNull((cache1.put(1, "z1")));
+        assertNotNull((cache1.getAndPut(1, "z1")));
 
         // Node 1 still has node2 in readers map.
         assertFalse(e1.readers().contains(n2.id()));
@@ -218,17 +218,17 @@ public class GridCacheNearReadersSelfTest extends 
GridCommonAbstractTest {
         ((IgniteKernal)g1).internalCache(null).preloader().request(F.asList(1, 
2), 2).get();
         ((IgniteKernal)g2).internalCache(null).preloader().request(F.asList(1, 
2), 2).get();
 
-        GridCache<Integer, String> cache1 = g1.cache(null);
-        GridCache<Integer, String> cache2 = g2.cache(null);
+        IgniteCache<Integer, String> cache1 = g1.jcache(null);
+        IgniteCache<Integer, String> cache2 = g2.jcache(null);
 
-        assertEquals(cache1.affinity().mapKeyToNode(1), 
g1.cluster().localNode());
-        
assertFalse(cache1.affinity().mapKeyToNode(2).equals(g1.cluster().localNode()));
+        assertEquals(g1.affinity(null).mapKeyToNode(1), 
g1.cluster().localNode());
+        
assertFalse(g1.affinity(null).mapKeyToNode(2).equals(g1.cluster().localNode()));
 
-        assertEquals(cache2.affinity().mapKeyToNode(2), 
g2.cluster().localNode());
-        
assertFalse(cache2.affinity().mapKeyToNode(1).equals(g2.cluster().localNode()));
+        assertEquals(g1.affinity(null).mapKeyToNode(2), 
g2.cluster().localNode());
+        
assertFalse(g2.affinity(null).mapKeyToNode(1).equals(g2.cluster().localNode()));
 
         // Store first value in cache.
-        assertNull(cache1.put(1, "v1"));
+        assertNull(cache1.getAndPut(1, "v1"));
 
         assertTrue(cache1.containsKey(1));
         assertTrue(cache2.containsKey(1));
@@ -244,7 +244,7 @@ public class GridCacheNearReadersSelfTest extends 
GridCommonAbstractTest {
         GridDhtCacheEntry<Integer, String> e1 = (GridDhtCacheEntry<Integer, 
String>)dht(cache1).entryEx(1);
 
         // Store second value in cache.
-        assertNull(cache1.put(2, "v2"));
+        assertNull(cache1.getAndPut(2, "v2"));
 
         assertTrue(cache1.containsKey(2));
         assertTrue(cache2.containsKey(2));
@@ -274,12 +274,12 @@ public class GridCacheNearReadersSelfTest extends 
GridCommonAbstractTest {
 
         // Evict locally from cache2.
         // It should not be successful since it's not allowed to evict entry 
on backup node.
-        assertFalse(cache2.evict(1));
+        cache2.localEvict(Collections.singleton(1));
 
         assertNull(near(cache2).peekNearOnly(1));
         assertEquals("v1", dht(cache2).peek(1));
 
-        assertEquals("v1", cache1.put(1, "z1"));
+        assertEquals("v1", cache1.getAndPut(1, "z1"));
 
         // Node 1 should not have node2 in readers map.
         assertFalse(e1.readers().contains(n2.id()));
@@ -391,11 +391,11 @@ public class GridCacheNearReadersSelfTest extends 
GridCommonAbstractTest {
 
         assertFalse("Nodes cannot be equal: " + primary, 
primary.equals(backup));
 
-        GridCache<Integer, String> cache1 = grid(primary.id()).cache(null);
-        GridCache<Integer, String> cache2 = grid(backup.id()).cache(null);
+        IgniteCache<Integer, String> cache1 = grid(primary.id()).jcache(null);
+        IgniteCache<Integer, String> cache2 = grid(backup.id()).jcache(null);
 
         // Store a values in cache.
-        assertNull(cache1.put(1, "v1"));
+        assertNull(cache1.getAndPut(1, "v1"));
 
         GridDhtCacheEntry<Integer, String> e1 = (GridDhtCacheEntry<Integer, 
String>)dht(cache1).peekEx(1);
         GridDhtCacheEntry<Integer, String> e2 = (GridDhtCacheEntry<Integer, 
String>)dht(cache2).peekEx(1);
@@ -577,7 +577,7 @@ public class GridCacheNearReadersSelfTest extends 
GridCommonAbstractTest {
                 assertNull(near(2).peekEx(key2));
             }
             finally {
-                lock2.lock();
+                lock2.unlock();
             }
         }
         finally {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java
index 46b9ed2..f6b1deb 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java
@@ -379,7 +379,7 @@ public class GridCachePartitionedAffinitySelfTest extends 
GridCommonAbstractTest
     /** @param g Grid. */
     private static void partitionMap(Ignite g) {
         X.println(">>> Full partition map for grid: " + g.name());
-        X.println(">>> " + 
dht(g.cache(null)).topology().partitionMap(false).toFullString());
+        X.println(">>> " + 
dht(g.jcache(null)).topology().partitionMap(false).toFullString());
     }
 
     /** @throws Exception If failed. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java
index 7cef4d9..22228d9 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java
@@ -165,8 +165,8 @@ public class GridCachePartitionedEvictionSelfTest extends 
GridCacheAbstractSelfT
         // This condition should be "true", otherwise the test doesn't make 
sense.
         assert KEY_CNT >= EVICT_CACHE_SIZE;
 
-        GridDhtCacheAdapter<String, Integer> dht0 = dht(cache(0));
-        GridDhtCacheAdapter<String, Integer> dht1 = dht(cache(1));
+        GridDhtCacheAdapter<String, Integer> dht0 = dht(jcache(0));
+        GridDhtCacheAdapter<String, Integer> dht1 = dht(jcache(1));
 
         CacheAffinity<String> aff = dht0.affinity();
 
@@ -209,7 +209,7 @@ public class GridCachePartitionedEvictionSelfTest extends 
GridCacheAbstractSelfT
         assertEquals(EVICT_CACHE_SIZE, dht0.size());
         assertEquals(EVICT_CACHE_SIZE, dht1.size());
 
-        assertEquals(0, near(cache(0)).nearSize());
-        assertEquals(0, near(cache(1)).nearSize());
+        assertEquals(0, near(jcache(0)).nearSize());
+        assertEquals(0, near(jcache(1)).nearSize());
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index 744b62c..459be63 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -227,7 +227,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest 
extends GridCacheParti
         jcache().put("key", 1);
 
         for (int i = 0; i < gridCount(); i++) {
-            boolean nearEnabled = nearEnabled(cache(i));
+            boolean nearEnabled = nearEnabled(jcache(i));
 
             Integer nearPeekVal = nearEnabled ? 1 : null;
 
@@ -264,7 +264,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest 
extends GridCacheParti
         jcache().put("key", 1);
 
         for (int i = 0; i < gridCount(); i++) {
-            boolean nearEnabled = nearEnabled(cache(i));
+            boolean nearEnabled = nearEnabled(jcache(i));
 
             Integer nearPeekVal = nearEnabled ? 1 : null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0100a50c/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
 
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 9a723a4..e01da76 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -126,12 +126,21 @@ public abstract class GridCommonAbstractTest extends 
GridAbstractTest {
      * @param cache Cache.
      * @return DHT cache.
      */
-    protected static <K, V> GridDhtCacheAdapter<K, V> dht(CacheProjection<K,V> 
cache) {
+    protected static <K, V> GridDhtCacheAdapter<K, V> dht(GridCache<K,V> 
cache) {
         return nearEnabled(cache) ? near(cache).dht() :
             ((IgniteKernal)cache.gridProjection().ignite()).<K, 
V>internalCache(cache.name()).context().dht();
     }
 
     /**
+     * @param cache Cache.
+     * @return DHT cache.
+     */
+    protected static <K, V> GridDhtCacheAdapter<K, V> dht(IgniteCache<K,V> 
cache) {
+        return nearEnabled(cache) ? near(cache).dht() :
+            ((IgniteKernal)cache.unwrap(Ignite.class)).<K, 
V>internalCache(cache.getName()).context().dht();
+    }
+
+    /**
      * @return DHT cache.
      */
     protected <K, V> GridDhtCacheAdapter<K, V> dht() {
@@ -168,7 +177,7 @@ public abstract class GridCommonAbstractTest extends 
GridAbstractTest {
      * @param cache Cache.
      * @return {@code True} if near cache is enabled.
      */
-    protected static <K, V> boolean nearEnabled(CacheProjection<K,V> cache) {
+    protected static <K, V> boolean nearEnabled(GridCache<K,V> cache) {
         CacheConfiguration cfg = 
((IgniteKernal)cache.gridProjection().ignite()).
             <K, V>internalCache(cache.name()).context().config();
 
@@ -177,18 +186,37 @@ public abstract class GridCommonAbstractTest extends 
GridAbstractTest {
 
     /**
      * @param cache Cache.
+     * @return {@code True} if near cache is enabled.
+     */
+    protected static <K, V> boolean nearEnabled(IgniteCache<K,V> cache) {
+        CacheConfiguration cfg = ((IgniteKernal)cache.unwrap(Ignite.class)).
+            <K, V>internalCache(cache.getName()).context().config();
+
+        return isNearEnabled(cfg);
+    }
+
+    /**
+     * @param cache Cache.
      * @return Near cache.
      */
-    protected static <K, V> GridNearCacheAdapter<K, V> 
near(CacheProjection<K,V> cache) {
+    protected static <K, V> GridNearCacheAdapter<K, V> near(GridCache<K,V> 
cache) {
         return ((IgniteKernal)cache.gridProjection().ignite()).<K, 
V>internalCache(cache.name()).context().near();
     }
 
     /**
      * @param cache Cache.
+     * @return Near cache.
+     */
+    protected static <K, V> GridNearCacheAdapter<K, V> near(IgniteCache<K,V> 
cache) {
+        return ((IgniteKernal)cache.unwrap(Ignite.class)).<K, 
V>internalCache(cache.getName()).context().near();
+    }
+
+    /**
+     * @param cache Cache.
      * @return Colocated cache.
      */
-    protected static <K, V> GridDhtColocatedCache<K, V> 
colocated(CacheProjection<K,V> cache) {
-        return ((IgniteKernal)cache.gridProjection().ignite()).<K, 
V>internalCache(cache.name()).context().colocated();
+    protected static <K, V> GridDhtColocatedCache<K, V> 
colocated(IgniteCache<K,V> cache) {
+        return ((IgniteKernal)cache.unwrap(Ignite.class)).<K, 
V>internalCache(cache.getName()).context().colocated();
     }
 
     /**

Reply via email to