Code example for ArrayBlockingQueue

Methods: add

0
    private final ArrayBlockingQueue<Message> messages = new ArrayBlockingQueue<Message>(
            1); 
 
    @Override 
    public void processMessage(Chat chat, Message message) {
        messages.add(message);
    } 
 
    public void receivesAMessage(Matcher<? super String> messageMatcher)
            throws InterruptedException { 
        final Message message = messages.poll(10, TimeUnit.SECONDS);
        assertThat("Message", message, is(notNullValue()));
        assertThat(message.getBody(), messageMatcher);
 
    } 
}