use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testGetConnectionIds.
@Test
public void testGetConnectionIds() 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());
assertEquals(2, list.getConnectionIds().size());
assertTrue(list.getConnectionIds().contains(getName()));
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testConnectionState_SharedConnectionState.
@Test
public void testConnectionState_SharedConnectionState() throws Exception {
Adapter adapter = AdapterTest.createAdapter(getName());
MockConnection connection = new MockConnection();
connection.setUniqueId(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());
stop(producer);
assertNotSame(ClosedState.getInstance(), connection.retrieveComponentState());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testLifecycle_Close.
@Test
public void testLifecycle_Close() 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);
LifecycleHelper.close(list);
assertEquals(2, list.getConnections().size());
for (AdaptrisConnection c : list.getConnections()) {
assertEquals(ClosedState.getInstance(), c.retrieveComponentState());
}
} finally {
stop(list);
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testInterlok_1096.
// FilteredStart was removing connections
// from the underlying list.
@Test
public void testInterlok_1096() throws Exception {
SharedComponentList list = new SharedComponentList();
List<AdaptrisConnection> good = Arrays.asList(new AdaptrisConnection[] { new MockConnection(getName()), new MockConnection(getName() + "_1") });
list.setConnections(new ArrayList<>(good));
FilteredSharedComponentStart starter = new FilteredSharedComponentStart();
starter.addExclude(getName());
starter.addExclude(getName() + "_1");
list.setLifecycleStrategy(starter);
try {
LifecycleHelper.init(list);
LifecycleHelper.start(list);
assertEquals(2, list.getConnections().size());
for (AdaptrisConnection c : good) {
assertEquals(ClosedState.getInstance(), c.retrieveComponentState());
}
} finally {
stop(list);
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class InitialisedStateTest method testRestart.
@Test
public void testRestart() throws Exception {
MockConnection component = new MockConnection();
component.requestInit();
InitialisedState state = InitialisedState.getInstance();
state.requestRestart(component);
assertEquals(StartedState.getInstance(), component.retrieveComponentState());
assertEquals(2, component.getInitCount());
assertEquals(1, component.getStartCount());
assertEquals(0, component.getStopCount());
assertEquals(1, component.getCloseCount());
}
Aggregations