Search in sources :

Example 1 with AdapterStartEvent

use of com.adaptris.core.event.AdapterStartEvent in project interlok by adaptris.

the class AdapterTest method testAdapterStartThrowsException.

@Test
public void testAdapterStartThrowsException() throws Exception {
    MockMessageProducer mockEventProducer = new MockMessageProducer();
    Adapter a = createAdapter("testAdapterStartThrowsException", new DefaultEventHandler(mockEventProducer));
    a.getChannelList().add(new Channel() {

        @Override
        public void start() throws CoreException {
            super.start();
            throw new CoreException();
        }
    });
    a.requestInit();
    try {
        a.requestStart();
        fail();
    } catch (CoreException e) {
    }
    waitForMessages(mockEventProducer, 3);
    assertEquals(3, mockEventProducer.messageCount());
    Event event = EventFactory.createEvent(mockEventProducer.getMessages().get(2));
    assertEquals(AdapterStartEvent.class, event.getClass());
    assertEquals(false, ((AdapterStartEvent) event).getWasSuccessful());
    a.requestClose();
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdapterCloseEvent(com.adaptris.core.event.AdapterCloseEvent) StubAdapterStartUpEvent(com.adaptris.core.stubs.StubAdapterStartUpEvent) AdapterStopEvent(com.adaptris.core.event.AdapterStopEvent) AdapterInitEvent(com.adaptris.core.event.AdapterInitEvent) AdapterStartEvent(com.adaptris.core.event.AdapterStartEvent) Test(org.junit.Test)

Aggregations

AdapterCloseEvent (com.adaptris.core.event.AdapterCloseEvent)1 AdapterInitEvent (com.adaptris.core.event.AdapterInitEvent)1 AdapterStartEvent (com.adaptris.core.event.AdapterStartEvent)1 AdapterStopEvent (com.adaptris.core.event.AdapterStopEvent)1 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)1 StubAdapterStartUpEvent (com.adaptris.core.stubs.StubAdapterStartUpEvent)1 Test (org.junit.Test)1