Search in sources :

Example 41 with MockNode

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

the class VacuumdIT method bringNodeUpCreatingEvent.

private void bringNodeUpCreatingEvent(int nodeid) {
    MockNode node = m_network.getNode(nodeid);
    m_eventdIpcMgr.sendNow(node.createUpEvent());
}
Also used : MockNode(org.opennms.netmgt.mock.MockNode)

Example 42 with MockNode

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

the class VacuumdIT method bringNodeDownCreatingEventWithReason.

private void bringNodeDownCreatingEventWithReason(int nodeid, String reason) {
    MockNode node = m_network.getNode(nodeid);
    m_eventdIpcMgr.sendNow(node.createDownEventWithReason(reason));
}
Also used : MockNode(org.opennms.netmgt.mock.MockNode)

Example 43 with MockNode

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

the class MockDatabaseIT method testNodeQuery.

public void testNodeQuery() {
    Querier querier = new Querier(m_db, "select * from node") {

        @Override
        public void processRow(ResultSet rs) throws SQLException {
            int nodeId = rs.getInt("nodeId");
            String label = rs.getString("nodeLabel");
            MockNode node = m_network.getNode(nodeId);
            assertNotNull(node);
            assertEquals(nodeId, node.getNodeId());
            assertEquals(label, node.getLabel());
        }
    };
    querier.execute();
    assertEquals(m_network.getNodeCount(), querier.getCount());
}
Also used : Querier(org.opennms.core.utils.Querier) ResultSet(java.sql.ResultSet) MockNode(org.opennms.netmgt.mock.MockNode)

Example 44 with MockNode

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

the class PollerIT method testNodeOutageProcessingDisabled.

// test to see that node lost/regained service events come in
@Test
public void testNodeOutageProcessingDisabled() throws Exception {
    m_pollerConfig.setNodeOutageProcessingEnabled(false);
    MockNode node = m_network.getNode(1);
    startDaemons();
    resetAnticipated();
    anticipateServicesDown(node);
    node.bringDown();
    verifyAnticipated(10000);
    resetAnticipated();
    anticipateServicesUp(node);
    node.bringUp();
    verifyAnticipated(10000);
}
Also used : MockNode(org.opennms.netmgt.mock.MockNode) Test(org.junit.Test)

Example 45 with MockNode

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

the class PollerIT method testNodeLabelChanged.

// nodeLabelChanged: EventConstants.NODE_LABEL_CHANGED_EVENT_UEI
@Test
public void testNodeLabelChanged() {
    MockNode element = m_network.getNode(1);
    String newLabel = "NEW LABEL";
    Event event = element.createNodeLabelChangedEvent(newLabel);
    m_pollerConfig.setNodeOutageProcessingEnabled(false);
    PollAnticipator poll = new PollAnticipator();
    element.addAnticipator(poll);
    poll.anticipateAllServices(element);
    startDaemons();
    // wait until after the first poll of the services
    poll.waitForAnticipated(1000L);
    assertEquals("Router", m_poller.getNetwork().getNode(1).getNodeLabel());
    // now delete the node and send a nodeDeleted event
    element.setLabel(newLabel);
    m_eventMgr.sendEventToListeners(event);
    assertEquals(newLabel, m_poller.getNetwork().getNode(1).getNodeLabel());
}
Also used : PollAnticipator(org.opennms.netmgt.mock.PollAnticipator) Event(org.opennms.netmgt.xml.event.Event) MockNode(org.opennms.netmgt.mock.MockNode) Test(org.junit.Test)

Aggregations

MockNode (org.opennms.netmgt.mock.MockNode)53 Test (org.junit.Test)43 Event (org.opennms.netmgt.xml.event.Event)21 MockService (org.opennms.netmgt.mock.MockService)16 MockInterface (org.opennms.netmgt.mock.MockInterface)7 Date (java.util.Date)5 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)5 ResultSet (java.sql.ResultSet)4 PollAnticipator (org.opennms.netmgt.mock.PollAnticipator)4 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)3 MockNetwork (org.opennms.netmgt.mock.MockNetwork)3 MockVisitor (org.opennms.netmgt.mock.MockVisitor)3 MockVisitorAdapter (org.opennms.netmgt.mock.MockVisitorAdapter)3 Ignore (org.junit.Ignore)2 Querier (org.opennms.core.utils.Querier)2 RowCallbackHandler (org.springframework.jdbc.core.RowCallbackHandler)2 HashSet (java.util.HashSet)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Before (org.junit.Before)1