use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class EventIpcManagerDefaultImplTest method testAddEventListenerAndBroadcast.
public void testAddEventListenerAndBroadcast() throws Exception {
EventBuilder bldr = new EventBuilder(null, "testAddEventListenerAndBroadcast");
Event event = bldr.getEvent();
m_mocks.replayAll();
m_manager.addEventListener(m_listener);
m_manager.broadcastNow(event, false);
Thread.sleep(100);
m_mocks.verifyAll();
assertTrue("could not remove broadcasted event--did it make it?", m_listener.getEvents().remove(event));
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class EventIpcManagerDefaultImplTest method testAddEventListenerTwoArgumentStringWithUeiPartTooMuchAndBroadcast.
public void testAddEventListenerTwoArgumentStringWithUeiPartTooMuchAndBroadcast() throws Exception {
EventBuilder bldr = new EventBuilder("uei.opennms.org/foo", "testAddEventListenerTwoArgumentStringWithUeiPartTooMuchAndBroadcast");
Event e = bldr.getEvent();
m_mocks.replayAll();
m_manager.addEventListener(m_listener, "uei.opennms.org/*");
m_manager.broadcastNow(e, false);
Thread.sleep(100);
m_mocks.verifyAll();
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class EventIpcManagerDefaultImplTest method testBroadcastNowSync.
public void testBroadcastNowSync() throws InterruptedException {
final AtomicInteger counter = new AtomicInteger();
final EventListener slowListener = new EventListener() {
@Override
public String getName() {
return "testBroadcastNowSync";
}
@Override
public void onEvent(Event event) {
try {
Thread.sleep(TimeUnit.SECONDS.toMillis(2));
} catch (InterruptedException e) {
}
counter.incrementAndGet();
}
};
EventIpcManagerDefaultImpl manager = new EventIpcManagerDefaultImpl(m_registry);
manager.setHandlerPoolSize(5);
DefaultEventHandlerImpl handler = new DefaultEventHandlerImpl(m_registry);
manager.setEventHandler(handler);
manager.afterPropertiesSet();
manager.addEventListener(slowListener);
EventBuilder bldr = new EventBuilder("uei.opennms.org/foo", "testBroadcastNowSync");
Event e = bldr.getEvent();
// Verify the initial state
assertEquals(0, counter.get());
// Broadcast synchronously - this should block until our event listener returns
manager.broadcastNow(e, true);
// broadcastNow() returned, so the counter should have been increased
assertEquals(1, counter.get());
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class EventIpcManagerDefaultImplTest method testBroadcastWithNoListeners.
public void testBroadcastWithNoListeners() throws Exception {
EventBuilder bldr = new EventBuilder(null, "testBroadcastWithNoListeners");
m_mocks.replayAll();
m_manager.broadcastNow(bldr.getEvent(), false);
Thread.sleep(100);
m_mocks.verifyAll();
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class EventIpcManagerDefaultImplTest method testAddEventListenerTwoArgumentStringWithUeiPartTooLittleAndBroadcast.
public void testAddEventListenerTwoArgumentStringWithUeiPartTooLittleAndBroadcast() throws Exception {
EventBuilder bldr = new EventBuilder("uei.opennms.org/foo", "testAddEventListenerTwoArgumentStringWithUeiPartTooLittleAndBroadcast");
Event e = bldr.getEvent();
m_mocks.replayAll();
m_manager.addEventListener(m_listener, "uei.opennms.org");
m_manager.broadcastNow(e, false);
Thread.sleep(100);
m_mocks.verifyAll();
}
Aggregations