use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class SlowMessageNotificationTest method testNotifyThreshold.
@Test
public void testNotifyThreshold() throws Exception {
SlowMessageNotification notif = new SlowMessageNotification();
final TimeInterval defaultThreshold = new TimeInterval(1L, TimeUnit.MINUTES);
assertNull(notif.getNotifyThreshold());
assertEquals(defaultThreshold.toMilliseconds(), notif.notifyThreshold());
TimeInterval newInterval = new TimeInterval(10L, TimeUnit.MINUTES);
notif.setNotifyThreshold(newInterval);
assertNotNull(notif.getNotifyThreshold());
assertEquals(newInterval, notif.getNotifyThreshold());
assertEquals(newInterval.toMilliseconds(), notif.notifyThreshold());
}
use of com.adaptris.util.TimeInterval 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.util.TimeInterval in project interlok by adaptris.
the class PluggableJdbcPooledConnectionTest method configure.
@Override
protected PluggableJdbcPooledConnection configure(PluggableJdbcPooledConnection conn1) throws Exception {
String url = initialiseDatabase();
conn1.setConnectUrl(url);
conn1.setDriverImp(DRIVER_IMP);
conn1.setConnectionAttempts(1);
conn1.setConnectionRetryInterval(new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
KeyValuePairSet poolProps = new KeyValuePairSet();
poolProps.add(new KeyValuePair("maximumPoolSize", "50"));
poolProps.add(new KeyValuePair("minimumIdle", "1"));
conn1.setPoolProperties(poolProps);
return conn1;
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class MessageCountNotificationTest method testNotification_BelowThreshold.
@Test
public void testNotification_BelowThreshold() throws Exception {
MessageCountNotification notif = new MessageCountNotification(getName(), new TimeInterval(200L, TimeUnit.MILLISECONDS));
notif.setMessageCount(2);
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, 6, 5);
LifecycleHelper.waitQuietly(200);
submitWithDelay(msg, workflow, 1, 0);
LifecycleHelper.waitQuietly(200);
submitWithDelay(msg, workflow, 1, 0);
LifecycleHelper.waitQuietly(200);
submitWithDelay(msg, workflow, 1, 0);
listener.waitForMessages(3);
assertEquals(3, listener.getNotifications().size());
Notification n1 = listener.getNotifications().get(0);
Notification n2 = listener.getNotifications().get(1);
assertTrue(n1.getMessage().startsWith(MessageCountNotification.NOTIF_MESSAGE_ABOVE_THRESHOLD));
assertTrue(n2.getMessage().startsWith(MessageCountNotification.NOTIF_MESSAGE_BELOW_THRESHOLD));
} finally {
stop(adapter);
}
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class MessageCountNotificationTest method testNotifyThreshold.
@Test
public void testNotifyThreshold() throws Exception {
MessageCountNotification notif = new MessageCountNotification();
final TimeInterval defaultThreshold = new TimeInterval(1L, TimeUnit.MINUTES);
assertNull(notif.getTimesliceDuration());
assertEquals(defaultThreshold.toMilliseconds(), notif.timesliceDurationMs());
TimeInterval newInterval = new TimeInterval(10L, TimeUnit.MINUTES);
notif.setTimesliceDuration(newInterval);
assertNotNull(notif.getTimesliceDuration());
assertEquals(newInterval, notif.getTimesliceDuration());
assertEquals(newInterval.toMilliseconds(), notif.timesliceDurationMs());
}
Aggregations