From 2c2204d6d942e829cbc93d6cd16c6ba289088998 Mon Sep 17 00:00:00 2001 From: sevdokimov Date: Mon, 9 Feb 2015 18:42:04 +0300 Subject: [PATCH] # IGNITE-56 Migration tests to IgniteCache --- .../GridCacheClientModesAbstractSelfTest.java | 16 +++++++------- .../GridCacheEntrySetAbstractSelfTest.java | 15 ++++++------- .../GridCacheEventAbstractTest.java | 22 ------------------- .../GridCacheMixedModeSelfTest.java | 5 +++-- .../near/GridCacheNearOnlySelfTest.java | 5 +++-- 5 files changed, 21 insertions(+), 42 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java index 014c96ab0002d..a632d37ecc4bc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java @@ -97,7 +97,7 @@ public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbst * @throws Exception If failed. */ public void testPutFromClientNode() throws Exception { - GridCache nearOnly = nearOnlyCache(); + IgniteCache nearOnly = nearOnlyCache(); for (int i = 0; i < 5; i++) nearOnly.put(i, i); @@ -113,7 +113,7 @@ public void testPutFromClientNode() throws Exception { if (nearEnabled()) assertEquals(key, nearOnly.peek(key)); - assertNull(nearOnly.peek(key, F.asList(GridCachePeekMode.PARTITIONED_ONLY))); + assertNull(nearOnly.localPeek(key, CachePeekMode.PRIMARY, CachePeekMode.BACKUP)); } } @@ -121,12 +121,12 @@ public void testPutFromClientNode() throws Exception { * @throws Exception If failed. */ public void testGetFromClientNode() throws Exception { - GridCache dht = dhtCache(); + IgniteCache dht = dhtCache(); for (int i = 0; i < 10; i++) dht.put(i, i); - GridCache nearOnly = nearOnlyCache(); + IgniteCache nearOnly = nearOnlyCache(); assert dht != nearOnly; @@ -189,19 +189,19 @@ public void testNearOnlyAffinity() throws Exception { /** * @return Near only cache for this test. */ - protected GridCache nearOnlyCache() { + protected IgniteCache nearOnlyCache() { assert nearOnlyGridName != null; - return G.ignite(nearOnlyGridName).cache(null); + return G.ignite(nearOnlyGridName).jcache(null); } /** * @return DHT cache for this test. */ - protected GridCache dhtCache() { + protected IgniteCache dhtCache() { for (int i = 0; i < gridCount(); i++) { if (!nearOnlyGridName.equals(grid(i).name())) - return grid(i).cache(null); + return grid(i).jcache(null); } assert false : "Cannot find DHT cache for this test."; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java index 7c0377beba7ec..31e6cd6eedbd8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache.distributed; +import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.testframework.*; @@ -72,7 +73,7 @@ public void testEntrySet() throws Exception { log.info("Use cache " + idx); - GridCache cache = grid(idx).cache(null); + IgniteCache cache = grid(idx).jcache(null); for (int i = 0; i < 100; i++) putAndCheckEntrySet(cache); @@ -90,8 +91,8 @@ public void testEntrySet() throws Exception { * @param cache Cache. * @throws Exception If failed. */ - private void putAndCheckEntrySet(GridCache cache) throws Exception { - try (IgniteTx tx = cache.txStart(PESSIMISTIC, REPEATABLE_READ)) { + private void putAndCheckEntrySet(IgniteCache cache) throws Exception { + try (IgniteTx tx = cache.unwrap(Ignite.class).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { Integer total = (Integer) cache.get(TX_KEY); if (total == null) @@ -99,18 +100,16 @@ private void putAndCheckEntrySet(GridCache cache) throws Excepti int cntr = 0; - Set> entries = cache.entrySet(); - - for (Cache.Entry e : entries) { + for (Cache.Entry e : cache) { if (e.getKey() instanceof Integer) cntr++; } assertEquals(total, (Integer)cntr); - cache.putx(cntr + 1, cntr + 1); + cache.put(cntr + 1, cntr + 1); - cache.putx(TX_KEY, cntr + 1); + cache.put(TX_KEY, cntr + 1); tx.commit(); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java index 52b0044e8a971..bcf2746010476 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java @@ -197,28 +197,6 @@ private Map pairs(int size) { return pairs; } - /** - * @throws Exception If test failed. - */ - public void testFilteredPut() throws Exception { - GridCache cache = grid(0).cache(null); - - String key = "1"; - int val = 1; - - assert !cache.putx(key, val, F.cacheHasPeekValue()); - - assert !cache.containsKey(key); - - assertEquals(0, TestEventListener.eventCount(EVT_CACHE_OBJECT_PUT)); - - assert cache.putx(key, val); - - assert cache.containsKey(key); - - waitForEvents(0, F.t(EVT_CACHE_OBJECT_PUT, gridCnt)); - } - /** * @throws Exception If test failed. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMixedModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMixedModeSelfTest.java index 246ff857cc129..d7fcee59bb391 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMixedModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMixedModeSelfTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache.distributed; +import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.util.typedef.*; @@ -64,7 +65,7 @@ private CacheConfiguration cacheConfiguration(String gridName) { * @throws Exception If failed. */ public void testBasicOps() throws Exception { - GridCache cache = grid(0).cache(null); + IgniteCache cache = grid(0).jcache(null); for (int i = 0; i < 1000; i++) cache.put(i, i); @@ -73,7 +74,7 @@ public void testBasicOps() throws Exception { assertEquals(i, cache.get(i)); for (int i = 0; i < 1000; i++) - assertEquals(i, cache.remove(i)); + assertEquals(i, cache.getAndRemove(i)); for (int i = 0; i < 1000; i++) assertNull(cache.get(i)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlySelfTest.java index 647a45bcc9fcc..089b85ae5fca0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlySelfTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache.distributed.near; +import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.internal.processors.cache.distributed.*; @@ -40,14 +41,14 @@ public class GridCacheNearOnlySelfTest extends GridCacheClientModesAbstractSelfT * @throws Exception If failed. */ public void testUpdateNearOnlyReader() throws Exception { - GridCache dhtCache = dhtCache(); + IgniteCache dhtCache = dhtCache(); final int keyCnt = 100; for (int i = 0; i < keyCnt; i++) dhtCache.put(i, i); - GridCache nearOnlyCache = nearOnlyCache(); + IgniteCache nearOnlyCache = nearOnlyCache(); for (int i = 0; i < keyCnt; i++) { assertNull(nearOnlyCache.peek(i));