コード例 #1
0
ファイル: AlarmdTest.java プロジェクト: lunar999/opennms
  private void sendNodeDownEventWithUpdateFieldSeverity(
      String reductionKey, MockNode node, OnmsSeverity severity) throws SQLException {
    EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);

    if (reductionKey != null) {
      AlarmData data = new AlarmData();
      data.setAlarmType(1);
      data.setReductionKey(reductionKey);

      List<UpdateField> fields = new ArrayList<UpdateField>();

      UpdateField field = new UpdateField();
      field.setFieldName("Severity");
      field.setUpdateOnReduction(Boolean.TRUE);
      fields.add(field);

      data.setUpdateField(fields);

      event.setAlarmData(data);
    } else {
      event.setAlarmData(null);
    }

    event.setLogDest("logndisplay");
    event.setLogMessage("testing");

    event.setSeverity(severity.getLabel());

    m_eventdIpcMgr.sendNow(event.getEvent());
  }
コード例 #2
0
ファイル: AlarmdTest.java プロジェクト: lunar999/opennms
  private void sendNodeDownEventChangeLogMsg(String reductionKey, MockNode node, String logMsg) {

    EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);

    if (reductionKey != null) {
      AlarmData data = new AlarmData();
      data.setAlarmType(1);
      data.setReductionKey(reductionKey);

      List<UpdateField> fields = new ArrayList<UpdateField>();

      UpdateField field = new UpdateField();
      field.setFieldName("logMsg");
      field.setUpdateOnReduction(Boolean.TRUE);
      fields.add(field);

      data.setUpdateField(fields);

      event.setAlarmData(data);
    } else {
      event.setAlarmData(null);
    }

    event.setLogDest("logndisplay");
    event.setLogMessage(logMsg);

    m_eventdIpcMgr.sendNow(event.getEvent());
  }
コード例 #3
0
ファイル: AlarmdTest.java プロジェクト: lunar999/opennms
  @Test
  public void testNoAlarmData() throws Exception {
    EventBuilder bldr = new EventBuilder("testNoAlarmData", "AlarmdTest");
    bldr.setLogMessage(null);

    m_alarmd.getPersister().persist(bldr.getEvent());
  }
コード例 #4
0
ファイル: AlarmdTest.java プロジェクト: lunar999/opennms
  @Test
  public void testNoDbid() throws Exception {
    EventBuilder bldr = new EventBuilder("testNoDbid", "AlarmdTest");
    bldr.setLogMessage(null);
    bldr.setAlarmData(new AlarmData());

    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("Incoming event has an illegal dbid (0), aborting"));
    try {
      m_alarmd.getPersister().persist(bldr.getEvent());
    } catch (Throwable t) {
      ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
  }
コード例 #5
0
ファイル: AlarmdTest.java プロジェクト: lunar999/opennms
  private void sendNodeDownEvent(String reductionKey, MockNode node) throws SQLException {
    EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);

    if (reductionKey != null) {
      AlarmData data = new AlarmData();
      data.setAlarmType(1);
      data.setReductionKey(reductionKey);
      event.setAlarmData(data);
    } else {
      event.setAlarmData(null);
    }

    event.setLogDest("logndisplay");
    event.setLogMessage("testing");

    m_eventdIpcMgr.sendNow(event.getEvent());
  }
コード例 #6
0
ファイル: AlarmdTest.java プロジェクト: lunar999/opennms
  @Test
  @JUnitTemporaryDatabase(
      tempDbClass = MockDatabase.class) // Relies on specific IDs so we need a fresh database
  public void testNorthbounder() throws Exception {
    assertTrue(m_northbounder.isInitialized());
    assertTrue(m_northbounder.getAlarms().isEmpty());

    final EventBuilder bldr = new EventBuilder("testNoLogmsg", "AlarmdTest");
    bldr.setAlarmData(new AlarmData());
    bldr.setLogMessage("This is a test.");

    final Event event = bldr.getEvent();
    event.setDbid(17);

    MockNode node = m_mockNetwork.getNode(1);
    sendNodeDownEvent("%nodeid%", node);

    final List<NorthboundAlarm> alarms = m_northbounder.getAlarms();
    assertTrue(alarms.size() > 0);
  }