use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class PoolingWorkflowTest method testHandleChannelUnavailable.
@Test
public void testHandleChannelUnavailable() throws Exception {
final MockChannel channel = createChannel();
PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
MockMessageProducer prod = (MockMessageProducer) wf.getProducer();
try {
wf.setChannelUnavailableWaitInterval(new TimeInterval(1200L, TimeUnit.MILLISECONDS));
start(channel);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("");
Timer t = new Timer(true);
channel.toggleAvailability(false);
t.schedule(new TimerTask() {
@Override
public void run() {
channel.toggleAvailability(true);
}
}, 500);
wf.onAdaptrisMessage(msg);
waitForMessages(prod, 1);
assertEquals(1, prod.messageCount());
} finally {
stop(channel);
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class PoolingWorkflowTest method testMaxIdle_CannotExceed_Poolsize.
@Test
public void testMaxIdle_CannotExceed_Poolsize() throws Exception {
MockChannel channel = createChannel();
PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
wf.setMaxIdle(100);
wf.setThreadKeepAlive(new TimeInterval(100L, TimeUnit.MILLISECONDS));
LifecycleHelper.init(channel);
assertEquals(10, wf.poolSize());
assertEquals(10, wf.maxIdle());
assertEquals(DEFAULT_MIN_IDLE, wf.minIdle());
LifecycleHelper.close(channel);
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class PoolingWorkflowTest method testFixedPoolsizeAfterProcessing.
@Test
public void testFixedPoolsizeAfterProcessing() 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));
int count = wf.poolSize() * 2;
MockMessageProducer prod = (MockMessageProducer) wf.getProducer();
try {
start(channel);
submitMessages(wf, count);
waitForMessages(prod, count);
Thread.sleep(200);
assertTrue("ObjectPool >= 10", wf.currentObjectPoolCount() >= 1);
assertTrue("ObjectPool idle >= 1", wf.currentlyIdleObjects() >= 1);
assertMessages(prod, count);
} finally {
stop(channel);
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class GaussianIntervalPollerTest method testLifecycle.
@Test
public void testLifecycle() throws Exception {
PollingTrigger consumer = new PollingTrigger();
consumer.setPoller(new GaussianIntervalPoller(new TimeInterval(0L, TimeUnit.SECONDS), new TimeInterval(100L, TimeUnit.MILLISECONDS)));
MockMessageProducer producer = new MockMessageProducer();
MockChannel channel = new MockChannel();
StandardWorkflow workflow = new StandardWorkflow();
workflow.setConsumer(consumer);
workflow.setProducer(producer);
channel.getWorkflowList().add(workflow);
try {
channel.requestClose();
channel.requestStart();
waitForMessages(producer, 1);
channel.requestStop();
producer.getMessages().clear();
channel.requestStart();
waitForMessages(producer, 1);
channel.requestClose();
producer.getMessages().clear();
channel.requestStart();
waitForMessages(producer, 1);
} finally {
channel.requestClose();
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class RequestReplyWorkflowTest method createChannel.
// private RequestReplyWorkflow workFlow;
// private MockMessageConsumer consumer;
// private MockRequestReplyProducer producer;
// private MockMessageProducer replyProducer;
private Channel createChannel() throws Exception {
Channel channel = new MockChannel();
MockMessageConsumer consumer = new MockMessageConsumer();
MockRequestReplyProducer producer = new MockRequestReplyProducer();
MockMessageProducer replyProducer = new MockMessageProducer();
RequestReplyWorkflow workFlow = new RequestReplyWorkflow();
workFlow.setConsumer(consumer);
workFlow.setProducer(producer);
workFlow.setReplyProducer(replyProducer);
channel.getWorkflowList().addWorkflow(workFlow);
channel.prepare();
return channel;
}
Aggregations