Search in sources :

Example 6 with MockConnection

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()));
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 7 with MockConnection

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());
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 8 with MockConnection

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);
    }
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 9 with MockConnection

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);
    }
}
Also used : FilteredSharedComponentStart(com.adaptris.core.lifecycle.FilteredSharedComponentStart) MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 10 with MockConnection

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());
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Aggregations

MockConnection (com.adaptris.core.stubs.MockConnection)49 Test (org.junit.Test)49 Adapter (com.adaptris.core.Adapter)7 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)5 TimeInterval (com.adaptris.util.TimeInterval)5 TimeoutException (java.util.concurrent.TimeoutException)5 ObjectName (javax.management.ObjectName)5 MockMessageConsumer (com.adaptris.core.stubs.MockMessageConsumer)3 FilteredSharedComponentStart (com.adaptris.core.lifecycle.FilteredSharedComponentStart)1 ChannelRestartConnectionErrorHandler (com.adaptris.core.stubs.ChannelRestartConnectionErrorHandler)1 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)1 MockChannel (com.adaptris.core.stubs.MockChannel)1 SimpleIdGenerator (com.adaptris.util.SimpleIdGenerator)1