Search in sources :

Example 91 with TimeInterval

use of com.adaptris.util.TimeInterval in project interlok by adaptris.

the class RequestReplyWorkflowTest method testSetReplyTimeout.

@Test
public void testSetReplyTimeout() throws Exception {
    TimeInterval defaultInterval = new TimeInterval(30L, TimeUnit.SECONDS);
    TimeInterval interval = new TimeInterval(60L, TimeUnit.SECONDS);
    RequestReplyWorkflow workflow = new RequestReplyWorkflow();
    assertNull(workflow.getReplyTimeout());
    assertEquals(defaultInterval.toMilliseconds(), workflow.replyTimeout());
    workflow.setReplyTimeout(interval);
    assertEquals(interval, workflow.getReplyTimeout());
    assertEquals(interval.toMilliseconds(), workflow.replyTimeout());
    workflow.setReplyTimeout(null);
    assertNull(workflow.getReplyTimeout());
    assertEquals(defaultInterval.toMilliseconds(), workflow.replyTimeout());
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) Test(org.junit.Test)

Example 92 with TimeInterval

use of com.adaptris.util.TimeInterval in project interlok by adaptris.

the class PoolingWorkflowTest method testHandleChannelUnavailableForever.

@Test
public void testHandleChannelUnavailableForever() throws Exception {
    MockMessageProducer producer = new MockMessageProducer();
    final MockChannel channel = createChannel();
    PoolingWorkflow workflow = (PoolingWorkflow) channel.getWorkflowList().get(0);
    MockMessageProducer meh = new MockMessageProducer();
    try {
        workflow.setChannelUnavailableWaitInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS));
        workflow.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList<Service>(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
        start(channel);
        channel.toggleAvailability(false);
        workflow.onAdaptrisMessage(msg);
        assertEquals("Make none produced", 0, producer.getMessages().size());
        assertEquals(1, meh.getMessages().size());
    } finally {
        stop(channel);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) StaticMockMessageProducer(com.adaptris.core.stubs.StaticMockMessageProducer) TimeInterval(com.adaptris.util.TimeInterval) WaitService(com.adaptris.core.services.WaitService) XmlRoundTripService(com.adaptris.core.stubs.XmlRoundTripService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) Test(org.junit.Test)

Example 93 with TimeInterval

use of com.adaptris.util.TimeInterval in project interlok by adaptris.

the class PoolingWorkflowTest method testMinIdle_Changes_MaxIdle.

@Test
public void testMinIdle_Changes_MaxIdle() throws Exception {
    MockChannel channel = createChannel();
    PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
    wf.setPoolSize(1000);
    wf.setMaxIdle(10);
    wf.setMinIdle(100);
    wf.setThreadKeepAlive(new TimeInterval(100L, TimeUnit.MILLISECONDS));
    LifecycleHelper.init(channel);
    assertEquals(100, wf.maxIdle());
    LifecycleHelper.close(channel);
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) TimeInterval(com.adaptris.util.TimeInterval) Test(org.junit.Test)

Example 94 with TimeInterval

use of com.adaptris.util.TimeInterval in project interlok by adaptris.

the class PoolingWorkflowTest method testFixedPoolsizeOnStart.

@Test
public void testFixedPoolsizeOnStart() throws Exception {
    MockChannel channel = createChannel();
    PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
    wf.setMaxIdle(DEFAULT_MAX_POOLSIZE);
    wf.setMinIdle(DEFAULT_MAX_POOLSIZE);
    wf.setThreadKeepAlive(new TimeInterval(100L, TimeUnit.MILLISECONDS));
    try {
        start(channel);
        Thread.sleep(200);
        assertTrue("ObjectPool >= 10", wf.currentObjectPoolCount() >= 1);
        assertTrue("ObjectPool idle >= 1", wf.currentlyIdleObjects() >= 1);
    } finally {
        stop(channel);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) TimeInterval(com.adaptris.util.TimeInterval) Test(org.junit.Test)

Example 95 with TimeInterval

use of com.adaptris.util.TimeInterval in project interlok by adaptris.

the class RetryMessageErrorHandlerTest method testSetRetryInterval.

@Test
public void testSetRetryInterval() throws Exception {
    RetryMessageErrorHandler meh = new RetryMessageErrorHandler();
    TimeInterval defaultInterval = new TimeInterval(10L, TimeUnit.MINUTES);
    TimeInterval interval = new TimeInterval(20L, TimeUnit.SECONDS);
    assertNull(meh.getRetryInterval());
    assertEquals(defaultInterval.toMilliseconds(), meh.retryIntervalMs());
    meh.setRetryInterval(interval);
    assertEquals(interval, meh.getRetryInterval());
    assertEquals(interval.toMilliseconds(), meh.retryIntervalMs());
    meh.setRetryInterval(null);
    assertNull(meh.getRetryInterval());
    assertEquals(defaultInterval.toMilliseconds(), meh.retryIntervalMs());
}
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