use of io.joynr.provider.AbstractSubscriptionPublisher in project joynr by bmwcarit.
the class DispatcherImplTest method addRequestCallerDoesNotBlock.
@Test
public void addRequestCallerDoesNotBlock() throws InterruptedException, ExecutionException, TimeoutException {
final Callable<Boolean> stuffToDo = new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
try {
String requestReplyId = UUID.randomUUID().toString();
RequestCaller requestCaller = mock(RequestCaller.class);
AbstractSubscriptionPublisher subscriptionPublisher = mock(AbstractSubscriptionPublisher.class);
/* setBlockInitialisation to true causes the messageReceiver to block
* during startup
* The MessageReceiver is invoked by the dispatcher once a request caller
* is registered
*
*/
messageReceiverMock.setBlockOnInitialisation(true);
requestCallerDirectory.add(requestReplyId, new ProviderContainer("interfaceName", DispatcherImplTest.class, requestCaller, subscriptionPublisher));
} finally {
messageReceiverMock.setBlockOnInitialisation(false);
}
return true;
}
};
final ExecutorService executor = Executors.newSingleThreadExecutor();
final Future<Boolean> future = executor.submit(stuffToDo);
// should not throw a timeout exception
future.get(1000, TimeUnit.MILLISECONDS);
verify(messageReceiverMock).start(eq(fixture), any(ReceiverStatusListener.class));
}
Aggregations