Search in sources :

Example 6 with MockService

use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.

the class PollerQueryManagerDaoIT method testInterfaceWithNoCriticalService.

@Test
public void testInterfaceWithNoCriticalService() {
    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    MockInterface iface = m_network.getInterface(3, "192.168.1.4");
    MockService svc = iface.getService("SMTP");
    MockService otherService = iface.getService("HTTP");
    startDaemons();
    anticipateDown(iface);
    iface.bringDown();
    verifyAnticipated(8000);
    anticipateUp(iface);
    anticipateDown(otherService, true);
    svc.bringUp();
    verifyAnticipated(8000);
}
Also used : MockInterface(org.opennms.netmgt.mock.MockInterface) MockService(org.opennms.netmgt.mock.MockService) Test(org.junit.Test)

Example 7 with MockService

use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.

the class PollerQueryManagerDaoIT 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);
}
Also used : MockService(org.opennms.netmgt.mock.MockService) Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test)

Example 8 with MockService

use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.

the class PollablesIT method anticipateResponsive.

private void anticipateResponsive(MockElement element) {
    MockVisitor visitor = new MockVisitorAdapter() {

        @Override
        public void visitService(MockService svc) {
            m_eventMgr.getEventAnticipator().anticipateEvent(svc.createResponsiveEvent());
        }
    };
    element.visit(visitor);
}
Also used : MockVisitorAdapter(org.opennms.netmgt.mock.MockVisitorAdapter) MockVisitor(org.opennms.netmgt.mock.MockVisitor) MockService(org.opennms.netmgt.mock.MockService)

Example 9 with MockService

use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.

the class PollablesIT method testPollService.

@Test
public void testPollService() throws Exception {
    PollableService pSvc = pDot1Smtp;
    MockService mSvc = mDot1Smtp;
    pSvc.doPoll();
    assertUp(pSvc);
    assertUnchanged(pSvc);
    mSvc.bringDown();
    pSvc.doPoll();
    assertDown(pSvc);
    assertChanged(pSvc);
    pSvc.resetStatusChanged();
    mSvc.bringUp();
    pSvc.doPoll();
    assertUp(pSvc);
    assertChanged(pSvc);
    pSvc.recalculateStatus();
}
Also used : MockService(org.opennms.netmgt.mock.MockService) Test(org.junit.Test)

Example 10 with MockService

use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.

the class PollablesIT method assertNoPoll.

/**
     * @param network
     */
private void assertNoPoll(MockElement elem) {
    MockVisitor zeroAsserter = new MockVisitorAdapter() {

        @Override
        public void visitService(MockService svc) {
            assertEquals("Unexpected poll count for " + svc, 0, svc.getPollCount());
        }
    };
    elem.visit(zeroAsserter);
}
Also used : MockVisitorAdapter(org.opennms.netmgt.mock.MockVisitorAdapter) MockVisitor(org.opennms.netmgt.mock.MockVisitor) MockService(org.opennms.netmgt.mock.MockService)

Aggregations

MockService (org.opennms.netmgt.mock.MockService)59 Test (org.junit.Test)36 Event (org.opennms.netmgt.xml.event.Event)19 MockNode (org.opennms.netmgt.mock.MockNode)16 MockVisitor (org.opennms.netmgt.mock.MockVisitor)14 MockVisitorAdapter (org.opennms.netmgt.mock.MockVisitorAdapter)14 Date (java.util.Date)8 MockInterface (org.opennms.netmgt.mock.MockInterface)8 Timestamp (java.sql.Timestamp)3 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)3 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 Querier (org.opennms.core.utils.Querier)2 PollAnticipator (org.opennms.netmgt.mock.PollAnticipator)2 HashSet (java.util.HashSet)1 Before (org.junit.Before)1 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)1 LocationAwarePingClient (org.opennms.netmgt.icmp.proxy.LocationAwarePingClient)1 MockNetwork (org.opennms.netmgt.mock.MockNetwork)1