use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class PoolingWorkflowTest method testOnMessage_SkipProducer.
@Test
public void testOnMessage_SkipProducer() throws Exception {
StaticMockMessageProducer serviceProducer = new StaticMockMessageProducer();
serviceProducer.getMessages().clear();
MockChannel channel = createAndPrepareChannel(Arrays.asList(new Service[] { createService(), new StandaloneProducer(serviceProducer), new MockSkipProducerService() }));
try {
PoolingWorkflow workflow = (PoolingWorkflow) channel.getWorkflowList().get(0);
MockMessageProducer workflowProducer = (MockMessageProducer) workflow.getProducer();
start(channel);
submitMessages(workflow, 10);
waitForMessages(serviceProducer, 10);
// assertEquals(10, serviceProducer.messageCount());
assertEquals(0, workflowProducer.messageCount());
} finally {
stop(channel);
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class PoolingWorkflowTest method testLessThanPoolSize.
@Test
public void testLessThanPoolSize() throws Exception {
MockChannel channel = createChannel();
PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
int count = wf.poolSize() - 1;
MockMessageProducer prod = (MockMessageProducer) wf.getProducer();
try {
start(channel);
submitMessages(wf, count);
waitForMessages(prod, count);
assertTrue("ObjectPool > 1", wf.currentObjectPoolCount() > 1);
assertTrue("ThreadPool > 1", wf.currentThreadPoolCount() > 1);
assertTrue("ObjectPool >=0", wf.currentlyIdleObjects() >= 0);
assertTrue("ThreadPool >=0", wf.currentlyActiveObjects() >= 0);
assertMessages(prod, count);
} finally {
stop(channel);
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class PoolingWorkflowTest method testHandleRuntimeException.
@Test
public void testHandleRuntimeException() throws Exception {
MockChannel channel = createChannel();
PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
MockMessageProducer meh = new MockMessageProducer();
MockMessageProducer prod = new MockMessageProducer() {
@Override
protected void doProduce(AdaptrisMessage msg, String endpoint) throws ProduceException {
throw new RuntimeException();
}
};
wf.setProducer(prod);
channel.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList<Service>(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
try {
start(channel);
submitMessages(wf, 1);
waitForMessages(meh, 1);
assertEquals(1, meh.messageCount());
} finally {
stop(channel);
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class PoolingWorkflowTest method createAndPrepareChannel.
private MockChannel createAndPrepareChannel(List<Service> services) throws Exception {
MockChannel channel = buildChannel(services);
LifecycleHelper.prepare(channel);
return channel;
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class PoolingWorkflowTest method testSingleMessage.
@Test
public void testSingleMessage() throws Exception {
MockChannel channel = createChannel();
PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
MockMessageProducer prod = (MockMessageProducer) wf.getProducer();
try {
start(channel);
submitMessages(wf, 1);
waitForMessages(prod, 1);
assertMessages(prod, 1);
} finally {
stop(channel);
}
}
Aggregations