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());
}
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);
}
}
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);
}
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);
}
}
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());
}
Aggregations