use of net.dempsy.transport.SenderFactory in project Dempsy by Dempsy.
the class BlockingQueueTest method testBlockingQueue.
/*
* Test basic functionality for the BlockingQueue implementation of Message Transport. Verify that messages sent to the Sender arrive at the receiver via
* handleMessage.
*/
@Test
public void testBlockingQueue() throws Exception {
final AtomicReference<String> message = new AtomicReference<String>(null);
final ArrayBlockingQueue<Object> input = new ArrayBlockingQueue<>(16);
try (final Receiver r = new BlockingQueueReceiver(input);
final TestInfrastructure infra = new TestInfrastructure(new DefaultThreadingModel("BQTest-testBlockingQueue-"));
final TransportManager tranMan = chain(new TransportManager(), c -> c.start(infra));
SenderFactory sf = tranMan.getAssociatedInstance(transportTypeId)) {
final Sender sender = sf.getSender(r.getAddress(infra));
r.start((final String msg) -> {
message.set(new String(msg));
return true;
}, infra);
sender.send("Hello");
assertTrue(poll(o -> "Hello".equals(message.get())));
}
}
Aggregations