Skip to content

Commit

Permalink
IGNITE-96 Migrating tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
niktikhonov committed Feb 10, 2015
1 parent aae71de commit 244e604
Show file tree
Hide file tree
Showing 23 changed files with 300 additions and 462 deletions.
Expand Up @@ -90,14 +90,6 @@ public abstract class GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest
*/ */
protected abstract CacheAffinityFunction affinityFunction(); protected abstract CacheAffinityFunction affinityFunction();


/**
* @param ignite Grid.
* @return Affinity.
*/
static CacheAffinity<Object> affinity(Ignite ignite) {
return ignite.cache(null).affinity();
}

/** /**
* @param aff Affinity. * @param aff Affinity.
* @param key Key. * @param key Key.
Expand All @@ -123,7 +115,7 @@ public void testAffinityMultiNode() throws Exception {
for (int i = 0; i < grids; i++) { for (int i = 0; i < grids; i++) {
final Ignite g = grid(i); final Ignite g = grid(i);


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


List<TcpDiscoveryNode> top = new ArrayList<>(); List<TcpDiscoveryNode> top = new ArrayList<>();


Expand Down Expand Up @@ -170,7 +162,7 @@ public void testAffinitySingleNode() throws Exception {
try { try {
Object key = 12345; Object key = 12345;


Collection<? extends ClusterNode> affNodes = nodes(affinity(g), key); Collection<? extends ClusterNode> affNodes = nodes(g.affinity(null), key);


info("Affinity picture for grid: " + U.toShortString(affNodes)); info("Affinity picture for grid: " + U.toShortString(affNodes));


Expand Down
Expand Up @@ -70,7 +70,7 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe


@Override protected void afterTest() throws Exception { @Override protected void afterTest() throws Exception {
for (int i = 0; i < gridCount(); i++) for (int i = 0; i < gridCount(); i++)
grid(i).cache(null).removeAll(); grid(i).jcache(null).removeAll();


super.afterTest(); super.afterTest();
} }
Expand Down
Expand Up @@ -29,6 +29,7 @@


import javax.cache.*; import javax.cache.*;
import javax.cache.configuration.*; import javax.cache.configuration.*;
import javax.cache.integration.*;
import java.util.concurrent.*; import java.util.concurrent.*;


import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheAtomicityMode.*;
Expand Down Expand Up @@ -122,11 +123,11 @@ private void checkGetError(boolean nearEnabled, CacheMode cacheMode) throws Exce
try { try {
GridTestUtils.assertThrows(log, new Callable<Object>() { GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception { @Override public Object call() throws Exception {
grid(0).cache(null).get(nearKey()); grid(0).jcache(null).get(nearKey());


return null; return null;
} }
}, IgniteCheckedException.class, null); }, CacheLoaderException.class, null);
} }
finally { finally {
stopAllGrids(); stopAllGrids();
Expand Down
Expand Up @@ -20,6 +20,7 @@
import org.apache.ignite.*; 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.*;
import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.lang.*; import org.apache.ignite.lang.*;
import org.apache.ignite.marshaller.optimized.*; import org.apache.ignite.marshaller.optimized.*;
Expand Down Expand Up @@ -91,12 +92,12 @@ public void testNearEnabledOneNode() throws Exception {
startGridsMultiThreaded(gridCnt); startGridsMultiThreaded(gridCnt);


try { try {
GridCache<Integer, String> c = grid(0).cache(null); IgniteCache<Integer, String> c = grid(0).jcache(null);


int cnt = 100; int cnt = 100;


for (int i = 0; i < cnt; i++) for (int i = 0; i < cnt; i++)
assertTrue(c.putx(i, Integer.toString(i))); c.put(i, Integer.toString(i));


assertEquals(cnt, c.size()); assertEquals(cnt, c.size());
assertEquals(cnt, c.size()); assertEquals(cnt, c.size());
Expand All @@ -121,18 +122,17 @@ public void testNearEnabledTwoNodes() throws Exception {
private Ignite ignite; private Ignite ignite;


@Override public Object call() throws Exception { @Override public Object call() throws Exception {
GridCache<Integer, String> c = ignite.cache(null); IgniteCache<Integer, String> c = ignite.jcache(null);


for (int i = 0; i < cnt; i++) for (int i = 0; i < cnt; i++)
c.putx(i, Integer.toString(i)); c.put(i, Integer.toString(i));


return true; return true;
} }
}); });


for (int i = 0; i < gridCnt; i++) { for (int i = 0; i < gridCnt; i++) {
assertEquals(cnt, grid(i).cache(null).size()); assertEquals(cnt, internalCache(i).size());
assertEquals(cnt, grid(i).cache(null).size());
assertEquals(0, near(i).nearSize()); assertEquals(0, near(i).nearSize());
} }
} }
Expand All @@ -155,23 +155,23 @@ public void testNearEnabledThreeNodes() throws Exception {
private Ignite ignite; private Ignite ignite;


@Override public Object call() throws Exception { @Override public Object call() throws Exception {
GridCache<Integer, String> c = ignite.cache(null); IgniteCache<Integer, String> c = ignite.jcache(null);


for (int i = 0; i < cnt; i++) for (int i = 0; i < cnt; i++)
c.putx(i, Integer.toString(i)); c.put(i, Integer.toString(i));


return true; return true;
} }
}); });


for (int i = 0; i < gridCnt; i++) { for (int i = 0; i < gridCnt; i++) {
final Ignite g = grid(i); final GridCacheAdapter cache = internalCache(i);


// Repeatedly check cache sizes because of concurrent cache updates. // Repeatedly check cache sizes because of concurrent cache updates.
assertTrue(GridTestUtils.waitForCondition(new PA() { assertTrue(GridTestUtils.waitForCondition(new PA() {
@Override public boolean apply() { @Override public boolean apply() {
// Every node contains either near, backup, or primary. // Every node contains either near, backup, or primary.
return cnt == g.cache(null).size(); return cnt == cache.size();
} }
}, getTestTimeout())); }, getTestTimeout()));


Expand Down

0 comments on commit 244e604

Please sign in to comment.