Search in sources :

Example 11 with MockMessageConsumer

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

the class ConnectionErrorHandlerTest method testAdaptrisComponentConnectionErrorHandler.

@Test
public void testAdaptrisComponentConnectionErrorHandler() throws Exception {
    MockStandaloneConsumer c = new MockStandaloneConsumer(new TriggeredFailingConnection(), new MockMessageConsumer(new MockMessageListener()));
    start(c);
    ((TriggeredFailingConnection) c.getConnection()).triggerError();
    assertEquals(2, c.getInitCount());
    assertEquals(2, c.getStartCount());
    assertEquals(1, c.getStopCount());
    assertEquals(1, c.getCloseCount());
    stop(c);
}
Also used : MockStandaloneConsumer(com.adaptris.core.stubs.MockStandaloneConsumer) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) Test(org.junit.Test)

Example 12 with MockMessageConsumer

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

the class ConnectionErrorHandlerTest method testAdaptrisComponentNullConnectionErrorHandler.

@Test
public void testAdaptrisComponentNullConnectionErrorHandler() throws Exception {
    MockStandaloneConsumer c = new MockStandaloneConsumer(new TriggeredFailingConnection(new NullConnectionErrorHandler()), new MockMessageConsumer(new MockMessageListener()));
    start(c);
    ((TriggeredFailingConnection) c.getConnection()).triggerError();
    assertEquals(1, c.getInitCount());
    assertEquals(1, c.getStartCount());
    assertEquals(0, c.getStopCount());
    assertEquals(0, c.getCloseCount());
    stop(c);
}
Also used : MockStandaloneConsumer(com.adaptris.core.stubs.MockStandaloneConsumer) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) Test(org.junit.Test)

Example 13 with MockMessageConsumer

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

the class ConnectionErrorHandlerTest method testStateManagedComponentNullConnectionErrorHandler.

@Test
public void testStateManagedComponentNullConnectionErrorHandler() throws Exception {
    MockStandaloneConsumer c = new StateManagedStandaloneConsumer(new TriggeredFailingConnection(new NullConnectionErrorHandler()), new MockMessageConsumer(new MockMessageListener()));
    start(c);
    ((TriggeredFailingConnection) c.getConnection()).triggerError();
    assertEquals(1, c.getInitCount());
    assertEquals(1, c.getStartCount());
    assertEquals(0, c.getStopCount());
    assertEquals(0, c.getCloseCount());
    stop(c);
}
Also used : StateManagedStandaloneConsumer(com.adaptris.core.stubs.StateManagedStandaloneConsumer) MockStandaloneConsumer(com.adaptris.core.stubs.MockStandaloneConsumer) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) Test(org.junit.Test)

Example 14 with MockMessageConsumer

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

the class AdaptrisConnectionTest method testCloseWithoutWorkferLifecycle.

@Test
public void testCloseWithoutWorkferLifecycle() 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);
    }
    invoke(mc, INIT);
    invoke(producers, INIT);
    invoke(consumers, INIT);
    invoke(mc, START);
    invoke(producers, START);
    invoke(consumers, START);
    invoke(mc, STOP);
    assertState(producers, StartedState.getInstance());
    assertState(consumers, StartedState.getInstance());
    invoke(producers, STOP);
    invoke(consumers, STOP);
    invoke(mc, CLOSE);
    assertState(producers, StoppedState.getInstance());
    assertState(consumers, StoppedState.getInstance());
    invoke(producers, CLOSE);
    invoke(consumers, CLOSE);
}
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 15 with MockMessageConsumer

use of com.adaptris.core.stubs.MockMessageConsumer 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)

Aggregations

MockMessageConsumer (com.adaptris.core.stubs.MockMessageConsumer)31 Test (org.junit.Test)20 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)18 MockChannel (com.adaptris.core.stubs.MockChannel)10 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)5 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)4 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)4 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)4 MockStandaloneConsumer (com.adaptris.core.stubs.MockStandaloneConsumer)4 MockConnection (com.adaptris.core.stubs.MockConnection)3 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)3 StandardWorkflow (com.adaptris.core.StandardWorkflow)2 MockRequestReplyProducer (com.adaptris.core.stubs.MockRequestReplyProducer)2 StateManagedStandaloneConsumer (com.adaptris.core.stubs.StateManagedStandaloneConsumer)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 AdaptrisMessageConsumer (com.adaptris.core.AdaptrisMessageConsumer)1 AdaptrisMessageProducer (com.adaptris.core.AdaptrisMessageProducer)1 Channel (com.adaptris.core.Channel)1 Service (com.adaptris.core.Service)1 ServiceImp (com.adaptris.core.ServiceImp)1