private void startDaemons() {
   // m_outageMgr.init();
   m_poller.init();
   // m_outageMgr.start();
   m_poller.start();
   m_daemonsStarted = true;
 }
  // 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());
  }
 //
 // Tests
 //
 @Test
 public void testIsRemotePackage() {
   Properties p = new Properties();
   p.setProperty("org.opennms.netmgt.ConfigFileConstants", "ERROR");
   MockLogAppender.setupLogging(p);
   Package pkg = new Package();
   pkg.setName("SFO");
   pkg.setRemote(true);
   Poller poller = new Poller();
   assertFalse(poller.pollableServiceInPackage(null, null, pkg));
   poller = null;
 }
 private void stopDaemons() {
   if (m_daemonsStarted) {
     m_poller.stop();
     // m_outageMgr.stop();
     m_daemonsStarted = false;
   }
 }
  @Before
  public void setUp() throws Exception {
    m_assertLevel = Level.WARN;

    // System.setProperty("mock.logLevel", "DEBUG");
    // System.setProperty("mock.debug", "true");
    MockUtil.println("------------ Begin Test  --------------------------");
    MockLogAppender.setupLogging();

    m_network = new MockNetwork();
    m_network.setCriticalService("ICMP");
    m_network.addNode(1, "Router");
    m_network.addInterface("192.168.1.1");
    m_network.addService("ICMP");
    m_network.addService("SMTP");
    m_network.addService("SNMP");
    m_network.addInterface("192.168.1.2");
    m_network.addService("ICMP");
    m_network.addService("SMTP");
    m_network.addNode(2, "Server");
    m_network.addInterface("192.168.1.3");
    m_network.addService("ICMP");
    m_network.addService("HTTP");
    m_network.addService("SMTP");
    m_network.addService("SNMP");
    m_network.addNode(3, "Firewall");
    m_network.addInterface("192.168.1.4");
    m_network.addService("SMTP");
    m_network.addService("HTTP");
    m_network.addInterface("192.168.1.5");
    m_network.addService("SMTP");
    m_network.addService("HTTP");
    m_network.addNode(4, "DownNode");
    m_network.addInterface("192.168.1.6");
    m_network.addService("SNMP");
    //		m_network.addInterface("fe80:0000:0000:0000:0231:f982:0123:4567");
    //		m_network.addService("SNMP");

    m_db = new MockDatabase();
    m_db.populate(m_network);
    DataSourceFactory.setInstance(m_db);

    //		DemandPollDao demandPollDao = new DemandPollDaoHibernate(m_db);
    //		demandPollDao.setAllocateIdStmt(m_db
    //				.getNextSequenceValStatement("demandPollNxtId"));
    //		m_demandPollDao = demandPollDao;

    m_pollerConfig = new MockPollerConfig(m_network);
    m_pollerConfig.setNextOutageIdSql(m_db.getNextOutageIdStatement());
    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    m_pollerConfig.setCriticalService("ICMP");
    m_pollerConfig.addPackage("TestPackage");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(1000L);
    m_pollerConfig.populatePackage(m_network);
    m_pollerConfig.addPackage("TestPkg2");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(2000L);
    m_pollerConfig.addService(m_network.getService(2, "192.168.1.3", "HTTP"));

    m_anticipator = new EventAnticipator();
    m_outageAnticipator = new OutageAnticipator(m_db);

    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setEventWriter(m_db);
    m_eventMgr.setEventAnticipator(m_anticipator);
    m_eventMgr.addEventListener(m_outageAnticipator);
    m_eventMgr.setSynchronous(false);

    QueryManager queryManager = new DefaultQueryManager();
    queryManager.setDataSource(m_db);

    DefaultPollContext pollContext = new DefaultPollContext();
    pollContext.setEventManager(m_eventMgr);
    pollContext.setLocalHostName("localhost");
    pollContext.setName("Test.DefaultPollContext");
    pollContext.setPollerConfig(m_pollerConfig);
    pollContext.setQueryManager(queryManager);

    PollableNetwork network = new PollableNetwork(pollContext);

    m_poller = new Poller();
    m_poller.setDataSource(m_db);
    m_poller.setEventManager(m_eventMgr);
    m_poller.setNetwork(network);
    m_poller.setQueryManager(queryManager);
    m_poller.setPollerConfig(m_pollerConfig);
    m_poller.setPollOutagesConfig(m_pollerConfig);

    MockOutageConfig config = new MockOutageConfig();
    config.setGetNextOutageID(m_db.getNextOutageIdStatement());

    RrdUtils.setStrategy(new NullRrdStrategy());

    // m_outageMgr = new OutageManager();
    // m_outageMgr.setEventMgr(m_eventMgr);
    // m_outageMgr.setOutageMgrConfig(config);
    // m_outageMgr.setDbConnectionFactory(m_db);

  }
 @Override
 void implClose() throws IOException {
   // delegate to poller
   poller.close();
 }
 @Override
 WatchKey register(Path path, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers)
     throws IOException {
   // delegate to poller
   return poller.register(path, events, modifiers);
 }