Search in sources :

Example 16 with SimpleNotificationListener

use of com.adaptris.core.runtime.SimpleNotificationListener in project interlok by adaptris.

the class MessageCountNotificationTest method testNotification_NoNotifications.

@Test
public void testNotification_NoNotifications() throws Exception {
    MessageCountNotification notif = new MessageCountNotification(getName(), new TimeInterval(10L, TimeUnit.SECONDS));
    StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
    Adapter adapter = createAdapter(getName(), workflow);
    List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
    BaseComponentMBean notifier = getFirstImpl(mBeans, InterceptorNotificationMBean.class);
    assertNotNull(notifier);
    ObjectName notifObjName = notifier.createObjectName();
    SimpleNotificationListener listener = new SimpleNotificationListener();
    try {
        start(adapter);
        register(mBeans);
        mBeanServer.addNotificationListener(notifObjName, listener, null, null);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World");
        submitWithDelay(msg, workflow, 5, 5);
    } finally {
        stop(adapter);
    }
    assertEquals(0, listener.getNotifications().size());
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) StandardWorkflow(com.adaptris.core.StandardWorkflow) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleNotificationListener(com.adaptris.core.runtime.SimpleNotificationListener) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

Adapter (com.adaptris.core.Adapter)16 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)16 StandardWorkflow (com.adaptris.core.StandardWorkflow)16 BaseComponentMBean (com.adaptris.core.runtime.BaseComponentMBean)16 SimpleNotificationListener (com.adaptris.core.runtime.SimpleNotificationListener)16 ObjectName (javax.management.ObjectName)16 Test (org.junit.Test)16 Notification (javax.management.Notification)10 TimeInterval (com.adaptris.util.TimeInterval)9 Properties (java.util.Properties)6 AlwaysFailService (com.adaptris.core.services.AlwaysFailService)3 WaitService (com.adaptris.core.services.WaitService)3