assert cache1.get("key").equals("value1");
assert cache2.get("key").equals("value1");
}
public void testReplaceWithOldVal() {
AdvancedCache cache1 = cache(0,"replication").getAdvancedCache();
AdvancedCache cache2 = cache(1,"replication").getAdvancedCache();
cache2.withFlags(CACHE_MODE_LOCAL).put("key", "value2");
assert cache1.get("key") == null;
assert cache2.get("key").equals("value2");
cache1.replace("key", "valueOld", "value1"); // should do nothing since there is nothing to replace on cache1
assert cache1.get("key") == null;
assert cache2.get("key").equals("value2");
cache1.withFlags(CACHE_MODE_LOCAL).put("key", "valueN");
cache1.replace("key", "valueOld", "value1"); // should do nothing since there is nothing to replace on cache1
assert cache1.get("key").equals("valueN");
assert cache2.get("key").equals("value2");
expectRpc(cache2, ReplaceCommand.class);
cache1.replace("key", "valueN", "value1");
waitForRpc(cache2);
// the replace executed identically on both of them
assertEquals("value1", cache1.get("key"));
assertEquals("value1", cache2.get("key"));
}