Search in sources :

Example 16 with MockConnection

use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.

the class ClosedStateTest method testRestart.

@Test
public void testRestart() throws Exception {
    MockConnection channel = new MockConnection();
    ClosedState state = ClosedState.getInstance();
    state.requestRestart(channel);
    assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
    assertEquals(1, channel.getInitCount());
    assertEquals(1, channel.getStartCount());
    assertEquals(0, channel.getStopCount());
    assertEquals(0, channel.getCloseCount());
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 17 with MockConnection

use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.

the class StoppedStateTest method testStopped_To_Started.

@Test
public void testStopped_To_Started() throws Exception {
    MockConnection component = new MockConnection();
    component.requestStart();
    component.requestStop();
    StoppedState state = StoppedState.getInstance();
    state.requestStart(component);
    assertEquals(StartedState.getInstance(), component.retrieveComponentState());
    assertEquals(1, component.getInitCount());
    assertEquals(2, component.getStartCount());
    assertEquals(1, component.getStopCount());
    assertEquals(0, component.getCloseCount());
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 18 with MockConnection

use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.

the class StoppedStateTest method testRestart.

@Test
public void testRestart() throws Exception {
    MockConnection component = new MockConnection();
    component.requestStart();
    component.requestStop();
    StoppedState state = StoppedState.getInstance();
    state.requestRestart(component);
    assertEquals(StartedState.getInstance(), component.retrieveComponentState());
    assertEquals(2, component.getInitCount());
    assertEquals(2, component.getStartCount());
    assertEquals(1, component.getStopCount());
    assertEquals(1, component.getCloseCount());
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 19 with MockConnection

use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.

the class StartedStateTest method testStarted_To_Initialised.

@Test
public void testStarted_To_Initialised() throws Exception {
    MockConnection component = new MockConnection();
    component.requestStart();
    StartedState state = StartedState.getInstance();
    state.requestInit(component);
    // redmineID #4453 - Started won't let you goto Initialised.
    assertEquals(StartedState.getInstance(), component.retrieveComponentState());
    assertEquals(1, component.getInitCount());
    assertEquals(1, component.getStartCount());
    assertEquals(0, component.getStopCount());
    assertEquals(0, component.getCloseCount());
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 20 with MockConnection

use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.

the class SharedComponentListTest method testAddConnection.

@Test
public void testAddConnection() throws Exception {
    SharedComponentList list = new SharedComponentList();
    try {
        list.addConnection(new MockConnection());
        fail();
    } catch (IllegalArgumentException expected) {
    }
    assertEquals(0, list.getConnections().size());
    try {
        list.addConnection(null);
        fail();
    } catch (IllegalArgumentException expected) {
    }
    assertEquals(0, list.getConnections().size());
    // Should have no effect as you're just adding to a clone.
    list.getConnections().add(new MockConnection());
    assertEquals(0, list.getConnections().size());
    list.addConnection(new MockConnection(getName()));
    assertFalse(list.addConnection(new MockConnection(getName())));
    assertEquals(1, list.getConnections().size());
}
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