use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class MessageThresholdNotificationTest method testNotification_SizeThresholdExceeded.
@Test
public void testNotification_SizeThresholdExceeded() throws Exception {
MessageThresholdNotification notif = new MessageThresholdNotification(getName());
notif.setSizeThreshold(1L);
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");
workflow.onAdaptrisMessage(msg);
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification notification = listener.getNotifications().get(0);
Properties userData = (Properties) notification.getUserData();
assertEquals("11", userData.getProperty(MessageThresholdNotification.KEY_MESSAGE_SIZE));
assertEquals("1", userData.getProperty(MessageThresholdNotification.KEY_MESSAGE_COUNT));
assertEquals("0", userData.getProperty(MessageThresholdNotification.KEY_MESSAGE_ERROR));
} finally {
stop(adapter);
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class MessageThresholdNotificationTest method testNotification_ErrorThresholdNotExceeded.
@Test
public void testNotification_ErrorThresholdNotExceeded() throws Exception {
MessageThresholdNotification notif = new MessageThresholdNotification(getName());
notif.setErrorThreshold(100L);
StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
workflow.getServiceCollection().add(new AlwaysFailService());
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");
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
} finally {
stop(adapter);
}
assertEquals(0, listener.getNotifications().size());
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class MessageThresholdNotificationTest method testNotification_NoNotifications.
@Test
public void testNotification_NoNotifications() throws Exception {
MessageThresholdNotification notif = new MessageThresholdNotification(getName());
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");
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
workflow.onAdaptrisMessage(msg);
} finally {
stop(adapter);
}
assertEquals(0, listener.getNotifications().size());
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class MessageThresholdNotificationWorkflowTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
Channel c = new Channel();
StandardWorkflow wf = new StandardWorkflow();
MessageThresholdNotification ti = new MessageThresholdNotification("MessageCount_For_MyWorkflowName");
ti.setTimesliceDuration(new TimeInterval(30L, TimeUnit.SECONDS));
ti.setCountThreshold(20L);
wf.addInterceptor(ti);
c.setUniqueId(UUID.randomUUID().toString());
wf.setUniqueId(UUID.randomUUID().toString());
c.getWorkflowList().add(wf);
return c;
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class MetadataCountWorkflowTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
Channel c = new Channel();
StandardWorkflow wf = new StandardWorkflow();
wf.setUniqueId("MyWorkflowName");
MetadataCountInterceptor ti = new MetadataCountInterceptor("metadatakey1");
ti.setUniqueId("Metrics_For_MyWorkflowName");
ti.setTimesliceDuration(new TimeInterval(60L, TimeUnit.SECONDS));
wf.addInterceptor(ti);
c.setUniqueId(UUID.randomUUID().toString());
wf.setUniqueId(UUID.randomUUID().toString());
c.getWorkflowList().add(wf);
return c;
}
Aggregations