use of org.apache.flink.runtime.rpc.RpcEndpoint in project flink by apache.
the class AkkaRpcActorTest method testMessageDiscarding.
/**
* Tests that the {@link AkkaRpcActor} discards messages until the corresponding
* {@link RpcEndpoint} has been started.
*/
@Test
public void testMessageDiscarding() throws Exception {
int expectedValue = 1337;
DummyRpcEndpoint rpcEndpoint = new DummyRpcEndpoint(akkaRpcService);
DummyRpcGateway rpcGateway = rpcEndpoint.getSelf();
// this message should be discarded and completed with an AkkaRpcException
Future<Integer> result = rpcGateway.foobar();
try {
result.get(timeout.getSize(), timeout.getUnit());
fail("Expected an AkkaRpcException.");
} catch (ExecutionException ee) {
// expected this exception, because the endpoint has not been started
assertTrue(ee.getCause() instanceof AkkaRpcException);
}
// set a new value which we expect to be returned
rpcEndpoint.setFoobar(expectedValue);
// start the endpoint so that it can process messages
rpcEndpoint.start();
// send the rpc again
result = rpcGateway.foobar();
// now we should receive a result :-)
Integer actualValue = result.get(timeout.getSize(), timeout.getUnit());
assertThat("The new foobar value should have been returned.", actualValue, Is.is(expectedValue));
rpcEndpoint.shutDown();
}
Aggregations