public void setUpMock() {

    EasyMock.expect(m_nodeDao.getAllLabelsById());
    EasyMock.expectLastCall().andReturn(getNodeLabelsById()).anyTimes();

    for (int i = 1; i < 9; i++) {
      EasyMock.expect(m_nodeDao.get(i)).andReturn(getNode(i)).anyTimes();
      EasyMock.expect(m_snmpInterfaceDao.findByNodeIdAndIfIndex(i, -1)).andReturn(null).anyTimes();
      EasyMock.expect(m_ipInterfaceDao.findPrimaryInterfaceByNodeId(i))
          .andReturn(getNode(i).getPrimaryInterface())
          .anyTimes();
      EasyMock.expect(m_ipInterfaceDao.findByNodeId(i))
          .andReturn(getList(getNode(i).getIpInterfaces()))
          .anyTimes();
    }

    EasyMock.replay(m_nodeDao);
    EasyMock.replay(m_snmpInterfaceDao);
    EasyMock.replay(m_ipInterfaceDao);
  }
Exemple #2
0
  /** @throws Exception */
  public void testNoMatchingSpecs() throws Exception {

    setupCollector("SNMP", false);
    expect(m_ipIfDao.findByServiceType("SNMP")).andReturn(new ArrayList<OnmsIpInterface>(0));
    setupTransactionManager();

    m_easyMockUtils.replayAll();

    m_collectd.afterPropertiesSet();

    m_collectd.start();

    m_scheduler.next();

    assertEquals(0, m_scheduler.getEntryCount());

    m_collectd.stop();

    m_easyMockUtils.verifyAll();
  }
Exemple #3
0
 private void setupInterface(OnmsIpInterface iface) {
   expect(m_ipIfDao.findByServiceType("SNMP")).andReturn(Collections.singletonList(iface));
   expect(m_ipIfDao.load(iface.getId())).andReturn(iface).atLeastOnce();
 }
  public void resetDatabase() {
    LOG.debug("==== DatabasePopulator Reset ====");
    for (final DataLinkInterface iface : m_dataLinkInterfaceDao.findAll()) {
      m_dataLinkInterfaceDao.delete(iface);
    }
    for (final OnmsOutage outage : m_outageDao.findAll()) {
      m_outageDao.delete(outage);
    }
    for (final OnmsUserNotification not : m_userNotificationDao.findAll()) {
      m_userNotificationDao.delete(not);
    }
    for (final OnmsNotification not : m_notificationDao.findAll()) {
      m_notificationDao.delete(not);
    }
    for (final OnmsAlarm alarm : m_alarmDao.findAll()) {
      m_alarmDao.delete(alarm);
    }
    for (final OnmsEvent event : m_eventDao.findAll()) {
      m_eventDao.delete(event);
    }
    for (final OnmsSnmpInterface iface : m_snmpInterfaceDao.findAll()) {
      m_snmpInterfaceDao.delete(iface);
    }
    for (final OnmsIpInterface iface : m_ipInterfaceDao.findAll()) {
      m_ipInterfaceDao.delete(iface);
    }
    for (final OnmsNode node : m_nodeDao.findAll()) {
      m_nodeDao.delete(node);
    }
    for (final OnmsServiceType service : m_serviceTypeDao.findAll()) {
      m_serviceTypeDao.delete(service);
    }

    LOG.debug("= DatabasePopulatorExtension Reset Starting =");
    for (Extension eachExtension : extensions) {
      DaoSupport daoSupport = eachExtension.getDaoSupport();
      OnmsDao dao =
          daoSupport != null && daoSupport.getDaoClass() != null
              ? lookupDao(daoSupport.getDaoClass())
              : null;

      eachExtension.onShutdown(this, dao);
      if (dao != null) {
        dao.flush();
      }
    }
    LOG.debug("= DatabasePopulatorExtension Reset Finished =");

    m_dataLinkInterfaceDao.flush();
    m_outageDao.flush();
    m_userNotificationDao.flush();
    m_notificationDao.flush();
    m_alarmDao.flush();
    m_eventDao.flush();
    m_snmpInterfaceDao.flush();
    m_ipInterfaceDao.flush();
    m_nodeDao.flush();
    m_serviceTypeDao.flush();

    LOG.debug("==== DatabasePopulator Reset Finished ====");
  }