Skip to content

Commit

Permalink
# IGNITE-56 Migration of tests to IgniteCache
Browse files Browse the repository at this point in the history
  • Loading branch information
sevdokimov-gg committed Feb 10, 2015
1 parent 244e604 commit f138c00
Show file tree
Hide file tree
Showing 29 changed files with 264 additions and 246 deletions.
Expand Up @@ -66,7 +66,7 @@ public class IgniteTxTimeoutAbstractTest extends GridCommonAbstractTest {
* @return Cache. * @return Cache.
*/ */
@Override protected <K, V> GridCache<K, V> cache(int i) { @Override protected <K, V> GridCache<K, V> cache(int i) {
return IGNITEs.get(i).cache(null); throw new UnsupportedOperationException();
} }


/** /**
Expand Down
Expand Up @@ -17,6 +17,7 @@


package org.apache.ignite.internal.processors.cache.distributed.dht; package org.apache.ignite.internal.processors.cache.distributed.dht;


import org.apache.ignite.*;
import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.configuration.*; import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.distributed.*;
Expand All @@ -42,13 +43,13 @@ public abstract class GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest ex
protected static final String CACHE_ATOMIC_OFFHEAP_TIERED = "cache_atomic_offheap_tiered"; protected static final String CACHE_ATOMIC_OFFHEAP_TIERED = "cache_atomic_offheap_tiered";


/** Atomic caches. */ /** Atomic caches. */
private static GridCache<Integer, Object>[] cachesAtomic; private static IgniteCache<Integer, Object>[] cachesAtomic;


/** Atomic offheap caches. */ /** Atomic offheap caches. */
private static GridCache<Integer, Object>[] cachesAtomicOffheap; private static IgniteCache<Integer, Object>[] cachesAtomicOffheap;


/** Atomic offheap caches. */ /** Atomic offheap caches. */
private static GridCache<Integer, Object>[] cachesAtomicOffheapTiered; private static IgniteCache<Integer, Object>[] cachesAtomicOffheapTiered;


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
Expand Down Expand Up @@ -98,14 +99,14 @@ public abstract class GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest ex


int gridCnt = gridCount(); int gridCnt = gridCount();


cachesAtomic = new GridCache[gridCnt]; cachesAtomic = new IgniteCache[gridCnt];
cachesAtomicOffheap = new GridCache[gridCnt]; cachesAtomicOffheap = new IgniteCache[gridCnt];
cachesAtomicOffheapTiered = new GridCache[gridCnt]; cachesAtomicOffheapTiered = new IgniteCache[gridCnt];


for (int i = 0; i < gridCount(); i++) { for (int i = 0; i < gridCount(); i++) {
cachesAtomic[i] = ignites[i].cache(CACHE_ATOMIC); cachesAtomic[i] = ignites[i].jcache(CACHE_ATOMIC);
cachesAtomicOffheap[i] = ignites[i].cache(CACHE_ATOMIC_OFFHEAP); cachesAtomicOffheap[i] = ignites[i].jcache(CACHE_ATOMIC_OFFHEAP);
cachesAtomicOffheapTiered[i] = ignites[i].cache(CACHE_ATOMIC_OFFHEAP_TIERED); cachesAtomicOffheapTiered[i] = ignites[i].jcache(CACHE_ATOMIC_OFFHEAP_TIERED);
} }
} }


Expand Down Expand Up @@ -151,13 +152,13 @@ public void testAtomicOffheapTiered() throws Exception {
* @param caches Caches. * @param caches Caches.
* @throws Exception If failed. * @throws Exception If failed.
*/ */
private void testAtomic0(GridCache<Integer, Object>[] caches) throws Exception { private void testAtomic0(IgniteCache<Integer, Object>[] caches) throws Exception {
byte[] val = wrap(1); byte[] val = wrap(1);


for (GridCache<Integer, Object> cache : caches) { for (IgniteCache<Integer, Object> cache : caches) {
cache.put(KEY_1, val); cache.put(KEY_1, val);


for (GridCache<Integer, Object> cacheInner : caches) for (IgniteCache<Integer, Object> cacheInner : caches)
assertArrayEquals(val, (byte[])cacheInner.get(KEY_1)); assertArrayEquals(val, (byte[])cacheInner.get(KEY_1));


cache.remove(KEY_1); cache.remove(KEY_1);
Expand Down
Expand Up @@ -161,9 +161,9 @@ private void checkPutAll() throws Exception {


Ignite ignite0 = grid(0); Ignite ignite0 = grid(0);


GridCache<Integer, Integer> cache0 = ignite0.cache(null); IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null);


CacheAffinity<Integer> aff = cache0.affinity(); CacheAffinity<Integer> aff = ignite0.affinity(null);


UUID id0 = ignite0.cluster().localNode().id(); UUID id0 = ignite0.cluster().localNode().id();


Expand Down Expand Up @@ -224,7 +224,7 @@ private void checkPutAll() throws Exception {
for (int i = 0; i < GRID_CNT; i++) { for (int i = 0; i < GRID_CNT; i++) {
delay(); delay();


GridCache<Integer, Integer> cache = grid(i).cache(null); IgniteCache<Integer, Integer> cache = grid(i).jcache(null);


for (Integer key : nearKeys.keySet()) for (Integer key : nearKeys.keySet())
nearKeys.put(key, val); nearKeys.put(key, val);
Expand Down Expand Up @@ -342,7 +342,7 @@ private void checkTransformAll() throws Exception {


IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null); IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null);


CacheAffinity<Object> aff = ignite0.cache(null).affinity(); CacheAffinity<Object> aff = ignite0.affinity(null);


UUID id0 = ignite0.cluster().localNode().id(); UUID id0 = ignite0.cluster().localNode().id();


Expand Down Expand Up @@ -439,21 +439,21 @@ private void checkTransformAll() throws Exception {
private void checkPutRemoveGet() throws Exception { private void checkPutRemoveGet() throws Exception {
Ignite ignite0 = grid(0); Ignite ignite0 = grid(0);


GridCache<Integer, Integer> cache0 = ignite0.cache(null); IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null);


Integer key = key(ignite0, NOT_PRIMARY_AND_BACKUP); Integer key = key(ignite0, NOT_PRIMARY_AND_BACKUP);


cache0.put(key, key); cache0.put(key, key);


for (int i = 0; i < GRID_CNT; i++) for (int i = 0; i < GRID_CNT; i++)
grid(i).cache(null).get(key); grid(i).jcache(null).get(key);


cache0.remove(key); cache0.remove(key);


cache0.put(key, key); cache0.put(key, key);


for (int i = 0; i < GRID_CNT; i++) for (int i = 0; i < GRID_CNT; i++)
grid(i).cache(null).get(key); grid(i).jcache(null).get(key);


cache0.remove(key); cache0.remove(key);
} }
Expand All @@ -477,9 +477,9 @@ private void checkPut(int grid) throws Exception {


Ignite ignite0 = grid(grid); Ignite ignite0 = grid(grid);


GridCache<Integer, Integer> cache0 = ignite0.cache(null); IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null);


CacheAffinity<Integer> aff = cache0.affinity(); CacheAffinity<Integer> aff = ignite0.affinity(null);


UUID id0 = ignite0.cluster().localNode().id(); UUID id0 = ignite0.cluster().localNode().id();


Expand Down Expand Up @@ -524,7 +524,7 @@ private void checkPut(int grid) throws Exception {
for (int i = 0; i < GRID_CNT; i++) { for (int i = 0; i < GRID_CNT; i++) {
delay(); delay();


GridCache<Integer, Integer> cache = grid(i).cache(null); IgniteCache<Integer, Integer> cache = grid(i).jcache(null);


log.info("Put [grid=" + grid(i).name() + ", val=" + val + ']'); log.info("Put [grid=" + grid(i).name() + ", val=" + val + ']');


Expand Down Expand Up @@ -554,7 +554,7 @@ private void checkRemove() throws Exception {


Ignite ignite0 = grid(0); Ignite ignite0 = grid(0);


GridCache<Integer, Integer> cache0 = ignite0.cache(null); IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null);


Integer primaryKey = key(ignite0, PRIMARY); Integer primaryKey = key(ignite0, PRIMARY);


Expand Down Expand Up @@ -600,9 +600,9 @@ private void checkReaderEvict() throws Exception {


Ignite ignite0 = grid(0); Ignite ignite0 = grid(0);


GridCache<Integer, Integer> cache0 = ignite0.cache(null); IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null);


CacheAffinity<Integer> aff = cache0.affinity(); CacheAffinity<Integer> aff = ignite0.affinity(null);


UUID id0 = ignite0.cluster().localNode().id(); UUID id0 = ignite0.cluster().localNode().id();


Expand All @@ -624,8 +624,8 @@ private void checkReaderEvict() throws Exception {
checkEntry(grid(i), nearKey, 1, false, expReaders); checkEntry(grid(i), nearKey, 1, false, expReaders);
} }


GridCache<Integer, Integer> primaryCache = G.ignite( IgniteCache<Integer, Integer> primaryCache = G.ignite(
(String) aff.mapKeyToNode(nearKey).attribute(ATTR_GRID_NAME)).cache(null); (String) aff.mapKeyToNode(nearKey).attribute(ATTR_GRID_NAME)).jcache(null);


delay(); delay();


Expand All @@ -650,9 +650,9 @@ private void checkReaderEvict() throws Exception {
private void checkReaderRemove() throws Exception { private void checkReaderRemove() throws Exception {
Ignite ignite0 = grid(0); Ignite ignite0 = grid(0);


GridCache<Integer, Integer> cache0 = ignite0.cache(null); IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null);


CacheAffinity<Integer> aff = cache0.affinity(); CacheAffinity<Integer> aff = ignite0.affinity(null);


UUID id0 = ignite0.cluster().localNode().id(); UUID id0 = ignite0.cluster().localNode().id();


Expand All @@ -675,7 +675,7 @@ private void checkReaderRemove() throws Exception {


delay(); delay();


GridCache<Integer, Integer> primaryCache = primaryNode.cache(null); IgniteCache<Integer, Integer> primaryCache = primaryNode.jcache(null);


primaryCache.put(nearKey, 2); // Put from primary, check there are no readers. primaryCache.put(nearKey, 2); // Put from primary, check there are no readers.


Expand Down Expand Up @@ -735,9 +735,9 @@ private void checkEntry(Ignite ignite, Integer key, @Nullable Integer val, boole
* @return Key with properties specified by the given mode. * @return Key with properties specified by the given mode.
*/ */
private Integer key(Ignite ignite, int mode) { private Integer key(Ignite ignite, int mode) {
GridCache<Integer, Integer> cache = ignite.cache(null); IgniteCache<Integer, Integer> cache = ignite.jcache(null);


CacheAffinity<Integer> aff = cache.affinity(); CacheAffinity<Integer> aff = ignite.affinity(null);


Integer key = null; Integer key = null;


Expand Down

0 comments on commit f138c00

Please sign in to comment.