Sounds like what you need is FiberStub - http://code.google.com/p/jetlang/source/browse/trunk/src/main/java/org/jetlang/fibers/FiberStub.java - I use this extensively for my integration / functional testing. With FiberStub you call executeAllPending / executeAllScheduled to trigger events in the queue. A little trick is you may need to call these several times if a particular behavior involves more than one Jetlang event.
Mike
> --
> You received this message because you are subscribed to the Google Groups "jetlang-dev" group.
> To post to this group, send email to jetla...@googlegroups.com.
> To unsubscribe from this group, send email to jetlang-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jetlang-dev?hl=en.
>
@Test
public void requestReplyWithBlockingQueue() throws InterruptedException {
Fiber fiber = new ThreadFiber();
fiber.start();
BlockingQueue<String> replyQueue = new ArrayBlockingQueue<String>(1);
MemoryChannel<BlockingQueue<String>> channel = new
MemoryChannel<BlockingQueue<String>>();
Callback<BlockingQueue<String>> replyCb = new
Callback<BlockingQueue<String>>() {
public void onMessage(BlockingQueue<String> message) {
try {
message.put("hello");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
};
channel.subscribe(fiber, replyCb);
channel.publish(replyQueue);
Assert.assertEquals("hello", replyQueue.poll(10, TimeUnit.SECONDS));
fiber.dispose();