use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method defaultCollectorThrowsExceptionAfterFunctionReturnsIllegalStateExceptionAsIntermediateResult.
@Test()
public void defaultCollectorThrowsExceptionAfterFunctionReturnsIllegalStateExceptionAsIntermediateResult() {
// GEODE-1762 - clients throw from execute, but peers throw from rc.getResult
// GEODE-1762 - client throws a ServerOperationException
thrown.expect(Exception.class);
// thrown.expect(FunctionException.class);
// thrown.expectCause(isA(IllegalStateException.class));
ResultCollector rc = getExecution().execute((context) -> {
context.getResultSender().sendResult(new IllegalStateException());
context.getResultSender().lastResult("done");
});
final Object result = rc.getResult();
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method customCollectorDoesNotSeeExceptionFunctionThrowsFunctionException.
@Test
public void customCollectorDoesNotSeeExceptionFunctionThrowsFunctionException() {
// GEODE-1762 - clients throw from execute, but peers throw from rc.getResult
try {
ResultCollector rc = getExecution().withCollector(customCollector).execute((context) -> {
throw new FunctionException();
});
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 FunctionServiceBase method defaultCollectorThrowsExceptionAfterFunctionThrowsFunctionException.
@Test()
public void defaultCollectorThrowsExceptionAfterFunctionThrowsFunctionException() {
// GEODE-1762 - clients throw from execute, but peers throw from rc.getResult
thrown.expect(FunctionException.class);
ResultCollector rc = getExecution().execute((context) -> {
throw new FunctionException();
});
final Object result = rc.getResult();
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method defaultCollectorReturnsSingleResult.
@Test
public void defaultCollectorReturnsSingleResult() {
ResultCollector rc = getExecution().execute((context) -> {
context.getResultSender().lastResult("done");
});
List<String> results = (List<String>) rc.getResult();
assertEquals(numberOfExecutions(), results.size());
results.stream().forEach(element -> assertEquals("done", element));
}
use of org.apache.geode.cache.execute.ResultCollector in project geode by apache.
the class FunctionServiceBase method defaultCollectorThrowsExceptionAfterFunctionReturnsIllegalStateException.
/**
* Tests what happens if a function returns an exception as a result. This is kind a weird, but it
* seems that the default collector will just throw it as an exception
*/
@Test()
public void defaultCollectorThrowsExceptionAfterFunctionReturnsIllegalStateException() {
// GEODE-1762 - clients throw from execute, but peers throw from rc.getResult
// GEODE-1762 - clients throw a ServerOperationException
thrown.expect(Exception.class);
// thrown.expect(FunctionException.class);
// thrown.expectCause(isA(IllegalStateException.class));
ResultCollector rc = getExecution().execute((context) -> {
context.getResultSender().lastResult(new IllegalStateException());
});
final Object result = rc.getResult();
}
Aggregations