Search in sources :

Example 16 with TimeInterval

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());
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) Test(org.junit.Test)

Example 17 with TimeInterval

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;
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) TimeInterval(com.adaptris.util.TimeInterval) Channel(com.adaptris.core.Channel)

Example 18 with TimeInterval

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;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 19 with TimeInterval

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);
    }
}
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) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 20 with TimeInterval

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());
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) Test(org.junit.Test)

Aggregations

TimeInterval (com.adaptris.util.TimeInterval)310 Test (org.junit.Test)249 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)86 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)49 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)42 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)40 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)38 Channel (com.adaptris.core.Channel)36 MockChannel (com.adaptris.core.stubs.MockChannel)32 File (java.io.File)28 StandardWorkflow (com.adaptris.core.StandardWorkflow)27 Adapter (com.adaptris.core.Adapter)26 GuidGenerator (com.adaptris.util.GuidGenerator)25 FilenameFilter (java.io.FilenameFilter)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)24 StandaloneProducer (com.adaptris.core.StandaloneProducer)23 CoreException (com.adaptris.core.CoreException)22 WaitService (com.adaptris.core.services.WaitService)22 RandomAccessFile (java.io.RandomAccessFile)21 ObjectName (javax.management.ObjectName)21