use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method defaultCollectorReturnsResultOfSendFunctionException.
@Test
public void defaultCollectorReturnsResultOfSendFunctionException() {
ResultCollector rc = getExecution().execute((context) -> {
context.getResultSender().sendException(new FunctionException());
});
final List<Object> result = (List<Object>) rc.getResult();
assertEquals(numberOfExecutions(), result.size());
result.stream().forEach(element -> assertEquals(FunctionException.class, element.getClass()));
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method defaultCollectorThrowsExceptionAfterFunctionThrowsIllegalState.
@Test()
public void defaultCollectorThrowsExceptionAfterFunctionThrowsIllegalState() {
// GEODE-1762 - clients throw from execute, but peers throw from rc.getResult
thrown.expect(FunctionException.class);
// GEODE-1762 - clients wrap cause in a ServerOperationException
// thrown.expectCause(isA(IllegalStateException.class));
ResultCollector rc = getExecution().execute((context) -> {
throw new IllegalStateException();
});
final Object result = rc.getResult();
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method customCollectorReturnsResultOfSendFunctionException.
// GEODE-1827
@Category(FlakyTest.class)
@Test
public void customCollectorReturnsResultOfSendFunctionException() {
ResultCollector rc = getExecution().withCollector(customCollector).execute((context) -> {
context.getResultSender().sendException(new FunctionException());
});
final List<Object> result = (List<Object>) rc.getResult();
assertEquals(numberOfExecutions(), result.size());
result.stream().forEach(element -> assertEquals(FunctionException.class, element.getClass()));
assertEquals(result, customCollector.getResult());
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method customCollectorDoesNotSeeExceptionFunctionThrowsIllegalState.
@Test
public void customCollectorDoesNotSeeExceptionFunctionThrowsIllegalState() {
// GEODE-1762 - clients throw from execute, but peers throw from rc.getResult
try {
ResultCollector rc = getExecution().withCollector(customCollector).execute((context) -> {
throw new IllegalStateException();
});
rc.getResult();
fail("should have received an exception");
} catch (FunctionException expected) {
}
Assert.assertEquals(0, customCollector.getResult().size());
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class ClientServerFunctionExecutionDUnitTest method executeRegisteredFunction.
public static void executeRegisteredFunction() {
DistributedSystem.setThreadsSocketPolicy(false);
Execution member = FunctionService.onServer(pool);
// remove any existing attributes
((AbstractExecution) member).removeFunctionAttributes(TestFunction.TEST_FUNCTION1);
ResultCollector rs = member.setArguments(Boolean.TRUE).execute(TestFunction.TEST_FUNCTION1);
assertEquals(Boolean.TRUE, ((List) rs.getResult()).get(0));
byte[] functionAttributes = ((AbstractExecution) member).getFunctionAttributes(TestFunction.TEST_FUNCTION1);
assertNotNull(functionAttributes);
}
Aggregations