Search in sources :

Example 26 with MockConnection

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

the class AdaptrisConnectionTest method testAddMessageConsumer.

@Test
public void testAddMessageConsumer() throws Exception {
    MockConnection mc = new MockConnection();
    List<MockMessageConsumer> consumers = createConsumers();
    mc.addMessageConsumer(null);
    for (MockMessageConsumer c : consumers) {
        mc.addMessageConsumer(c);
    }
    for (MockMessageConsumer c : consumers) {
        mc.addMessageConsumer(c);
    }
    assertEquals(mc.retrieveMessageConsumers().size(), consumers.size());
}
Also used : MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 27 with MockConnection

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

the class AdaptrisConnectionTest method testConnectionErrorHandler.

@Test
public void testConnectionErrorHandler() throws Exception {
    MockConnection mc = new MockConnection();
    assertNull(mc.getConnectionErrorHandler());
    NullConnectionErrorHandler nc = new NullConnectionErrorHandler();
    mc.setConnectionErrorHandler(nc);
    assertEquals(nc, mc.getConnectionErrorHandler());
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 28 with MockConnection

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

the class AdaptrisConnectionTest method testCloseWithWorkerLifecycle.

@Test
public void testCloseWithWorkerLifecycle() 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);
    }
    mc.setWorkersFirstOnShutdown(true);
    invoke(mc, INIT);
    invoke(producers, INIT);
    invoke(consumers, INIT);
    invoke(mc, START);
    invoke(producers, START);
    invoke(consumers, START);
    invoke(mc, STOP);
    assertState(producers, StoppedState.getInstance());
    assertState(consumers, StoppedState.getInstance());
    invoke(mc, CLOSE);
    assertState(producers, ClosedState.getInstance());
    assertState(consumers, ClosedState.getInstance());
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 29 with MockConnection

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

the class InitialisedStateTest method testInitialised_To_Stopped.

@Test
public void testInitialised_To_Stopped() throws Exception {
    MockConnection component = new MockConnection();
    component.requestInit();
    InitialisedState state = InitialisedState.getInstance();
    state.requestStop(component);
    // This actually should do nothing.
    assertEquals(InitialisedState.getInstance(), component.retrieveComponentState());
    assertEquals(1, component.getInitCount());
    assertEquals(0, component.getStopCount());
}
Also used : MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 30 with MockConnection

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

the class InitialisedStateTest method testInitialised_To_Closed.

@Test
public void testInitialised_To_Closed() throws Exception {
    MockConnection component = new MockConnection();
    component.requestInit();
    InitialisedState state = InitialisedState.getInstance();
    state.requestClose(component);
    assertEquals(ClosedState.getInstance(), component.retrieveComponentState());
    assertEquals(1, component.getInitCount());
    assertEquals(0, 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