Search in sources :

Example 1 with AdapterInitEvent

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

the class AdapterTest method testAdapterInitThrowsException.

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

        @Override
        public void init() throws CoreException {
            super.init();
            throw new CoreException();
        }
    });
    try {
        a.requestInit();
        fail();
    } catch (CoreException e) {
    }
    // if channel.init() fails, we never
    waitForMessages(mockEventProducer, 1);
    // send a StartUp Event.
    assertEquals(1, mockEventProducer.messageCount());
    Event event = EventFactory.createEvent(mockEventProducer.getMessages().get(0));
    assertEquals(AdapterInitEvent.class, event.getClass());
    assertEquals(false, ((AdapterInitEvent) 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