Search in sources :

Example 1 with AnnotationBasedEventListenerAdapter

use of org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter in project opennms by OpenNMS.

the class AccessPointMonitordTest method setUp.

@Before
public void setUp() throws Exception {
    // Create our event manager and anticipator
    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setSynchronous(true);
    // Ensure our annotations are called
    m_adapter = new AnnotationBasedEventListenerAdapter(m_apm, m_eventMgr);
}
Also used : MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) AnnotationBasedEventListenerAdapter(org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter) Before(org.junit.Before)

Example 2 with AnnotationBasedEventListenerAdapter

use of org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter in project opennms by OpenNMS.

the class InstanceStrategyIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    // Initialise the SNMP peer
    SnmpPeerFactory.setInstance(m_snmpPeerFactory);
    // Create our event manager and anticipator
    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setSynchronous(true);
    // Ensure our annotations are called
    m_adapter = new AnnotationBasedEventListenerAdapter(m_apm, m_eventMgr);
}
Also used : MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) AnnotationBasedEventListenerAdapter(org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter) Before(org.junit.Before)

Example 3 with AnnotationBasedEventListenerAdapter

use of org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter in project opennms by OpenNMS.

the class AnnotationBasedEventListenerAdapterTest method setUp.

/* (non-Javadoc)
     * @see junit.framework.TestCase#setUp()
     */
@Before
public void setUp() throws Exception {
    m_mockUtils = new EasyMockUtils();
    m_eventIpcMgr = m_mockUtils.createMock(EventSubscriptionService.class);
    m_annotatedListener = new AnnotatedListener();
    m_adapter = new AnnotationBasedEventListenerAdapter();
    m_adapter.setAnnotatedListener(m_annotatedListener);
    m_adapter.setEventSubscriptionService(m_eventIpcMgr);
    m_subscriptions = new HashSet<String>();
    Collections.addAll(m_subscriptions, EventConstants.NODE_DOWN_EVENT_UEI, EventConstants.ADD_NODE_EVENT_UEI, EventConstants.NODE_LOST_SERVICE_EVENT_UEI);
    m_eventIpcMgr.addEventListener(m_adapter, m_subscriptions);
}
Also used : EventSubscriptionService(org.opennms.netmgt.events.api.EventSubscriptionService) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) AnnotationBasedEventListenerAdapter(org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter) Before(org.junit.Before)

Example 4 with AnnotationBasedEventListenerAdapter

use of org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter in project opennms by OpenNMS.

the class AnnotationBasedEventListenerAdapterTest method testDerivedClass.

@Test
public void testDerivedClass() throws Exception {
    AnnotationBasedEventListenerAdapter adapter = new AnnotationBasedEventListenerAdapter();
    // expect a subscription for the new adapter
    m_eventIpcMgr.addEventListener(adapter, m_subscriptions);
    m_mockUtils.replayAll();
    // finish expectations for the old adapter
    m_adapter.afterPropertiesSet();
    // setup the derivied listener
    DerivedListener derivedListener = new DerivedListener();
    adapter.setAnnotatedListener(derivedListener);
    adapter.setEventSubscriptionService(m_eventIpcMgr);
    adapter.afterPropertiesSet();
    assertEquals(0, derivedListener.preProcessedEvents);
    assertEquals(0, derivedListener.receivedEventCount);
    assertEquals(0, derivedListener.postProcessedEvents);
    adapter.onEvent(createEvent(EventConstants.NODE_DOWN_EVENT_UEI));
    assertEquals(1, derivedListener.preProcessedEvents);
    assertEquals(1, derivedListener.receivedEventCount);
    assertEquals(1, derivedListener.postProcessedEvents);
    m_mockUtils.verifyAll();
}
Also used : AnnotationBasedEventListenerAdapter(org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter) Test(org.junit.Test)

Aggregations

AnnotationBasedEventListenerAdapter (org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter)4 Before (org.junit.Before)3 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)2 Test (org.junit.Test)1 EventSubscriptionService (org.opennms.netmgt.events.api.EventSubscriptionService)1 EasyMockUtils (org.opennms.test.mock.EasyMockUtils)1