use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method defaultCollectorReturnsResultOfSendException.
@Test
public void defaultCollectorReturnsResultOfSendException() {
ResultCollector rc = getExecution().execute((context) -> {
context.getResultSender().sendException(new IllegalStateException());
});
final List<Object> result = (List<Object>) rc.getResult();
assertEquals(numberOfExecutions(), result.size());
result.stream().forEach(element -> assertEquals(IllegalStateException.class, element.getClass()));
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method customCollectorDoesNotSeeExceptionAfterFunctionReturnsIllegalStateException.
@Test
public void customCollectorDoesNotSeeExceptionAfterFunctionReturnsIllegalStateException() {
// GEODE-1762 - clients throw from execute, but peers throw from rc.getResult
try {
ResultCollector rc = getExecution().execute((context) -> {
context.getResultSender().lastResult(new IllegalStateException());
});
rc.getResult();
fail("should have received an exception");
// GEODE-1762 - clients throw a ServerOperationException
} catch (Exception expected) {
}
Assert.assertEquals(0, customCollector.getResult().size());
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method customCollectorReturnsResultOfSendException.
// GEODE-1981
@Category(FlakyTest.class)
@Test
public void customCollectorReturnsResultOfSendException() {
ResultCollector rc = getExecution().withCollector(customCollector).execute((context) -> {
context.getResultSender().sendException(new IllegalStateException());
});
final List<Object> result = (List<Object>) rc.getResult();
assertEquals(numberOfExecutions(), result.size());
result.stream().forEach(element -> assertEquals(IllegalStateException.class, element.getClass()));
assertEquals(result, customCollector.getResult());
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class MyFunctionException method executeFunctionFunctionInvocationTargetExceptionWithoutHA.
public static void executeFunctionFunctionInvocationTargetExceptionWithoutHA() {
try {
ResultCollector rc1 = FunctionService.onRegion(region).setArguments(Boolean.TRUE).execute("DistribuedRegionFunctionFunctionInvocationException", true, false);
rc1.getResult();
fail("Function Invocation Target Exception should be thrown");
} catch (Exception e) {
e.printStackTrace();
if (!(e.getCause() instanceof FunctionInvocationTargetException)) {
fail("FunctionInvocationTargetException should be thrown");
}
}
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class MyFunctionException method executeFunctionFunctionInvocationTargetException.
public static void executeFunctionFunctionInvocationTargetException() {
try {
ResultCollector rc1 = FunctionService.onRegion(region).setArguments(Boolean.TRUE).execute("DistribuedRegionFunctionFunctionInvocationException");
List list = (ArrayList) rc1.getResult();
assertEquals(5, list.get(0));
} catch (Exception e) {
e.printStackTrace();
Assert.fail("This is not expected Exception", e);
}
}
Aggregations