public void testPessimisticNonTransactionalAsync() throws Exception
{
TreeCache cache1 = createUnstartedCache( false );
TreeCache cache2 = createUnstartedCache( false );
cache1.setCacheMode(TreeCache.INVALIDATION_ASYNC);
cache2.setCacheMode(TreeCache.INVALIDATION_ASYNC);
cache1.startService();
cache2.startService();
Fqn fqn = Fqn.fromString("/a/b");
cache1.put(fqn, "key", "value");
TestingUtil.sleepThread(500); // give it time to broadcast the evict call
// test that this has NOT replicated, but rather has been invalidated:
Assert.assertEquals("value", cache1.get(fqn, "key"));
Assert.assertNull("Should NOT have replicated!", cache2.get(fqn));
log.info("***** Node not replicated, as expected.");
// now make sure cache2 is in sync with cache1:
cache2.put(fqn, "key", "value");
TestingUtil.sleepThread(500); // give it time to broadcast the evict call
Assert.assertNull("Should be null", cache1.get(fqn));
Assert.assertEquals("value", cache2.get(fqn, "key"));
// now test the invalidation:
cache1.put(fqn, "key2", "value2");
Assert.assertEquals("value2", cache1.get(fqn, "key2"));
TestingUtil.sleepThread(500); // give it time to broadcast the evict call
Assert.assertNull("Should have been invalidated!", cache2.get(fqn));
// clean up.
cache1.stopService();
cache2.stopService();
cache1 = null;
cache2 = null;
}