use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class InitialisedStateTest method testInitialised_To_Initialised.
@Test
public void testInitialised_To_Initialised() throws Exception {
MockConnection component = new MockConnection();
component.requestInit();
InitialisedState state = InitialisedState.getInstance();
state.requestInit(component);
assertEquals(InitialisedState.getInstance(), component.retrieveComponentState());
assertEquals(1, component.getInitCount());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class FilteredSharedComponentStartTest method testFilteredStart_Excludes.
@Test
public void testFilteredStart_Excludes() throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(getName());
MockConnection sc1 = new MockConnection(getName() + "_1");
MockConnection sc2 = new MockConnection(getName() + "_2");
MockConnection sc3 = new MockConnection(getClass().getSimpleName() + "_1");
MockConnection sc4 = new MockConnection(getClass().getSimpleName() + "_2");
MockConnection sc5 = new MockConnection(getClass().getSimpleName() + "_3");
try {
adapter.getSharedComponents().addConnection(sc1);
adapter.getSharedComponents().addConnection(sc2);
adapter.getSharedComponents().addConnection(sc3);
adapter.getSharedComponents().addConnection(sc4);
adapter.getSharedComponents().addConnection(sc5);
assertEquals(5, adapter.getSharedComponents().getConnections().size());
FilteredSharedComponentStart starter = new FilteredSharedComponentStart();
starter.addExclude(".*" + getClass().getSimpleName() + ".*");
adapter.getSharedComponents().setLifecycleStrategy(starter);
adapter.requestInit();
assertEquals(InitialisedState.getInstance(), adapter.retrieveComponentState());
assertEquals(InitialisedState.getInstance(), sc1.retrieveComponentState());
assertEquals(InitialisedState.getInstance(), sc2.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc3.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc4.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc5.retrieveComponentState());
adapter.requestStart();
assertEquals(StartedState.getInstance(), adapter.retrieveComponentState());
assertEquals(StartedState.getInstance(), sc1.retrieveComponentState());
assertEquals(StartedState.getInstance(), sc2.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc3.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc4.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc5.retrieveComponentState());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class FilteredSharedComponentStartTest method testFilteredStart_Includes.
@Test
public void testFilteredStart_Includes() throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(getName());
MockConnection sc1 = new MockConnection(getName() + "_1");
MockConnection sc2 = new MockConnection(getName() + "_2");
MockConnection sc3 = new MockConnection(getClass().getSimpleName() + "_1");
MockConnection sc4 = new MockConnection(getClass().getSimpleName() + "_2");
MockConnection sc5 = new MockConnection(getClass().getSimpleName() + "_3");
try {
adapter.getSharedComponents().addConnection(sc1);
adapter.getSharedComponents().addConnection(sc2);
adapter.getSharedComponents().addConnection(sc3);
adapter.getSharedComponents().addConnection(sc4);
adapter.getSharedComponents().addConnection(sc5);
assertEquals(5, adapter.getSharedComponents().getConnections().size());
FilteredSharedComponentStart starter = new FilteredSharedComponentStart();
starter.addInclude(".*" + getName() + ".*");
adapter.getSharedComponents().setLifecycleStrategy(starter);
adapter.requestInit();
assertEquals(InitialisedState.getInstance(), adapter.retrieveComponentState());
assertEquals(InitialisedState.getInstance(), sc1.retrieveComponentState());
assertEquals(InitialisedState.getInstance(), sc2.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc3.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc4.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc5.retrieveComponentState());
adapter.requestStart();
assertEquals(StartedState.getInstance(), adapter.retrieveComponentState());
assertEquals(StartedState.getInstance(), sc1.retrieveComponentState());
assertEquals(StartedState.getInstance(), sc2.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc3.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc4.retrieveComponentState());
assertEquals(ClosedState.getInstance(), sc5.retrieveComponentState());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class StartedStateTest method testStarted_To_Started.
@Test
public void testStarted_To_Started() throws Exception {
MockConnection component = new MockConnection();
component.requestStart();
StartedState state = StartedState.getInstance();
state.requestStart(component);
// This will do nothing.
assertEquals(StartedState.getInstance(), component.retrieveComponentState());
assertEquals(1, component.getInitCount());
assertEquals(1, component.getStartCount());
assertEquals(0, component.getStopCount());
assertEquals(0, component.getCloseCount());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class StartedStateTest method testStarted_To_Closed.
@Test
public void testStarted_To_Closed() throws Exception {
MockConnection component = new MockConnection();
component.requestStart();
StartedState state = StartedState.getInstance();
state.requestClose(component);
assertEquals(ClosedState.getInstance(), component.retrieveComponentState());
assertEquals(1, component.getInitCount());
assertEquals(1, component.getStartCount());
assertEquals(1, component.getStopCount());
assertEquals(1, component.getCloseCount());
}
Aggregations