Search in sources :

Example 1 with QueueNotificationListener

use of org.apache.qpid.server.model.QueueNotificationListener in project qpid-broker-j by apache.

the class AbstractQueueTestBase method testNotificationFiredOnEnqueue.

@Test
public void testNotificationFiredOnEnqueue() throws Exception {
    QueueNotificationListener listener = mock(QueueNotificationListener.class);
    _queue.setNotificationListener(listener);
    _queue.setAttributes(Collections.<String, Object>singletonMap(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, Integer.valueOf(2)));
    _queue.enqueue(createMessage(Long.valueOf(24)), null, null);
    verifyNoInteractions(listener);
    _queue.enqueue(createMessage(Long.valueOf(25)), null, null);
    verify(listener, atLeastOnce()).notifyClients(eq(NotificationCheck.MESSAGE_COUNT_ALERT), eq(_queue), contains("Maximum count on queue threshold"));
}
Also used : QueueNotificationListener(org.apache.qpid.server.model.QueueNotificationListener) Test(org.junit.Test)

Example 2 with QueueNotificationListener

use of org.apache.qpid.server.model.QueueNotificationListener in project qpid-broker-j by apache.

the class AbstractQueueTestBase method testNotificationFiredAsync.

@Test
public void testNotificationFiredAsync() throws Exception {
    QueueNotificationListener listener = mock(QueueNotificationListener.class);
    _queue.enqueue(createMessage(Long.valueOf(24)), null, null);
    _queue.enqueue(createMessage(Long.valueOf(25)), null, null);
    _queue.enqueue(createMessage(Long.valueOf(26)), null, null);
    _queue.setNotificationListener(listener);
    _queue.setAttributes(Collections.<String, Object>singletonMap(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, Integer.valueOf(2)));
    verifyNoInteractions(listener);
    _queue.checkMessageStatus();
    verify(listener, atLeastOnce()).notifyClients(eq(NotificationCheck.MESSAGE_COUNT_ALERT), eq(_queue), contains("Maximum count on queue threshold"));
}
Also used : QueueNotificationListener(org.apache.qpid.server.model.QueueNotificationListener) Test(org.junit.Test)

Aggregations

QueueNotificationListener (org.apache.qpid.server.model.QueueNotificationListener)2 Test (org.junit.Test)2