use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class MemberFunctionExecutionDUnitTest method testOnMembersWithoutCache.
@Test
public void testOnMembersWithoutCache() throws Exception {
DistributedMember member1Id = (DistributedMember) member1.invoke(new SerializableCallable() {
@Override
public Object call() {
disconnectFromDS();
return getSystem().getDistributedMember();
}
});
member2.invoke(new SerializableRunnable() {
@Override
public void run() {
getSystem();
ResultCollector<?, ?> rc = FunctionService.onMember(member1Id).execute(new FunctionAdapter() {
@Override
public String getId() {
return getClass().getName();
}
@Override
public void execute(FunctionContext context) {
// This will throw an exception because the cache is not yet created.
CacheFactory.getAnyInstance();
}
});
try {
rc.getResult(30, TimeUnit.SECONDS);
fail("Should have seen an exception");
} catch (Exception e) {
if (!(e.getCause() instanceof FunctionInvocationTargetException)) {
Assert.fail("failed", e);
}
}
}
});
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class PRClientServerRegionFunctionExecutionDUnitTest method testClientWithoutPool_Bug41832.
@Test
public void testClientWithoutPool_Bug41832() {
createScenarioWith2Regions();
Function function = new TestFunction(true, TEST_FUNCTION2);
registerFunctionAtServer(function);
isByName = new Boolean(true);
toRegister = new Boolean(true);
SerializableRunnable suspect = new SerializableRunnable() {
public void run() {
cache.getLogger().info("<ExpectedException action=add>" + "No target node found for KEY = " + "|Server could not send the reply" + "|Unexpected exception during" + "</ExpectedException>");
}
};
runOnAllServers(suspect);
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.serverSingleKeyExecutionWith2Regions(isByName, toRegister));
SerializableRunnable endSuspect = new SerializableRunnable() {
public void run() {
cache.getLogger().info("<ExpectedException action=remove>" + "No target node found for KEY = " + "|Server could not send the reply" + "|Unexpected exception during" + "</ExpectedException>");
}
};
runOnAllServers(endSuspect);
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class MultiRegionFunctionExecutionDUnitTest method postTearDownCacheTestCase.
@Override
public final void postTearDownCacheTestCase() throws Exception {
cache = null;
Invoke.invokeInEveryVM(new SerializableRunnable() {
public void run() {
cache = null;
}
});
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class PRClientServerRegionFunctionExecutionDUnitTest method testServerSingleKeyExecution_byName_WithoutRegister.
@Test
public void testServerSingleKeyExecution_byName_WithoutRegister() {
createScenario();
Function function = new TestFunction(true, TEST_FUNCTION2);
registerFunctionAtServer(function);
isByName = new Boolean(true);
toRegister = new Boolean(false);
SerializableRunnable suspect = new SerializableRunnable() {
public void run() {
cache.getLogger().info("<ExpectedException action=add>" + "No target node found for KEY = " + "|Server could not send the reply" + "|Unexpected exception during" + "</ExpectedException>");
}
};
runOnAllServers(suspect);
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.serverSingleKeyExecution(isByName, toRegister));
SerializableRunnable endSuspect = new SerializableRunnable() {
public void run() {
cache.getLogger().info("<ExpectedException action=remove>" + "No target node found for KEY = " + "|Server could not send the reply" + "|Unexpected exception during" + "</ExpectedException>");
}
};
runOnAllServers(endSuspect);
}
use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.
the class PRTransactionDUnitTest method resumeTx.
@SuppressWarnings("serial")
private SerializableRunnable resumeTx(Op op, TransactionId txId, DistributedMember dm1, DistributedMember dm2) {
return new SerializableRunnable("resume tx") {
@Override
public void run() {
PartitionedRegion pr = (PartitionedRegion) basicGetCache().getRegion(Region.SEPARATOR + OrderPartitionedRegionName);
CacheTransactionManager mgr = basicGetCache().getCacheTransactionManager();
moveBucket(op, dm1, dm2);
Assertions.assertThatThrownBy(() -> _resumeTx(op, txId, pr, mgr)).isInstanceOf(TransactionDataRebalancedException.class);
}
};
}
Aggregations