public void testOneMatchingSpec() throws Exception { OnmsIpInterface iface = getInterface(); setupCollector("SNMP", true); setupInterface(iface); setupTransactionManager(); expect(m_collectdConfig.getPackages()) .andReturn(Collections.singletonList(getCollectionPackageThatMatchesSNMP())); expect(m_collectdConfigFactory.interfaceInPackage(iface, getCollectionPackageThatMatchesSNMP())) .andReturn(true); m_easyMockUtils.replayAll(); assertEquals("scheduler entry count", 0, m_scheduler.getEntryCount()); m_collectd.afterPropertiesSet(); m_collectd.start(); m_scheduler.next(); assertEquals("scheduler entry count", 1, m_scheduler.getEntryCount()); m_scheduler.next(); m_collectd.stop(); m_easyMockUtils.verifyAll(); }
public void testCreate() throws Exception { setupCollector("SNMP", false); setupTransactionManager(); // Use a mock scheduler to track calls to the Collectd scheduler Scheduler m_scheduler = m_easyMockUtils.createMock(Scheduler.class); m_collectd.setScheduler(m_scheduler); // Expect one task to be scheduled m_scheduler.schedule(eq(0L), isA(ReadyRunnable.class)); // Expect the scheduler to be started and stopped during Collectd // start() and stop() m_scheduler.start(); m_scheduler.stop(); m_easyMockUtils.replayAll(); // Initialize Collectd m_collectd.afterPropertiesSet(); // Start and stop collectd m_collectd.start(); m_collectd.stop(); m_easyMockUtils.verifyAll(); }
/** @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(); }