use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method bringDownCritSvcs.
private void bringDownCritSvcs(MockElement element) {
MockVisitor markCritSvcDown = new MockVisitorAdapter() {
@Override
public void visitService(MockService svc) {
if ("ICMP".equals(svc.getSvcName())) {
svc.bringDown();
}
}
};
element.visit(markCritSvcDown);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerIT method testNullInterfaceOnNodeDown.
@Test
public void testNullInterfaceOnNodeDown() {
// NODE processing = true;
m_pollerConfig.setNodeOutageProcessingEnabled(true);
MockNode node = m_network.getNode(2);
MockService icmpService = m_network.getService(2, "192.168.1.3", "ICMP");
MockService smtpService = m_network.getService(2, "192.168.1.3", "SMTP");
MockService snmpService = m_network.getService(2, "192.168.1.3", "SNMP");
// start the poller
startDaemons();
anticipateDown(node);
icmpService.bringDown();
smtpService.bringDown();
snmpService.bringDown();
verifyAnticipated(10000);
// node is down at this point
boolean foundNodeDown = false;
for (final Event event : m_eventMgr.getEventAnticipator().getAnticipatedEventsReceived()) {
if (EventConstants.NODE_DOWN_EVENT_UEI.equals(event.getUei())) {
foundNodeDown = true;
assertNull(event.getInterfaceAddress());
}
}
assertTrue(foundNodeDown);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerIT method testNodeLostServiceWithReason.
@Test
public void testNodeLostServiceWithReason() {
m_pollerConfig.setNodeOutageProcessingEnabled(true);
MockService svc = m_network.getService(1, "192.168.1.1", "ICMP");
Event e = svc.createDownEvent();
String reasonParm = "eventReason";
String val = (String) AbstractEventUtil.getInstance().getNamedParmValue("parm[" + reasonParm + "]", e);
assertEquals("Service Not Responding.", val);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class NotifdIT method testBug1114.
@Test
public void testBug1114() throws Exception {
// XXX Needing to bump up this number is bogus
m_anticipator.setExpectedDifference(5000);
MockService svc = m_network.getService(1, "192.168.1.1", "ICMP");
long interval = computeInterval();
Event event = MockEventUtil.createServiceEvent("Test", "uei.opennms.org/tests/nodeTimeTest", svc, null);
Date date = event.getTime();
String dateString = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(date);
long endTime = anticipateNotificationsForGroup("time " + dateString + ".", "Timestamp: " + dateString + ".", "InitialGroup", date, interval);
m_eventMgr.sendEventToListeners(event);
// XXX Needing to decrease the end time is bogus
verifyAnticipated(endTime - 5000, 1000);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class BroadcastEventProcessorIT method testExpandNoticeId_Bug1745.
/**
* Trip a notification and see if the %noticeid% token gets expanded to a numeric
* value in the subject and text message
*
* @author Jeff Gehlbach <jeffg@jeffg.org>
*/
@Test
public void testExpandNoticeId_Bug1745() throws Exception {
MockService svc = m_network.getService(1, "192.168.1.1", "ICMP");
Event event = MockEventUtil.createServiceEvent("Test", "uei.opennms.org/test/noticeIdExpansion", svc, null);
// We need to know what noticeID to expect -- whatever the NotificationManager
// gives us, the next notice to come out will have noticeID n+1. This isn't
// foolproof, but it should work within the confines of JUnit as long as all
// previous cases have torn down the mock Notifd.
String antNID = Integer.toString(m_notificationManager.getNoticeId() + 1);
Date testDate = new Date();
long finishedNotifs = anticipateNotificationsForGroup("notification '" + antNID + "'", "Notification '" + antNID + "'", "InitialGroup", testDate, 0);
MockEventUtil.setEventTime(event, testDate);
m_eventMgr.sendEventToListeners(event);
verifyAnticipated(finishedNotifs, 1000);
}
Aggregations