use of org.opennms.netmgt.scheduler.Scheduler in project opennms by OpenNMS.
the class CollectableServiceTest method createCollectableService.
private void createCollectableService() throws CollectionInitializationException, IOException {
// Mock it all!
OnmsIpInterface iface = mock(OnmsIpInterface.class, RETURNS_DEEP_STUBS);
IpInterfaceDao ifaceDao = mock(IpInterfaceDao.class);
spec = mock(CollectionSpecification.class);
scheduler = mock(Scheduler.class);
SchedulingCompletedFlag schedulingCompletedFlag = mock(SchedulingCompletedFlag.class);
PlatformTransactionManager transMgr = mock(PlatformTransactionManager.class);
RrdPersisterFactory persisterFactory = new RrdPersisterFactory();
persisterFactory.setRrdStrategy(rrdStrategy);
ResourceStorageDao resourceStorageDao = mock(ResourceStorageDao.class);
// Disable thresholding
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("thresholding-enabled", Boolean.FALSE.toString());
ServiceParameters params = new ServiceParameters(paramsMap);
when(iface.getNode().getId()).thenReturn(1);
when(spec.getServiceParameters()).thenReturn(params);
when(spec.getRrdRepository(any())).thenReturn(createRrdRepository());
when(ifaceDao.load(any())).thenReturn(iface);
when(iface.getIpAddress()).thenReturn(InetAddrUtils.getLocalHostAddress());
service = new CollectableService(iface, ifaceDao, spec, scheduler, schedulingCompletedFlag, transMgr, persisterFactory, resourceStorageDao);
}
use of org.opennms.netmgt.scheduler.Scheduler in project opennms by OpenNMS.
the class CollectdTest method testCreate.
@Test
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();
}
Aggregations