use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class RetryMessageErrorHandlerTest method testBug854.
@Test
@SuppressWarnings("deprecation")
public void testBug854() throws Exception {
String name = renameThread("testBug854");
try {
MockMessageProducer failProducer = new MockMessageProducer();
RetryMessageErrorHandler meh = createMessageErrorHandler(failProducer);
meh.setRetryInterval(DEFAULT_RETRY_INTERVAL);
meh.setRetryLimit(0);
FailFirstMockMessageProducer workflowProducer = new FailFirstMockMessageProducer(1);
StandardWorkflow workflow = createWorkflow(workflowProducer);
workflow.setServiceCollection(new ServiceList());
workflow.setProduceExceptionHandler(new RestartProduceExceptionHandler());
Channel channel = new Channel();
channel.getWorkflowList().add(workflow);
channel.setProduceConnection(new MockConnection());
channel.getProduceConnection().setConnectionErrorHandler(new ChannelRestartConnectionErrorHandler());
Adapter adapter = new Adapter();
adapter.setUniqueId(new SimpleIdGenerator().create(this));
adapter.setMessageErrorHandler(meh);
adapter.getChannelList().addChannel(channel);
// adapter.prepare();
adapter.requestStart();
workflow.onAdaptrisMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage("XXXX"));
waitForMessages(workflowProducer, 1);
adapter.requestClose();
assertEquals("Ensure producer success", 1, workflowProducer.getMessages().size());
assertEquals("Should not have produced to failProducer", 0, failProducer.getMessages().size());
} finally {
renameThread(name);
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testGetConnections.
@Test
public void testGetConnections() throws Exception {
SharedComponentList list = new SharedComponentList();
List<AdaptrisConnection> good = Arrays.asList(new AdaptrisConnection[] { new MockConnection(getName()), new MockConnection(getName() + "_1") });
list.setConnections(good);
List<AdaptrisConnection> copy = list.getConnections();
copy.add(new NullConnection(getName()));
copy.add(new NullConnection(getName()));
copy.add(new NullConnection());
copy.add(new NullConnection());
// That should have no effect, and it should still be valid.
assertEquals(2, list.getConnections().size());
assertEquals(2, list.getConnectionIds().size());
try {
list.setConnections(copy);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(2, list.getConnections().size());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testContainsConnection.
@Test
public void testContainsConnection() throws Exception {
SharedComponentList list = new SharedComponentList();
List<AdaptrisConnection> good = Arrays.asList(new AdaptrisConnection[] { new MockConnection(getName()), new MockConnection(getName() + "_1") });
list.setConnections(good);
assertEquals(2, list.getConnections().size());
assertTrue(list.containsConnection(getName()));
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testRemoveConnection.
@Test
public void testRemoveConnection() throws Exception {
SharedComponentList list = new SharedComponentList();
List<AdaptrisConnection> good = Arrays.asList(new AdaptrisConnection[] { new MockConnection(getName()), new MockConnection(getName() + "_1") });
list.setConnections(good);
assertEquals(2, list.getConnections().size());
Collection<AdaptrisConnection> removed = list.removeConnection(getName());
assertEquals(1, removed.size());
assertFalse(list.containsConnection(getName()));
assertEquals(1, list.getConnections().size());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testConnectionState.
@Test
public void testConnectionState() throws Exception {
Adapter adapter = AdapterTest.createAdapter(getName());
MockConnection connection = new MockConnection(getName());
adapter.getSharedComponents().addConnection(connection);
StandaloneProducer producer = new StandaloneProducer(new SharedConnection(getName()), new NullMessageProducer());
StandardWorkflow workflow = (StandardWorkflow) adapter.getChannelList().getChannel(0).getWorkflowList().get(0);
workflow.getServiceCollection().add(producer);
start(adapter);
assertEquals(StartedState.getInstance(), connection.retrieveComponentState());
LifecycleHelper.stop(adapter);
assertEquals(StoppedState.getInstance(), connection.retrieveComponentState());
LifecycleHelper.close(adapter);
assertEquals(ClosedState.getInstance(), connection.retrieveComponentState());
}
Aggregations