use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class SlowMessageNotificationTest method testNotification_SentAsPartOfCleanup.
@Test
public void testNotification_SentAsPartOfCleanup() throws Exception {
SlowMessageNotification notif = new SlowMessageNotification(getName(), new TimeInterval(100L, TimeUnit.MILLISECONDS), new TimeInterval(200L, TimeUnit.MILLISECONDS));
StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
workflow.getServiceCollection().add(new WaitService(new TimeInterval(500L, TimeUnit.MILLISECONDS)));
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();
workflow.onAdaptrisMessage(msg);
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification notification = listener.getNotifications().get(0);
Properties userData = (Properties) notification.getUserData();
assertEquals(msg.getUniqueId(), userData.getProperty(SlowMessageNotification.KEY_MESSAGE_ID));
assertEquals("-1", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_DURATION));
assertEquals("-1", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_END));
assertEquals("false", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_SUCCESS));
} finally {
stop(adapter);
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class SlowMessageNotificationTest method testNotification_SlowMessage_Failure.
@Test
public void testNotification_SlowMessage_Failure() throws Exception {
SlowMessageNotification notif = new SlowMessageNotification(getName(), new TimeInterval(100L, TimeUnit.MILLISECONDS));
StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
workflow.getServiceCollection().add(new WaitService(new TimeInterval(500L, TimeUnit.MILLISECONDS)));
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();
workflow.onAdaptrisMessage(msg);
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification notification = listener.getNotifications().get(0);
Properties userData = (Properties) notification.getUserData();
assertEquals(msg.getUniqueId(), userData.getProperty(SlowMessageNotification.KEY_MESSAGE_ID));
assertEquals("false", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_SUCCESS));
} finally {
stop(adapter);
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class SlowMessageNotificationWorkflowTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
Channel c = new Channel();
StandardWorkflow wf = new StandardWorkflow();
SlowMessageNotification ti = new SlowMessageNotification("SlowMessages_For_MyWorkflowName", new TimeInterval(30L, TimeUnit.SECONDS));
wf.addInterceptor(ti);
c.getWorkflowList().add(wf);
c.setUniqueId(UUID.randomUUID().toString());
wf.setUniqueId(UUID.randomUUID().toString());
return c;
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class LoggingContextInterceptorTest method testInterceptor_Defaults_NotAsObjectMetadata.
@Test
public void testInterceptor_Defaults_NotAsObjectMetadata() throws Exception {
LoggingContextWorkflowInterceptor interceptor = new LoggingContextWorkflowInterceptor(null);
StandardWorkflow wf = StatisticsMBeanCase.createWorkflow("workflowName", interceptor);
MockMessageProducer prod = new MockMessageProducer();
wf.setProducer(prod);
wf.getServiceCollection().add(new LoggingContextToMetadata());
MockChannel c = new MockChannel();
c.setUniqueId("channelName");
c.getWorkflowList().add(wf);
try {
BaseCase.start(c);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
wf.onAdaptrisMessage(msg);
Map<String, String> metadata = prod.getMessages().get(0).getMessageHeaders();
Map<Object, Object> object = prod.getMessages().get(0).getObjectHeaders();
assertTrue(metadata.containsKey(CoreConstants.CHANNEL_ID_KEY));
assertEquals("channelName", metadata.get(CoreConstants.CHANNEL_ID_KEY));
assertTrue(metadata.containsKey(CoreConstants.WORKFLOW_ID_KEY));
assertEquals("workflowName", metadata.get(CoreConstants.WORKFLOW_ID_KEY));
assertTrue(metadata.containsKey(CoreConstants.MESSAGE_UNIQUE_ID_KEY));
assertEquals(msg.getUniqueId(), metadata.get(CoreConstants.MESSAGE_UNIQUE_ID_KEY));
assertFalse(object.containsKey(CoreConstants.CHANNEL_ID_KEY));
assertFalse(object.containsKey(CoreConstants.WORKFLOW_ID_KEY));
assertFalse(object.containsKey(CoreConstants.MESSAGE_UNIQUE_ID_KEY));
} finally {
BaseCase.stop(c);
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class LoggingContextInterceptorTest method testInterceptor_NoDefaults.
@Test
public void testInterceptor_NoDefaults() throws Exception {
LoggingContextWorkflowInterceptor interceptor = new LoggingContextWorkflowInterceptor(null);
interceptor.setUseDefaultKeys(false);
StandardWorkflow wf = StatisticsMBeanCase.createWorkflow("workflowName", interceptor);
MockMessageProducer prod = new MockMessageProducer();
wf.setProducer(prod);
wf.getServiceCollection().add(new LoggingContextToMetadata());
MockChannel c = new MockChannel();
c.setUniqueId("channelName");
c.getWorkflowList().add(wf);
try {
BaseCase.start(c);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
wf.onAdaptrisMessage(msg);
Map<String, String> metadata = prod.getMessages().get(0).getMessageHeaders();
Map<Object, Object> object = prod.getMessages().get(0).getObjectHeaders();
assertFalse(metadata.containsKey(CoreConstants.CHANNEL_ID_KEY));
assertFalse(metadata.containsKey(CoreConstants.WORKFLOW_ID_KEY));
assertFalse(metadata.containsKey(CoreConstants.MESSAGE_UNIQUE_ID_KEY));
assertFalse(object.containsKey(CoreConstants.CHANNEL_ID_KEY));
assertFalse(object.containsKey(CoreConstants.WORKFLOW_ID_KEY));
assertFalse(object.containsKey(CoreConstants.MESSAGE_UNIQUE_ID_KEY));
} finally {
BaseCase.stop(c);
}
}
Aggregations