final BasicThreadingContext threading = BasicThreadingContext.create (this, exceptions, exceptions.catcher);
Assert.assertTrue (threading.initialize (AbacusTest.defaultPollTimeout));
final BasicCallbackReactor reactor = BasicCallbackReactor.create (threading, exceptions);
Assert.assertTrue (reactor.initialize (AbacusTest.defaultPollTimeout));
final DefaultChannelMessageCoder coder = DefaultChannelMessageCoder.defaultInstance;
final BasicChannel serverChannel = BasicChannel.create (pipe1.source (), pipe2.sink (), coder, reactor, threading, exceptions);
final BasicChannel clientChannel = BasicChannel.create (pipe2.source (), pipe1.sink (), coder, reactor, threading, exceptions);
final BasicComponent serverComponent = BasicComponent.create (reactor, exceptions);
final BasicComponent clientComponent = BasicComponent.create (reactor, exceptions);
Assert.assertTrue (serverChannel.initialize (AbacusTest.defaultPollTimeout));
Assert.assertTrue (clientChannel.initialize (AbacusTest.defaultPollTimeout));
Assert.assertTrue (serverComponent.initialize (AbacusTest.defaultPollTimeout));
Assert.assertTrue (clientComponent.initialize (AbacusTest.defaultPollTimeout));
final ComponentController serverComponentController = serverComponent.getController ();
final ComponentController clientComponentController = clientComponent.getController ();
final ComponentCallbacks serverComponentCallbacksProxy = reactor.createProxy (ComponentCallbacks.class);
final ComponentCallbacks clientComponentCallbacksProxy = reactor.createProxy (ComponentCallbacks.class);
Assert.assertTrue (serverComponentController.bind (serverComponentCallbacksProxy, serverChannel.getController ()).await (AbacusTest.defaultPollTimeout));
Assert.assertTrue (clientComponentController.bind (clientComponentCallbacksProxy, clientChannel.getController ()).await (AbacusTest.defaultPollTimeout));
final AbacusComponentCallbacks serverComponentCallbacks = new AbacusComponentCallbacks (ComponentEnvironment.create (ComponentIdentifier.standalone, this.getClass ().getClassLoader (), reactor, threading, exceptions));
final QueueingComponentCallbacks clientComponentCallbacks = QueueingComponentCallbacks.create (clientComponentController, exceptions);
final CallbackIsolate serverComponentCallbacksIsolate = reactor.createIsolate ();
final CallbackIsolate clientComponentCallbacksIsolate = reactor.createIsolate ();
Assert.assertTrue (reactor.assignHandler (serverComponentCallbacksProxy, serverComponentCallbacks, serverComponentCallbacksIsolate).await (AbacusTest.defaultPollTimeout));
Assert.assertTrue (reactor.assignHandler (clientComponentCallbacksProxy, clientComponentCallbacks, clientComponentCallbacksIsolate).await (AbacusTest.defaultPollTimeout));
final ComponentIdentifier peer = ComponentIdentifier.resolve (Strings.repeat ("00", 20));
for (int index = 0; index < AbacusTest.defaultTries; index++) {
final double operandA = (int) (Math.random () * 10);
final double operandB = (int) (Math.random () * 10);
final ComponentCallRequest request = ComponentCallRequest.create ("+", Arrays.asList (Double.valueOf (operandA), Double.valueOf (operandB)), ByteBuffer.allocate (0), ComponentCallReference.create ());
Assert.assertTrue (clientComponentController.call (peer, request).await (AbacusTest.defaultPollTimeout));
final ComponentCallReply reply = (ComponentCallReply) clientComponentCallbacks.queue.poll (AbacusTest.defaultPollTimeout, TimeUnit.MILLISECONDS);
Assert.assertNotNull (reply);
Assert.assertTrue (reply.ok);
Assert.assertNotNull (reply.outputsOrError);
Assert.assertEquals (request.reference, reply.reference);
Assert.assertTrue ((operandA + operandB) == ((Number) reply.outputsOrError).doubleValue ());
}
pipe1.sink ().close ();
pipe2.sink ().close ();
Assert.assertTrue (serverComponent.await (AbacusTest.defaultPollTimeout));
Assert.assertTrue (clientComponent.await (AbacusTest.defaultPollTimeout));
Assert.assertTrue (serverComponent.destroy (AbacusTest.defaultPollTimeout));
Assert.assertTrue (clientComponent.destroy (AbacusTest.defaultPollTimeout));
Assert.assertTrue (serverChannel.destroy (AbacusTest.defaultPollTimeout));
Assert.assertTrue (clientChannel.destroy (AbacusTest.defaultPollTimeout));
Assert.assertTrue (serverComponentCallbacksIsolate.destroy ().await (AbacusTest.defaultPollTimeout));
Assert.assertTrue (clientComponentCallbacksIsolate.destroy ().await (AbacusTest.defaultPollTimeout));
Assert.assertTrue (reactor.destroy (AbacusTest.defaultPollTimeout));
Assert.assertTrue (threading.destroy (AbacusTest.defaultPollTimeout));
Assert.assertNull (exceptionsQueue.queue.poll ());