Re: Is it possible to have write NonBlocking Junit tests
Colin Vipurs <[email protected]> Thu, 10 Apr 2014 18:32:43 +0100
| Newsgroups | gmane.comp.java.junit.user |
|---|---|
| Message-ID | <CAKi4273twX35iRgMg95Lyw+pBHprsBQRqo1tcLa+Cx4HFT3wrw@mail.gmail.com> |
You could use a locking mechanism shared between your test and handler so
that progress continues as quick as possible and then put an overall
timeout on your test in the event of failure.
Something like this should work just fine:
@Test
public void testAsync() throws Exception {
final Semaphore lock = new Semaphore(0);
someAsyncCode(new Handler() {
public void handle() {
// put your assertions in here
lock.release();
}
});
lock.acquire();
}
On Thu, Apr 10, 2014 at 4:21 PM, <[email protected]> wrote:
>
>
> I am writing a Junit tests for Amqp Message Listener.This is how the test
> is written.I send a message to a exchange and introduce a delay of 1s
> (assuming that the listener will do its job within that time frame).This
> approach slows down the build process as there 15-20 tests like these which
> take a minimum of 20 seconds to execute.Is there a way in which I can do
> this is a non blocking way.For pass a call handler which verifies the tests
> after the listener does it job.Something like Actors might be internally
> used
>
>
--
Maybe she awoke to see the roommate's boyfriend swinging from the
chandelier wearing a boar's head.
Something which you, I, and everyone else would call "Tuesday", of course.