# 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/6bbaa99f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6bbaa99f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6bbaa99f Branch: refs/heads/ignite-51 Commit: 6bbaa99f6dac52139b473dcbfa86e398fc5658c2 Parents: ba9336c Author: sevdokimov <sergey.evdoki...@jetbrains.com> Authored: Sun Feb 8 12:11:19 2015 +0300 Committer: sevdokimov <sergey.evdoki...@jetbrains.com> Committed: Sun Feb 8 12:11:19 2015 +0300 ---------------------------------------------------------------------- .../GridCacheLoadOnlyStoreAdapterSelfTest.java | 2 +- .../cache/GridCacheAbstractFlagsTest.java | 3 +- ...cheAbstractFullApiMultithreadedSelfTest.java | 6 +- .../cache/GridCacheAbstractFullApiSelfTest.java | 507 ++++++++++--------- .../cache/GridCacheAbstractTxReadTest.java | 6 +- .../cache/GridCacheIncrementTransformTest.java | 2 +- .../GridCacheInterceptorAbstractSelfTest.java | 71 ++- ...idCacheValueConsistencyAbstractSelfTest.java | 2 +- .../IgniteCacheEntryListenerAbstractTest.java | 4 +- .../cache/IgniteCacheInvokeAbstractTest.java | 7 +- .../processors/cache/IgniteTxAbstractTest.java | 31 +- .../testframework/junits/GridAbstractTest.java | 2 +- 12 files changed, 353 insertions(+), 290 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java index d55668e..3ffa321 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java @@ -63,7 +63,7 @@ public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCacheAbstractSelf int cnt = 0; for (int i = 0; i < gridCount(); i++) - cnt += cache(i).size(); + cnt += jcache(i).localSize(); assertEquals(INPUT_SIZE - (INPUT_SIZE/10), cnt); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFlagsTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFlagsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFlagsTest.java index 27eb740..3463f30 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFlagsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFlagsTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache; +import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.configuration.*; @@ -79,7 +80,7 @@ public abstract class GridCacheAbstractFlagsTest extends GridCacheAbstractSelfTe @Override public Object call() throws Exception { int idx = cntr.getAndIncrement() % gridCount(); - GridCache<String, Integer> c = cache(idx); + IgniteCache<String, Integer> c = jcache(idx); l.await(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java index 531b3fa..3a105cc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java @@ -110,12 +110,12 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid } /** - * @throws IgniteCheckedException If failed. + * */ - private void checkConsistency() throws IgniteCheckedException { + private void checkConsistency() { for (Cache.Entry<String, Integer> e : jcache()) for (int i = 1; i < gridCount(); i++) { - Integer val = cache(i).get(e.getKey()); + Integer val = jcache(i).get(e.getKey()); if (val == null) assert e.getValue() == null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 6818801..50ba5ef 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -45,8 +45,8 @@ import java.util.concurrent.locks.*; import static java.util.concurrent.TimeUnit.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*; import static org.apache.ignite.events.EventType.*; +import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*; import static org.apache.ignite.testframework.GridTestUtils.*; import static org.apache.ignite.transactions.IgniteTxConcurrency.*; import static org.apache.ignite.transactions.IgniteTxIsolation.*; @@ -1036,19 +1036,19 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract cache.put("key2", 1); cache.put("key3", 3); - IgniteCache<String, Integer> asyncCache = cache.withAsync(); + IgniteCache<String, Integer> cacheAsync = cache.withAsync(); - assertNull(asyncCache.invoke("key1", INCR_PROCESSOR)); + assertNull(cacheAsync.invoke("key1", INCR_PROCESSOR)); - IgniteFuture<?> fut0 = asyncCache.future(); + IgniteFuture<?> fut0 = cacheAsync.future(); - assertNull(asyncCache.invoke("key2", INCR_PROCESSOR)); + assertNull(cacheAsync.invoke("key2", INCR_PROCESSOR)); - IgniteFuture<?> fut1 = asyncCache.future(); + IgniteFuture<?> fut1 = cacheAsync.future(); - assertNull(asyncCache.invoke("key3", RMV_PROCESSOR)); + assertNull(cacheAsync.invoke("key3", RMV_PROCESSOR)); - IgniteFuture<?> fut2 = asyncCache.future(); + IgniteFuture<?> fut2 = cacheAsync.future(); fut0.get(); fut1.get(); @@ -1478,7 +1478,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract /** * @throws Exception In case of error. */ - public void testPutIfAbsent() throws Exception { + public void testGetAndPutIfAbsent() throws Exception { IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null; IgniteCache<String, Integer> cache = jcache(); @@ -1532,20 +1532,16 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract cache.localEvict(Collections.singleton("key2")); - cache().clearLocally("key3"); - // Same checks inside tx. tx = txEnabled() ? grid(0).transactions().txStart() : null; try { assertEquals((Integer)1, cache.getAndPutIfAbsent("key2", 3)); - assertEquals((Integer)3, cache.getAndPutIfAbsent("key3", 4)); if (tx != null) tx.commit(); assertEquals((Integer)1, cache.get("key2")); - assertEquals((Integer)3, cache.get("key3")); } finally { if (tx != null) @@ -1556,19 +1552,27 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract /** * @throws Exception If failed. */ - public void testPutIfAbsentAsync() throws Exception { + public void testGetAndPutIfAbsentAsync() throws Exception { IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null; + IgniteCache<String, Integer> cache = jcache(); + + IgniteCache<String, Integer> cacheAsync = cache.withAsync(); + try { - IgniteInternalFuture<Integer> fut1 = cache().putIfAbsentAsync("key", 1); + cacheAsync.getAndPutIfAbsent("key", 1); + + IgniteFuture<Integer> fut1 = cacheAsync.future(); assert fut1.get() == null; - assert cache().get("key") != null && cache().get("key") == 1; + assert cache.get("key") != null && cache.get("key") == 1; + + cacheAsync.getAndPutIfAbsent("key", 2); - IgniteInternalFuture<Integer> fut2 = cache().putIfAbsentAsync("key", 2); + IgniteFuture<Integer> fut2 = cacheAsync.future(); assert fut2.get() != null && fut2.get() == 1; - assert cache().get("key") != null && cache().get("key") == 1; + assert cache.get("key") != null && cache.get("key") == 1; if (tx != null) tx.commit(); @@ -1579,32 +1583,35 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } // Check swap. - cache().put("key2", 1); + cache.put("key2", 1); - assertTrue(cache().evict("key2")); + cache.localEvict(Collections.singleton("key2")); - assertEquals((Integer)1, cache().putIfAbsentAsync("key2", 3).get()); + cacheAsync.getAndPutIfAbsent("key2", 3); + + assertEquals((Integer)1, cacheAsync.<Integer>future().get()); // Check db. putToStore("key3", 3); - assertEquals((Integer)3, cache().putIfAbsentAsync("key3", 4).get()); + cacheAsync.getAndPutIfAbsent("key3", 4); + + assertEquals((Integer)3, cacheAsync.<Integer>future().get()); - cache().evict("key2"); - cache().clearLocally("key3"); + cache.localEvict(Collections.singleton("key2")); // Same checks inside tx. tx = txEnabled() ? grid(0).transactions().txStart() : null; try { - assertEquals((Integer)1, cache().putIfAbsentAsync("key2", 3).get()); - assertEquals((Integer)3, cache().putIfAbsentAsync("key3", 4).get()); + cacheAsync.getAndPutIfAbsent("key2", 3); + + assertEquals((Integer)1, cacheAsync.future().get()); if (tx != null) tx.commit(); - assertEquals((Integer)1, cache().get("key2")); - assertEquals((Integer)3, cache().get("key3")); + assertEquals((Integer)1, cache.get("key2")); } finally { if (tx != null) @@ -1615,40 +1622,39 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract /** * @throws Exception If failed. */ - public void testPutxIfAbsent() throws Exception { - assertNull(cache().get("key")); - assert cache().putxIfAbsent("key", 1); - assert cache().get("key") != null && cache().get("key") == 1; - assert !cache().putxIfAbsent("key", 2); - assert cache().get("key") != null && cache().get("key") == 1; + public void testPutIfAbsent() throws Exception { + IgniteCache<String, Integer> cache = jcache(); + + assertNull(cache.get("key")); + assert cache.putIfAbsent("key", 1); + assert cache.get("key") != null && cache.get("key") == 1; + assert !cache.putIfAbsent("key", 2); + assert cache.get("key") != null && cache.get("key") == 1; // Check swap. - cache().put("key2", 1); + cache.put("key2", 1); - assertTrue(cache().evict("key2")); + cache.localEvict(Collections.singleton("key2")); - assertFalse(cache().putxIfAbsent("key2", 3)); + assertFalse(cache.putIfAbsent("key2", 3)); // Check db. putToStore("key3", 3); - assertFalse(cache().putxIfAbsent("key3", 4)); + assertFalse(cache.putIfAbsent("key3", 4)); - cache().evict("key2"); - cache().clearLocally("key3"); + cache.localEvict(Collections.singleton("key2")); // Same checks inside tx. IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null; try { - assertFalse(cache().putxIfAbsent("key2", 3)); - assertFalse(cache().putxIfAbsent("key3", 4)); + assertFalse(cache.putIfAbsent("key2", 3)); if (tx != null) tx.commit(); - assertEquals((Integer)1, cache().get("key2")); - assertEquals((Integer)3, cache().get("key3")); + assertEquals((Integer)1, cache.get("key2")); } finally { if (tx != null) @@ -1739,9 +1745,16 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract /** * @throws Exception In case of error. */ - public void testPutxIfAbsentAsyncConcurrent() throws Exception { - IgniteInternalFuture<Boolean> fut1 = cache().putxIfAbsentAsync("key1", 1); - IgniteInternalFuture<Boolean> fut2 = cache().putxIfAbsentAsync("key2", 2); + public void testPutIfAbsentAsyncConcurrent() throws Exception { + IgniteCache<String, Integer> cacheAsync = jcache().withAsync(); + + cacheAsync.putIfAbsent("key1", 1); + + IgniteFuture<Boolean> fut1 = cacheAsync.future(); + + cacheAsync.putIfAbsent("key2", 2); + + IgniteFuture<Boolean> fut2 = cacheAsync.future(); assert fut1.get(); assert fut2.get(); @@ -1750,54 +1763,56 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract /** * @throws Exception If failed. */ - public void testReplace() throws Exception { - cache().put("key", 1); + public void testGetAndReplace() throws Exception { + IgniteCache<String, Integer> cache = jcache(); - assert cache().get("key") == 1; + cache.put("key", 1); + + assert cache.get("key") == 1; info("key 1 -> 2"); - assert cache().replace("key", 2) == 1; + assert cache.getAndReplace("key", 2) == 1; - assert cache().get("key") == 2; + assert cache.get("key") == 2; - assert cache().replace("wrong", 0) == null; + assert cache.getAndReplace("wrong", 0) == null; - assert cache().get("wrong") == null; + assert cache.get("wrong") == null; info("key 0 -> 3"); - assert !cache().replace("key", 0, 3); + assert !cache.replace("key", 0, 3); - assert cache().get("key") == 2; + assert cache.get("key") == 2; info("key 0 -> 3"); - assert !cache().replace("key", 0, 3); + assert !cache.replace("key", 0, 3); - assert cache().get("key") == 2; + assert cache.get("key") == 2; info("key 2 -> 3"); - assert cache().replace("key", 2, 3); + assert cache.replace("key", 2, 3); - assert cache().get("key") == 3; + assert cache.get("key") == 3; info("evict key"); - cache().evict("key"); + cache.localEvict(Collections.singleton("key")); info("key 3 -> 4"); - assert cache().replace("key", 3, 4); + assert cache.replace("key", 3, 4); - assert cache().get("key") == 4; + assert cache.get("key") == 4; putToStore("key2", 5); info("key2 5 -> 6"); - assert cache().replace("key2", 5, 6); + assert cache.replace("key2", 5, 6); for (int i = 0; i < gridCount(); i++) { info("Peek key on grid [i=" + i + ", nodeId=" + grid(i).localNode().id() + @@ -1807,22 +1822,19 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract ", peekVal=" + grid(i).cache(null).peek("key2") + ']'); } - assertEquals((Integer)6, cache().get("key2")); + assertEquals((Integer)6, cache.get("key2")); - cache().evict("key"); - cache().clearLocally("key2"); + cache.localEvict(Collections.singleton("key")); IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null; try { - assert cache().replace("key", 4, 5); - assert cache().replace("key2", 6, 7); + assert cache.replace("key", 4, 5); if (tx != null) tx.commit(); - assert cache().get("key") == 5; - assert cache().get("key2") == 7; + assert cache.get("key") == 5; } finally { if (tx != null) @@ -1833,37 +1845,37 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract /** * @throws Exception If failed. */ - public void testReplacex() throws Exception { - cache().put("key", 1); + public void testReplace() throws Exception { + IgniteCache<String, Integer> cache = jcache(); - assert cache().get("key") == 1; + cache.put("key", 1); - assert cache().replacex("key", 2); + assert cache.get("key") == 1; - assert cache().get("key") == 2; + assert cache.replace("key", 2); - assert !cache().replacex("wrong", 2); + assert cache.get("key") == 2; - cache().evict("key"); + assert !cache.replace("wrong", 2); - assert cache().replacex("key", 4); + cache.localEvict(Collections.singleton("key")); - assert cache().get("key") == 4; + assert cache.replace("key", 4); + + assert cache.get("key") == 4; putToStore("key2", 5); - assert cache().replacex("key2", 6); + assert cache.replace("key2", 6); - assertEquals((Integer)6, cache().get("key2")); + assertEquals((Integer)6, cache.get("key2")); - cache().evict("key"); - cache().clearLocally("key2"); + cache.localEvict(Collections.singleton("key")); IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null; try { - assert cache().replacex("key", 5); - assert cache().replacex("key2", 7); + assert cache.replace("key", 5); if (tx != null) tx.commit(); @@ -1873,58 +1885,75 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract tx.close(); } - assert cache().get("key") == 5; - assert cache().get("key2") == 7; + assert cache.get("key") == 5; } /** * @throws Exception If failed. */ - public void testReplaceAsync() throws Exception { - cache().put("key", 1); + public void testGetAndReplaceAsync() throws Exception { + IgniteCache<String, Integer> cache = jcache(); - assert cache().get("key") == 1; + IgniteCache<String, Integer> cacheAsync = cache.withAsync(); + + cache.put("key", 1); + + assert cache.get("key") == 1; - assert cache().replaceAsync("key", 2).get() == 1; + cacheAsync.getAndReplace("key", 2); - assert cache().get("key") == 2; + assert cacheAsync.future().get() == 1; - assert cache().replaceAsync("wrong", 0).get() == null; + assert cache.get("key") == 2; + + cacheAsync.getAndReplace("wrong", 0); + + assert cacheAsync.future().get() == null; + + assert cache.get("wrong") == null; - assert cache().get("wrong") == null; + cacheAsync.replace("key", 0, 3); - assert !cache().replaceAsync("key", 0, 3).get(); + assert !cacheAsync.<Boolean>future().get(); - assert cache().get("key") == 2; + assert cache.get("key") == 2; - assert !cache().replaceAsync("key", 0, 3).get(); + cacheAsync.replace("key", 0, 3); - assert cache().get("key") == 2; + assert !cacheAsync.<Boolean>future().get(); - assert cache().replaceAsync("key", 2, 3).get(); + assert cache.get("key") == 2; - assert cache().get("key") == 3; + cacheAsync.replace("key", 2, 3); - cache().evict("key"); + assert cacheAsync.<Boolean>future().get(); - assert cache().replaceAsync("key", 3, 4).get(); + assert cache.get("key") == 3; - assert cache().get("key") == 4; + cache.localEvict(Collections.singleton("key")); + + cacheAsync.replace("key", 3, 4); + + assert cacheAsync.<Boolean>future().get(); + + assert cache.get("key") == 4; putToStore("key2", 5); - assert cache().replaceAsync("key2", 5, 6).get(); + cacheAsync.replace("key2", 5, 6); - assertEquals((Integer)6, cache().get("key2")); + assert cacheAsync.<Boolean>future().get(); - cache().evict("key"); - cache().clearLocally("key2"); + assertEquals((Integer)6, cache.get("key2")); + + cache.localEvict(Collections.singleton("key")); IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null; try { - assert cache().replaceAsync("key", 4, 5).get(); - assert cache().replaceAsync("key2", 6, 7).get(); + cacheAsync.replace("key", 4, 5); + + assert cacheAsync.<Boolean>future().get(); if (tx != null) tx.commit(); @@ -1934,46 +1963,57 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract tx.close(); } - assert cache().get("key") == 5; - assert cache().get("key2") == 7; + assert cache.get("key") == 5; } /** * @throws Exception If failed. */ public void testReplacexAsync() throws Exception { - cache().put("key", 1); + IgniteCache<String, Integer> cache = jcache(); + + IgniteCache<String, Integer> cacheAsync = cache.withAsync(); + + cache.put("key", 1); + + assert cache.get("key") == 1; - assert cache().get("key") == 1; + cacheAsync.replace("key", 2); - assert cache().replacexAsync("key", 2).get(); + assert cacheAsync.<Boolean>future().get(); U.debug(log, "Finished replace."); - assertEquals((Integer)2, cache().get("key")); + assertEquals((Integer)2, cache.get("key")); + + cacheAsync.replace("wrond", 2); + + assert !cacheAsync.<Boolean>future().get(); - assert !cache().replacexAsync("wrong", 2).get(); + cache.localEvict(Collections.singleton("key")); - cache().evict("key"); + cacheAsync.replace("key", 4); - assert cache().replacexAsync("key", 4).get(); + assert cacheAsync.<Boolean>future().get(); - assert cache().get("key") == 4; + assert cache.get("key") == 4; putToStore("key2", 5); - assert cache().replacexAsync("key2", 6).get(); + cacheAsync.replace("key2", 6); - assert cache().get("key2") == 6; + assert cacheAsync.<Boolean>future().get(); - cache().evict("key"); - cache().clearLocally("key2"); + assert cache.get("key2") == 6; + + cache.localEvict(Collections.singleton("key")); IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null; try { - assert cache().replacexAsync("key", 5).get(); - assert cache().replacexAsync("key2", 7).get(); + cacheAsync.replace("key", 5); + + assert cacheAsync.<Boolean>future().get(); if (tx != null) tx.commit(); @@ -1983,24 +2023,25 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract tx.close(); } - assert cache().get("key") == 5; - assert cache().get("key2") == 7; + assert cache.get("key") == 5; } /** * @throws Exception In case of error. */ - public void testRemove() throws Exception { - cache().put("key1", 1); - cache().put("key2", 2); + public void testGetAndRemove() throws Exception { + IgniteCache<String, Integer> cache = jcache(); - assert !cache().remove("key1", 0); - assert cache().get("key1") != null && cache().get("key1") == 1; - assert cache().remove("key1", 1); - assert cache().get("key1") == null; - assert cache().remove("key2") == 2; - assert cache().get("key2") == null; - assert cache().remove("key2") == null; + cache.put("key1", 1); + cache.put("key2", 2); + + assert !cache.remove("key1", 0); + assert cache.get("key1") != null && cache.get("key1") == 1; + assert cache.remove("key1", 1); + assert cache.get("key1") == null; + assert cache.getAndRemove("key2") == 2; + assert cache.get("key2") == null; + assert cache.getAndRemove("key2") == null; } /** @@ -2044,12 +2085,12 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract public void testRemoveLoad() throws Exception { int cnt = 10; - Collection<String> keys = new ArrayList<>(); + Set<String> keys = new HashSet<>(); for (int i = 0; i < cnt; i++) keys.add(String.valueOf(i)); - cache().removeAll(keys); + jcache().removeAll(keys); for (String key : keys) putToStore(key, Integer.parseInt(key)); @@ -2061,7 +2102,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (int i = 0; i < cnt; i++) { String key = String.valueOf(i); - if (cache().affinity().mapKeyToPrimaryAndBackups(key).contains(grid(g).localNode())) + if (grid(0).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(g).localNode())) assertEquals((Integer)i, cache(g).peek(key)); else assertNull(cache(g).peek(key)); @@ -2073,51 +2114,83 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @throws Exception In case of error. */ public void testRemoveAsync() throws Exception { - cache().put("key1", 1); - cache().put("key2", 2); + IgniteCache<String, Integer> cache = jcache(); + + IgniteCache<String, Integer> cacheAsync = cache.withAsync(); + + cache.put("key1", 1); + cache.put("key2", 2); + + cacheAsync.remove("key1", 0); + + assert !cacheAsync.<Boolean>future().get(); + + assert cache.get("key1") != null && cache.get("key1") == 1; + + cacheAsync.remove("key1", 1); + + assert cacheAsync.<Boolean>future().get(); + + assert cache.get("key1") == null; + + cacheAsync.getAndRemove("key2"); + + assert cacheAsync.future().get() == 2; + + assert cache.get("key2") == null; + + cacheAsync.getAndRemove("key2"); - assert !cache().removeAsync("key1", 0).get(); - assert cache().get("key1") != null && cache().get("key1") == 1; - assert cache().removeAsync("key1", 1).get(); - assert cache().get("key1") == null; - assert cache().removeAsync("key2").get() == 2; - assert cache().get("key2") == null; - assert cache().removeAsync("key2").get() == null; + assert cacheAsync.future().get() == null; } /** * @throws Exception In case of error. */ - public void testRemovex() throws Exception { - cache().put("key1", 1); + public void testRemove() throws Exception { + IgniteCache<String, Integer> cache = jcache(); - assert cache().removex("key1"); - assert cache().get("key1") == null; - assert !cache().removex("key1"); + cache.put("key1", 1); + + assert cache.remove("key1"); + assert cache.get("key1") == null; + assert !cache.remove("key1"); } /** * @throws Exception In case of error. */ public void testRemovexAsync() throws Exception { - cache().put("key1", 1); + IgniteCache<String, Integer> cache = jcache(); + + IgniteCache<String, Integer> cacheAsync = cache.withAsync(); + + cache.put("key1", 1); - assert cache().removexAsync("key1").get(); - assert cache().get("key1") == null; - assert !cache().removexAsync("key1").get(); + cacheAsync.remove("key1"); + + assert cacheAsync.<Boolean>future().get(); + + assert cache.get("key1") == null; + + cacheAsync.remove("key1"); + + assert !cacheAsync.<Boolean>future().get(); } /** * @throws Exception In case of error. */ public void testRemoveAll() throws Exception { - cache().put("key1", 1); - cache().put("key2", 2); - cache().put("key3", 3); + IgniteCache<String, Integer> cache = jcache(); + + cache.put("key1", 1); + cache.put("key2", 2); + cache.put("key3", 3); checkSize(F.asSet("key1", "key2", "key3")); - cache().removeAll(F.asList("key1", "key2")); + cache.removeAll(F.asSet("key1", "key2")); checkSize(F.asSet("key3")); @@ -2126,25 +2199,25 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract checkContainsKey(true, "key3"); // Put values again. - cache().put("key1", 1); - cache().put("key2", 2); - cache().put("key3", 3); + cache.put("key1", 1); + cache.put("key2", 2); + cache.put("key3", 3); cache(gridCount() > 1 ? 1 : 0).removeAll(); - assert cache().isEmpty(); + assert cache.localSize() == 0; long entryCount = hugeRemoveAllEntryCount(); for (int i = 0; i < entryCount; i++) - cache().put(String.valueOf(i), i); + cache.put(String.valueOf(i), i); for (int i = 0; i < entryCount; i++) - assertEquals(Integer.valueOf(i), cache().get(String.valueOf(i))); + assertEquals(Integer.valueOf(i), cache.get(String.valueOf(i))); - cache().removeAll(); + cache.removeAll(); for (int i = 0; i < entryCount; i++) - assertNull(cache().get(String.valueOf(i))); + assertNull(cache.get(String.valueOf(i))); } /** @@ -2211,7 +2284,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @throws Exception In case of error. */ public void testRemoveAllDuplicates() throws Exception { - cache().removeAll(Arrays.asList("key1", "key1", "key1")); + jcache().removeAll(ImmutableSet.of("key1", "key1", "key1")); } /** @@ -2220,7 +2293,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract public void testRemoveAllDuplicatesTx() throws Exception { if (txEnabled()) { try (IgniteTx tx = grid(0).transactions().txStart()) { - cache().removeAll(Arrays.asList("key1", "key1", "key1")); + jcache().removeAll(ImmutableSet.of("key1", "key1", "key1")); tx.commit(); } @@ -2231,20 +2304,26 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @throws Exception In case of error. */ public void testRemoveAllEmpty() throws Exception { - cache().removeAll(); + jcache().removeAll(); } /** * @throws Exception In case of error. */ public void testRemoveAllAsync() throws Exception { - cache().put("key1", 1); - cache().put("key2", 2); - cache().put("key3", 3); + IgniteCache<String, Integer> cache = jcache(); + + IgniteCache<String, Integer> cacheAsync = cache.withAsync(); + + cache.put("key1", 1); + cache.put("key2", 2); + cache.put("key3", 3); checkSize(F.asSet("key1", "key2", "key3")); - cache().removeAllAsync(F.asList("key1", "key2")).get(); + cacheAsync.removeAll(F.asSet("key1", "key2")); + + cacheAsync.future().get(); checkSize(F.asSet("key3")); @@ -2256,46 +2335,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract /** * @throws Exception In case of error. */ - public void testKeySet() throws Exception { - cache().put("key1", 1); - cache().put("key2", 2); - cache().put("key3", 3); - - Collection<String> keys = new HashSet<>(); - - for (int i = 0; i < gridCount(); i++) - keys.addAll(cache(i).keySet()); - - assert keys.size() == 3; - assert keys.contains("key1"); - assert keys.contains("key2"); - assert keys.contains("key3"); - assert !keys.contains("wrongKey"); - } - - /** - * @throws Exception In case of error. - */ - public void testValues() throws Exception { - cache().put("key1", 1); - cache().put("key2", 2); - cache().put("key3", 3); - - Collection<Integer> vals = new HashSet<>(); - - for (int i = 0; i < gridCount(); i++) - vals.addAll(cache(i).values()); - - assert vals.size() == 3; - assert vals.contains(1); - assert vals.contains(2); - assert vals.contains(3); - assert !vals.contains(0); - } - - /** - * @throws Exception In case of error. - */ public void testLoadAll() throws Exception { IgniteCache<String, Integer> cache = jcache(); @@ -3159,7 +3198,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assert cache.localPeek(key2, CachePeekMode.ONHEAP) == null; assert cache.localPeek(key3, CachePeekMode.ONHEAP) == 3; - cache().reloadAll(F.asList(key1, key2)); + loadAll(cache, ImmutableSet.of(key1, key2), true); assert cache.localPeek(key1, CachePeekMode.ONHEAP) == 1; assert cache.localPeek(key2, CachePeekMode.ONHEAP) == 2; @@ -3332,7 +3371,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract try (IgniteTx tx = grid(0).transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { // Remove missing key. - assertTrue(cache().removex(UUID.randomUUID().toString())); + assertTrue(jcache().remove(UUID.randomUUID().toString())); tx.commit(); } @@ -3349,7 +3388,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract try (IgniteTx tx = grid(0).transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { // Remove missing key. - assertTrue(cache().removex(UUID.randomUUID().toString())); + assertTrue(jcache().remove(UUID.randomUUID().toString())); tx.setRollbackOnly(); } @@ -3425,7 +3464,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract if (txEnabled()) { try (IgniteTx tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { // Remove missing key. - assertFalse(cache().removex(UUID.randomUUID().toString())); + assertFalse(jcache().remove(UUID.randomUUID().toString())); tx.commit(); } @@ -3441,7 +3480,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract if (txEnabled()) { try (IgniteTx tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { // Remove missing key. - assertFalse(cache().removex(UUID.randomUUID().toString())); + assertFalse(jcache().remove(UUID.randomUUID().toString())); tx.setRollbackOnly(); } @@ -3454,9 +3493,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract public void testPessimisticTxRepeatableRead() throws Exception { if (txEnabled()) { try (IgniteTx ignored = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - cache().putx("key", 1); + jcache().put("key", 1); - assert cache().get("key") == 1; + assert jcache().get("key") == 1; } } } @@ -3467,9 +3506,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract public void testPessimisticTxRepeatableReadOnUpdate() throws Exception { if (txEnabled()) { try (IgniteTx ignored = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - cache().put("key", 1); + jcache().put("key", 1); - assert cache().put("key", 2) == 1; + assert jcache().getAndPut("key", 2) == 1; } } } @@ -3574,16 +3613,20 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @throws Exception In case of error. */ public void testToMap() throws Exception { - if (offheapTiered(cache())) + IgniteCache<String, Integer> cache = jcache(); + + if (offheapTiered(cache)) return; - cache().put("key1", 1); - cache().put("key2", 2); + cache.put("key1", 1); + cache.put("key2", 2); Map<String, Integer> map = new HashMap<>(); - for (int i = 0; i < gridCount(); i++) - map.putAll(cache(i).toMap()); + for (int i = 0; i < gridCount(); i++) { + for (CacheEntry<String, Integer> entry : cache(i)) + map.put(entry.getKey(), entry.getValue()); + } assert map != null; assert map.size() == 2; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractTxReadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractTxReadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractTxReadTest.java index 7d249dc..fb1acac 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractTxReadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractTxReadTest.java @@ -99,11 +99,11 @@ public abstract class GridCacheAbstractTxReadTest extends GridCacheAbstractSelfT */ protected void checkTransactionalRead(IgniteTxConcurrency concurrency, IgniteTxIsolation isolation) throws IgniteCheckedException { - GridCache<String, Integer> cache = cache(0); + IgniteCache<String, Integer> cache = jcache(0); cache.clear(); - IgniteTx tx = cache.txStart(concurrency, isolation); + IgniteTx tx = grid(0).transactions().txStart(concurrency, isolation); try { cache.put("key", 1); @@ -119,7 +119,7 @@ public abstract class GridCacheAbstractTxReadTest extends GridCacheAbstractSelfT assertEquals("Invalid cache size after put", 1, cache.size()); try { - tx = cache.txStart(concurrency, isolation); + tx = grid(0).transactions().txStart(concurrency, isolation); assertEquals("Invalid value inside transactional read", Integer.valueOf(1), cache.get("key")); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIncrementTransformTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIncrementTransformTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIncrementTransformTest.java index e001f1f..320a2b6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIncrementTransformTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIncrementTransformTest.java @@ -89,7 +89,7 @@ public class GridCacheIncrementTransformTest extends GridCommonAbstractTest { for (int i = 0; i < GRID_CNT; i++) grids.set(i, grid(i)); - cache(0).put("key", new TestObject(0)); + jcache(0).put("key", new TestObject(0)); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java index 76f119e..594d990 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java @@ -147,7 +147,9 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst log.info("Get 1."); - assertEquals(null, cache(0).get(key)); + IgniteCache<String, Integer> cache = jcache(0); + + assertEquals(null, cache.get(key)); assertEquals(1, interceptor.invokeCnt.get()); @@ -163,7 +165,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst log.info("Get 2."); - assertEquals((Integer)1, cache(0).get(key)); + assertEquals((Integer)1, cache.get(key)); assertEquals(1, interceptor.invokeCnt.get()); @@ -175,7 +177,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst interceptor.disabled = true; - cache(0).put(key, 100); + cache.put(key, 100); interceptor.disabled = false; @@ -189,7 +191,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst log.info("Get 3."); - assertEquals(null, cache(0).get(key)); + assertEquals(null, cache.get(key)); assertEquals(1, interceptor.invokeCnt.get()); @@ -209,7 +211,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst log.info("Get 4."); - assertEquals((Integer)101, cache(0).get(key)); + assertEquals((Integer)101, cache.get(key)); assertEquals(1, interceptor.invokeCnt.get()); @@ -229,7 +231,11 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst log.info("GetAsync 1."); - assertEquals((Integer)101, cache(0).getAsync(key).get()); + IgniteCache<String, Integer> cacheAsync = cache.withAsync(); + + cacheAsync.get(key); + + assertEquals((Integer)101, cacheAsync.<Integer>future().get()); assertEquals(1, interceptor.invokeCnt.get()); @@ -244,7 +250,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst * @throws Exception If failed. */ public void testGetAll() throws Exception { - List<String> keys = new ArrayList<>(); + Set<String> keys = new HashSet<>(); for (int i = 0; i < 1000; i++) keys.add(String.valueOf(i)); @@ -255,7 +261,11 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst } }; - Map<String, Integer> map = cache(0).getAll(keys); + IgniteCache<String, Integer> cache = jcache(0); + + IgniteCache<String, Integer> cacheAsync = cache.withAsync(); + + Map<String, Integer> map = cache.getAll(keys); for (String key : keys) assertEquals(null, map.get(key)); @@ -272,7 +282,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst } }; - map = cache(0).getAll(keys); + map = cache.getAll(keys); for (String key : keys) { int k = Integer.valueOf(key); @@ -290,7 +300,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst interceptor.disabled = true; for (int i = 0; i < 500; i++) - cache(0).put(String.valueOf(i), i); + cache.put(String.valueOf(i), i); interceptor.disabled = false; @@ -319,11 +329,18 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst } }; - map = j == 0 ? cache(0).getAll(keys) : cache(0).getAllAsync(keys).get(); + if (j == 0) { + map = cache.getAll(keys); + } + else { + cacheAsync.getAll(keys); + + map = cacheAsync.<Map<String, Integer>>future().get(); + } - for (int i = 0; i < keys.size(); i++) { - String key = keys.get(i); + int i = 0; + for (String key : keys) { switch (i % 3) { case 0: assertEquals(null, map.get(key)); @@ -345,6 +362,8 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst default: fail(); } + + i++; } assertEquals(1000, interceptor.invokeCnt.get()); @@ -437,7 +456,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst clearCaches(); - cache(0).put(key, 1); + jcache(0).put(key, 1); checkCacheValue(key, 1); @@ -617,7 +636,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst clearCaches(); - cache(0).put(key, 1); + jcache(0).put(key, 1); checkCacheValue(key, 1); @@ -744,7 +763,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst clearCaches(); - cache(0).put(key, 1); + jcache(0).put(key, 1); checkCacheValue(key, 1); @@ -783,7 +802,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst clearCaches(); - cache(0).put(key, 2); + jcache(0).put(key, 2); checkCacheValue(key, 2); @@ -861,7 +880,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst interceptor.disabled = true; // Put from grid 1 to be sure grid 0 does not have value for near key. - cache(1).putAll(F.asMap(key1, 1, key2, 2, key3, 3)); + jcache(1).putAll(F.asMap(key1, 1, key2, 2, key3, 3)); interceptor.disabled = false; @@ -872,7 +891,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst assertNotNull(txIsolation); assertNotNull(op); - try (IgniteTx tx = cache(0).txStart(txConcurrency, txIsolation)) { + try (IgniteTx tx = ignite(0).transactions().txStart(txConcurrency, txIsolation)) { update(0, op, key1, 100, 1); update(0, op, key2, 200, 2); update(0, op, key3, 300, 3); @@ -881,7 +900,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst } } else - cache(0).putAll(F.asMap(key1, 100, key2, 200, key3, 300)); + jcache(0).putAll(F.asMap(key1, 100, key2, 200, key3, 300)); checkCacheValue(key1, 101); checkCacheValue(key2, 201); @@ -1052,7 +1071,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst interceptor.disabled = true; - cache(0).putAll(map); + jcache(0).putAll(map); interceptor.disabled = false; @@ -1089,7 +1108,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst interceptor.disabled = true; - cache(0).putAll(map); + jcache(0).putAll(map); interceptor.disabled = false; @@ -1351,7 +1370,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst private List<String> primaryKeys(int idx, int cnt) { assert cnt > 0; - CacheAffinity aff = cache(0).affinity(); + CacheAffinity aff = ignite(0).affinity(null); List<String> keys = new ArrayList<>(cnt); @@ -1376,7 +1395,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst * @return Primary key for grid. */ private String backupKey(int idx) { - CacheAffinity aff = cache(0).affinity(); + CacheAffinity aff = ignite(0).affinity(null); String key = null; @@ -1398,7 +1417,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst * @return Key which does not belong to the grid. */ private String nearKey(int idx) { - CacheAffinity aff = cache(0).affinity(); + CacheAffinity aff = ignite(0).affinity(null); String key = null; @@ -1440,7 +1459,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst */ private void clearCaches() throws Exception { for (int i = 0; i < gridCount(); i++) - cache(i).removeAll(); + jcache(i).removeAll(); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java index 1e68046..c7794d3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java @@ -206,7 +206,7 @@ public abstract class GridCacheValueConsistencyAbstractSelfTest extends GridCach for (int g = 0; g < gridCount(); g++) { info(">>>> Removing all values form cache: " + g); - cache(g).removeAll(); + jcache(g).removeAll(); } info(">>>> Starting values check"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java index 957dafa..58850fa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java @@ -821,7 +821,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb * @throws Exception If failed. */ protected Collection<Integer> keys() throws Exception { - GridCache<Integer, Object> cache = cache(0); + IgniteCache<Integer, Object> cache = jcache(0); ArrayList<Integer> keys = new ArrayList<>(); @@ -830,7 +830,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb if (gridCount() > 1) { keys.add(backupKeys(cache, 1, lastKey).get(0)); - if (cache.configuration().getCacheMode() != REPLICATED) + if (cache.getConfiguration(CacheConfiguration.class).getCacheMode() != REPLICATED) keys.add(nearKeys(cache, 1, lastKey).get(0)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java index 658a508..04150e3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.testframework.*; @@ -467,7 +468,7 @@ public abstract class IgniteCacheInvokeAbstractTest extends IgniteCacheAbstractT Object val = cache.localPeek(key, CachePeekMode.ONHEAP); if (val == null) - assertFalse(cache(0).affinity().isPrimaryOrBackup(ignite(i).cluster().localNode(), key)); + assertFalse(ignite(0).affinity(null).isPrimaryOrBackup(ignite(i).cluster().localNode(), key)); else assertEquals("Unexpected value for grid " + i, expVal, val); } @@ -486,7 +487,7 @@ public abstract class IgniteCacheInvokeAbstractTest extends IgniteCacheAbstractT * @throws Exception If failed. */ protected Collection<Integer> keys() throws Exception { - GridCache<Integer, Object> cache = cache(0); + IgniteCache<Integer, Object> cache = jcache(0); ArrayList<Integer> keys = new ArrayList<>(); @@ -495,7 +496,7 @@ public abstract class IgniteCacheInvokeAbstractTest extends IgniteCacheAbstractT if (gridCount() > 1) { keys.add(backupKeys(cache, 1, lastKey).get(0)); - if (cache.configuration().getCacheMode() != REPLICATED) + if (cache.getConfiguration(CacheConfiguration.class).getCacheMode() != REPLICATED) keys.add(nearKeys(cache, 1, lastKey).get(0)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxAbstractTest.java index c40d9e4..ba6ba82 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxAbstractTest.java @@ -22,7 +22,6 @@ import org.apache.ignite.cache.*; import org.apache.ignite.cache.affinity.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.transactions.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.spi.discovery.tcp.*; @@ -174,9 +173,9 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { debug("Checking commit on grid: " + ignite.cluster().localNode().id()); for (int i = 0; i < iterations(); i++) { - GridCache<Integer, String> cache = cache(gridIdx); + IgniteCache<Integer, String> cache = jcache(gridIdx); - IgniteTx tx = cache.txStart(concurrency, isolation, 0, 0); + IgniteTx tx = ignite(gridIdx).transactions().txStart(concurrency, isolation, 0, 0); try { int prevKey = -1; @@ -186,12 +185,12 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { assert key >= prevKey : "key: " + key + ", prevKey: " + prevKey; if (isTestDebug()) { - CacheAffinityFunction aff = cache.configuration().getAffinity(); + CacheAffinityFunction aff = cache.getConfiguration(CacheConfiguration.class).getAffinity(); int part = aff.partition(key); debug("Key affinity [key=" + key + ", partition=" + part + ", affinity=" + - U.toShortString(cache.affinity().mapPartitionToPrimaryAndBackups(part)) + ']'); + U.toShortString(ignite(gridIdx).affinity(null).mapPartitionToPrimaryAndBackups(part)) + ']'); } String val = Integer.toString(key); @@ -271,7 +270,7 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { throw e; } finally { - IgniteTx t = cache.tx(); + IgniteTx t = ignite(gridIdx).transactions().tx(); assert t == null : "Thread should not have transaction upon completion ['t==tx'=" + (t == tx) + ", t=" + t + (t != tx ? "tx=" + tx : "tx=''") + ']'; @@ -311,19 +310,19 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { debug("Checking commit on grid: " + ignite.cluster().localNode().id()); for (int i = 0; i < iterations(); i++) { - GridCache<Integer, String> cache = cache(gridIdx); + IgniteCache<Integer, String> cache = jcache(gridIdx); - IgniteTx tx = cache.txStart(concurrency, isolation, 0, 0); + IgniteTx tx = ignite(gridIdx).transactions().txStart(concurrency, isolation, 0, 0); try { for (Integer key : getKeys()) { if (isTestDebug()) { - CacheAffinityFunction aff = cache.configuration().getAffinity(); + CacheAffinityFunction aff = cache.getConfiguration(CacheConfiguration.class).getAffinity(); int part = aff.partition(key); debug("Key affinity [key=" + key + ", partition=" + part + ", affinity=" + - U.toShortString(cache.affinity().mapPartitionToPrimaryAndBackups(part)) + ']'); + U.toShortString(ignite(gridIdx).affinity(null).mapPartitionToPrimaryAndBackups(part)) + ']'); } String val = Integer.toString(key); @@ -340,7 +339,7 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { case WRITE: { debug("Writing key and value [key=" + key + ", val=" + val + ']'); - checkMap(map, key, cache.put(key, val)); + checkMap(map, key, cache.getAndPut(key, val)); break; } @@ -348,7 +347,7 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { case REMOVE: { debug("Removing key: " + key); - checkMap(map, key, cache.remove(key)); + checkMap(map, key, cache.getAndRemove(key)); break; } @@ -361,7 +360,7 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { debug("Rolled back transaction: " + tx); } - catch (IgniteTxOptimisticCheckedException e) { + catch (IgniteTxOptimisticException e) { tx.rollback(); log.warning("Rolled back transaction due to optimistic exception [tx=" + tx + ", e=" + e + ']'); @@ -376,7 +375,7 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { throw e; } finally { - IgniteTx t1 = cache.tx(); + IgniteTx t1 = ignite(gridIdx).transactions().tx(); debug("t1=" + t1); @@ -416,7 +415,7 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { for (int j = 0; j < gridCount(); j++) { GridCache<Integer, String> cache = cache(j); - IgniteTx tx = cache.tx(); + IgniteTx tx = ignite(j).transactions().tx(); assertNull("Transaction is not completed: " + tx, tx); @@ -457,7 +456,7 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { for (int k = 0; k < 3; k++) { try { for (int j = 0; j < gridCount(); j++) { - CacheProjection<Integer, String> cache = cache(j); + IgniteCache<Integer, String> cache = jcache(j); cache.removeAll(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6bbaa99f/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java index 3bd261c..bc288d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java @@ -72,7 +72,7 @@ public abstract class GridAbstractTest extends TestCase { private static final String NULL_NAME = UUID.randomUUID().toString(); /** */ - private static final long DFLT_TEST_TIMEOUT = 5 * 60 * 1000; + private static final long DFLT_TEST_TIMEOUT = 5000 * 60 * 1000; /** */ private static final transient Map<Class<?>, TestCounters> tests = new ConcurrentHashMap<>();