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();

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

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

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

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

Expand Down Expand Up @@ -170,7 +162,7 @@ public void testAffinitySingleNode() throws Exception {
try {
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));

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

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

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

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

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 {
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
grid(0).cache(null).get(nearKey());
grid(0).jcache(null).get(nearKey());

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

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

int cnt = 100;

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());
Expand All @@ -121,18 +122,17 @@ public void testNearEnabledTwoNodes() throws Exception {
private Ignite ignite;

@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++)
c.putx(i, Integer.toString(i));
c.put(i, Integer.toString(i));

return true;
}
});

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

@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++)
c.putx(i, Integer.toString(i));
c.put(i, Integer.toString(i));

return true;
}
});

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.
assertTrue(GridTestUtils.waitForCondition(new PA() {
@Override public boolean apply() {
// Every node contains either near, backup, or primary.
return cnt == g.cache(null).size();
return cnt == cache.size();
}
}, getTestTimeout()));

Expand Down

0 comments on commit 244e604

Please sign in to comment.