CacheSPI<String, String> cache1 = cache1TL.get();
CacheSPI<String, String> cache2 = cache2TL.get();
NodeSPI<String, String> root1 = root1TL.get();
NodeSPI<String, String> root2 = root2TL.get();
Node node1 = root1.addChild(fqn);
TransactionManager mgr = cache1.getTransactionManager();
mgr.begin();
cache1.getInvocationContext().getOptionOverrides().reset();
node1.put(key, "value1");
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
node1.put(key, "value2");
mgr.commit();
delay();
// cache1 should still have this
assertEquals("value2", cache1.get(fqn, key));
if (!isInvalidation)
{
assertEquals("value1", cache2.get(fqn, key));
}
else
{
assertNull(cache2.get(fqn, key));
}
// now try again with passing the default options
mgr.begin();
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
node1.put(key, "value3");
cache1.getInvocationContext().getOptionOverrides().reset();
node1.put(key, "value");
mgr.commit();
delay();
// cache1 should still have this
assertEquals("value", cache1.get(fqn, key));
// cache 2 should as well
if (!isInvalidation)
{
assertEquals("value", cache2.get(fqn, key));
}
else
{
assertNull("should be invalidated", cache2.get(fqn, key));
}
// now cache2
Node node2 = root2.addChild(fqn);
mgr = cache2.getTransactionManager();
mgr.begin();
cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(false);
node2.put(key, "value3");
cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
node2.put(key, "value2");
mgr.commit();
delay();
assertEquals("value2", cache2.get(fqn, key));
if (!isInvalidation)
{
assertEquals("value3", cache1.get(fqn, key));
}
else
{
assertNull(cache1.get(fqn, key));
}
mgr.begin();
cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
node2.put(key, "value2");
cache2.getInvocationContext().getOptionOverrides().reset();
node2.put(key, "value4");
mgr.commit();
delay();
assertEquals("value4", cache2.get(fqn, key));
if (!isInvalidation)
{