Search in sources :

Example 1 with Scheduler

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);
}
Also used : ResourceStorageDao(org.opennms.netmgt.dao.api.ResourceStorageDao) HashMap(java.util.HashMap) Scheduler(org.opennms.netmgt.scheduler.Scheduler) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) RrdPersisterFactory(org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) SchedulingCompletedFlag(org.opennms.netmgt.collectd.Collectd.SchedulingCompletedFlag)

Example 2 with Scheduler

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();
}
Also used : Scheduler(org.opennms.netmgt.scheduler.Scheduler) MockScheduler(org.opennms.netmgt.poller.mock.MockScheduler) ReadyRunnable(org.opennms.netmgt.scheduler.ReadyRunnable) Test(org.junit.Test)

Aggregations

Scheduler (org.opennms.netmgt.scheduler.Scheduler)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 SchedulingCompletedFlag (org.opennms.netmgt.collectd.Collectd.SchedulingCompletedFlag)1 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)1 RrdPersisterFactory (org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory)1 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)1 ResourceStorageDao (org.opennms.netmgt.dao.api.ResourceStorageDao)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 MockScheduler (org.opennms.netmgt.poller.mock.MockScheduler)1 ReadyRunnable (org.opennms.netmgt.scheduler.ReadyRunnable)1 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)1