Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sboikov committed Jan 20, 2015
1 parent 8a6387b commit 1eb8ba3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
Expand Up @@ -800,15 +800,22 @@ public void testTransformPessimisticRepeatableRead() throws Exception {
private void checkTransform(IgniteTxConcurrency concurrency, IgniteTxIsolation isolation) throws Exception {
IgniteCache<String, Integer> cache = jcache();

cache.put("key2", 1);
cache.put("key3", 3);
List<String> keys =
concurrency == OPTIMISTIC ? primaryKeysForCache(cache, 3) : Arrays.asList("key1", "key2", "key3");

String key1 = keys.get(0);
String key2 = keys.get(1);
String key3 = keys.get(2);

cache.put(key2, 1);
cache.put(key3, 3);

IgniteTx tx = txEnabled() ? ignite(0).transactions().txStart(concurrency, isolation) : null;

try {
assertEquals("null", cache.invoke("key1", INCR_PROCESSOR));
assertEquals("1", cache.invoke("key2", INCR_PROCESSOR));
assertEquals("3", cache.invoke("key3", RMV_PROCESSOR));
assertEquals("null", cache.invoke(key1, INCR_PROCESSOR));
assertEquals("1", cache.invoke(key2, INCR_PROCESSOR));
assertEquals("3", cache.invoke(key3, RMV_PROCESSOR));

if (tx != null)
tx.commit();
Expand All @@ -823,27 +830,27 @@ private void checkTransform(IgniteTxConcurrency concurrency, IgniteTxIsolation i
tx.close();
}

assertEquals((Integer)1, cache.get("key1"));
assertEquals((Integer)2, cache.get("key2"));
assertNull(cache.get("key3"));
assertEquals((Integer)1, cache.get(key1));
assertEquals((Integer)2, cache.get(key2));
assertNull(cache.get(key3));

for (int i = 0; i < gridCount(); i++)
assertNull("Failed for cache: " + i, cache(i).peek("key3"));
assertNull("Failed for cache: " + i, cache(i).peek(key3));

cache.remove("key1");
cache.put("key2", 1);
cache.put("key3", 3);
cache.remove(key1);
cache.put(key2, 1);
cache.put(key3, 3);

assertEquals("null", cache.invoke("key1", INCR_PROCESSOR));
assertEquals("1", cache.invoke("key2", INCR_PROCESSOR));
assertEquals("3", cache.invoke("key3", RMV_PROCESSOR));
assertEquals("null", cache.invoke(key1, INCR_PROCESSOR));
assertEquals("1", cache.invoke(key2, INCR_PROCESSOR));
assertEquals("3", cache.invoke(key3, RMV_PROCESSOR));

assertEquals((Integer)1, cache.get("key1"));
assertEquals((Integer)2, cache.get("key2"));
assertNull(cache.get("key3"));
assertEquals((Integer)1, cache.get(key1));
assertEquals((Integer)2, cache.get(key2));
assertNull(cache.get(key3));

for (int i = 0; i < gridCount(); i++)
assertNull(cache(i).peek("key3"));
assertNull(cache(i).peek(key3));
}

/**
Expand Down
Expand Up @@ -257,6 +257,8 @@ protected void testTxOriginatingNodeFails(Collection<Integer> keys, final boolea
CacheConfiguration cfg = super.cacheConfiguration(gridName);

cfg.setCacheStoreFactory(null);
cfg.setReadThrough(false);
cfg.setWriteThrough(false);

return cfg;
}
Expand Down

0 comments on commit 1eb8ba3

Please sign in to comment.