use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class AdaptrisConnectionTest method testAddMessageConsumer.
@Test
public void testAddMessageConsumer() throws Exception {
MockConnection mc = new MockConnection();
List<MockMessageConsumer> consumers = createConsumers();
mc.addMessageConsumer(null);
for (MockMessageConsumer c : consumers) {
mc.addMessageConsumer(c);
}
for (MockMessageConsumer c : consumers) {
mc.addMessageConsumer(c);
}
assertEquals(mc.retrieveMessageConsumers().size(), consumers.size());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class AdaptrisConnectionTest method testConnectionErrorHandler.
@Test
public void testConnectionErrorHandler() throws Exception {
MockConnection mc = new MockConnection();
assertNull(mc.getConnectionErrorHandler());
NullConnectionErrorHandler nc = new NullConnectionErrorHandler();
mc.setConnectionErrorHandler(nc);
assertEquals(nc, mc.getConnectionErrorHandler());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class AdaptrisConnectionTest method testCloseWithWorkerLifecycle.
@Test
public void testCloseWithWorkerLifecycle() throws Exception {
MockConnection mc = new MockConnection();
List<MockMessageConsumer> consumers = createConsumers();
List<MockMessageProducer> producers = createProducers();
for (MockMessageConsumer c : consumers) {
mc.addMessageConsumer(c);
}
for (MockMessageProducer c : producers) {
mc.addMessageProducer(c);
}
mc.setWorkersFirstOnShutdown(true);
invoke(mc, INIT);
invoke(producers, INIT);
invoke(consumers, INIT);
invoke(mc, START);
invoke(producers, START);
invoke(consumers, START);
invoke(mc, STOP);
assertState(producers, StoppedState.getInstance());
assertState(consumers, StoppedState.getInstance());
invoke(mc, CLOSE);
assertState(producers, ClosedState.getInstance());
assertState(consumers, ClosedState.getInstance());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class InitialisedStateTest method testInitialised_To_Stopped.
@Test
public void testInitialised_To_Stopped() throws Exception {
MockConnection component = new MockConnection();
component.requestInit();
InitialisedState state = InitialisedState.getInstance();
state.requestStop(component);
// This actually should do nothing.
assertEquals(InitialisedState.getInstance(), component.retrieveComponentState());
assertEquals(1, component.getInitCount());
assertEquals(0, component.getStopCount());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class InitialisedStateTest method testInitialised_To_Closed.
@Test
public void testInitialised_To_Closed() throws Exception {
MockConnection component = new MockConnection();
component.requestInit();
InitialisedState state = InitialisedState.getInstance();
state.requestClose(component);
assertEquals(ClosedState.getInstance(), component.retrieveComponentState());
assertEquals(1, component.getInitCount());
assertEquals(0, component.getStartCount());
assertEquals(0, component.getStopCount());
assertEquals(1, component.getCloseCount());
}
Aggregations