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);
}
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);
}
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);
}
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();
}
Aggregations