use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testLifecycle_Stop.
@Test
public void testLifecycle_Stop() throws Exception {
SharedComponentList list = new SharedComponentList();
List<AdaptrisConnection> good = Arrays.asList(new AdaptrisConnection[] { new MockConnection(getName()), new MockConnection(getName() + "_1") });
list.setConnections(good);
try {
LifecycleHelper.init(list);
LifecycleHelper.start(list);
LifecycleHelper.stop(list);
assertEquals(2, list.getConnections().size());
for (AdaptrisConnection c : list.getConnections()) {
assertEquals(StoppedState.getInstance(), c.retrieveComponentState());
}
} finally {
stop(list);
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class ClosedStateTest method testClosed_To_Closed.
@Test
public void testClosed_To_Closed() throws Exception {
MockConnection channel = new MockConnection();
ClosedState state = ClosedState.getInstance();
state.requestClose(channel);
// This actually should do nothing.
assertEquals(ClosedState.getInstance(), channel.retrieveComponentState());
assertEquals(0, channel.getInitCount());
assertEquals(0, channel.getStartCount());
assertEquals(0, channel.getStopCount());
assertEquals(0, channel.getCloseCount());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class ComponentStateCase method testStateChange_MultiThreaded.
// This is to check that we don't trigger the requestXXX operation multiple times.
//
@Test
public void testStateChange_MultiThreaded() throws Exception {
MockConnection connection = new MockConnection(1000);
ComponentState expected = createState();
prepareConn(connection);
new Thread(createOperator(connection)).start();
new Thread(createOperator(connection)).start();
new Thread(createOperator(connection)).start();
new Thread(createOperator(connection)).start();
new Thread(createOperator(connection)).start();
waitFor(connection, expected);
assertEquals(expected, connection.retrieveComponentState());
verifyOperation(connection);
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class AdaptrisConnectionTest method testCloseWithoutWorkferLifecycle.
@Test
public void testCloseWithoutWorkferLifecycle() 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);
}
invoke(mc, INIT);
invoke(producers, INIT);
invoke(consumers, INIT);
invoke(mc, START);
invoke(producers, START);
invoke(consumers, START);
invoke(mc, STOP);
assertState(producers, StartedState.getInstance());
assertState(consumers, StartedState.getInstance());
invoke(producers, STOP);
invoke(consumers, STOP);
invoke(mc, CLOSE);
assertState(producers, StoppedState.getInstance());
assertState(consumers, StoppedState.getInstance());
invoke(producers, CLOSE);
invoke(consumers, CLOSE);
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class AdaptrisConnectionTest method testAddMessageProducers.
@Test
public void testAddMessageProducers() throws Exception {
MockConnection mc = new MockConnection();
List<MockMessageProducer> producers = createProducers();
mc.addMessageProducer(null);
for (MockMessageProducer c : producers) {
mc.addMessageProducer(c);
}
for (MockMessageProducer c : producers) {
mc.addMessageProducer(c);
}
assertEquals(mc.retrieveMessageProducers().size(), producers.size());
}
Aggregations