use of org.apache.geode.cache.CacheWriter in project geode by apache.
the class RemoveGlobalDUnitTest method testRemoveGlobalMultiVM.
// end of testRemoveGlobalSingleVM
@Test
public void testRemoveGlobalMultiVM() throws Throwable {
// Commented the Test.As it is failing @ line no 145 : AssertionError
SerializableRunnable createSimpleRegion = new CacheSerializableRunnable("create region with cache writer") {
public void run2() throws CacheException {
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.GLOBAL);
region = cache.createRegion("map", factory.create());
}
};
SerializableRunnable createRegionWithWriter = new CacheSerializableRunnable("create region with capacity controller") {
public void run2() throws CacheException {
CacheWriter cw = new CacheWriterCallBack();
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.GLOBAL);
factory.setCacheWriter(cw);
region = cache.createRegion("map", factory.create());
}
};
vm0.invoke(createSimpleRegion);
vm1.invoke(createRegionWithWriter);
vm0.invoke(new CacheSerializableRunnable("put object") {
public void run2() throws CacheException {
for (int i = 1; i < 5; i++) {
region.put(new Integer(i), java.lang.Integer.toString(i));
}
}
});
vm1.invoke(new CacheSerializableRunnable("get object") {
public void run2() throws CacheException {
for (int i = 1; i < 5; i++) {
region.get(new Integer(i));
}
}
});
AsyncInvocation async = vm0.invokeAsync(new CacheSerializableRunnable("remove object") {
public void run2() throws CacheException {
region.remove(new Integer(2));
}
});
vm1.invoke(new CacheSerializableRunnable("verify locking") {
public void run2() throws CacheException {
cache.setLockTimeout(5);
synchronized (RemoveGlobalDUnitTest.class) {
if (!lockedForRemove) {
try {
RemoveGlobalDUnitTest.class.wait();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
try {
// getLogWriter().fine("11111111111111");
region.put(new Integer(2), "newEntry");
fail("Should have thrown TimeoutException");
} catch (TimeoutException tme) {
// pass
}
}
});
ThreadUtils.join(async, 30 * 1000);
if (async.exceptionOccurred())
throw async.getException();
}
Aggregations