Search in sources :

Example 1 with MockForeignSourceRepository

use of org.opennms.netmgt.provision.persist.MockForeignSourceRepository in project opennms by OpenNMS.

the class IfIndexNullIT method setUp.

@Before
public void setUp() {
    MockLogAppender.setupLogging();
    final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
    final ForeignSource fs = new ForeignSource();
    fs.setName("default");
    fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
    mfsr.putDefaultForeignSource(fs);
    m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Example 2 with MockForeignSourceRepository

use of org.opennms.netmgt.provision.persist.MockForeignSourceRepository in project opennms by OpenNMS.

the class MultipleImportIT method setUp.

@Before
public void setUp() {
    MockLogAppender.setupLogging();
    final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
    final ForeignSource fs = new ForeignSource();
    fs.setName("default");
    fs.addDetector(new PluginConfig("ICMP", "org.opennms.netmgt.provision.service.MockServiceDetector"));
    mfsr.putDefaultForeignSource(fs);
    m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Example 3 with MockForeignSourceRepository

use of org.opennms.netmgt.provision.persist.MockForeignSourceRepository in project opennms by OpenNMS.

the class NewSuspectScanIT method setUp.

@Before
public void setUp() throws Exception {
    m_eventSubscriber.getEventAnticipator().reset();
    if (m_distPollerDao.findAll().size() == 0) {
        OnmsDistPoller distPoller = new OnmsDistPoller(DistPollerDao.DEFAULT_DIST_POLLER_ID);
        distPoller.setLabel("localhost");
        distPoller.setLocation(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
        distPoller.setType(OnmsMonitoringSystem.TYPE_OPENNMS);
        m_distPollerDao.save(distPoller);
    }
    m_foreignSource = new ForeignSource();
    m_foreignSource.setName("imported:");
    m_foreignSource.setScanInterval(Duration.standardDays(1));
    final PluginConfig detector = new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector");
    detector.addParameter("timeout", "1000");
    detector.addParameter("retries", "0");
    m_foreignSource.addDetector(detector);
    m_foreignSourceRepository = new MockForeignSourceRepository();
    m_foreignSourceRepository.putDefaultForeignSource(m_foreignSource);
    m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
    m_provisioner.start();
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Example 4 with MockForeignSourceRepository

use of org.opennms.netmgt.provision.persist.MockForeignSourceRepository in project opennms by OpenNMS.

the class HandlerTest method dwOpenConnectionURL.

@Test
@Ignore
public void dwOpenConnectionURL() throws IOException {
    URL url = new URL(DNS_URL);
    UrlResource resource = new UrlResource(url);
    MockForeignSourceRepository fsr = new MockForeignSourceRepository();
    Requisition r = fsr.importResourceRequisition(resource);
    Assert.assertTrue("Number of nodes in Model Import > 1", 1 == r.getNodeCount());
    Assert.assertTrue("NodeLabel isn't localhost", "localhost".equals(r.getNodes().get(0).getNodeLabel()));
    Assert.assertTrue("127.0.0.1".equals(r.getNodes().get(0).getInterfaces().get(0).getIpAddr()));
}
Also used : UrlResource(org.springframework.core.io.UrlResource) URL(java.net.URL) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with MockForeignSourceRepository

use of org.opennms.netmgt.provision.persist.MockForeignSourceRepository in project opennms by OpenNMS.

the class ProvisionerRescanExistingFalseIT method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging(true, "ERROR");
    SnmpPeerFactory.setInstance(m_snmpPeerFactory);
    assertTrue(m_snmpPeerFactory instanceof ProxySnmpAgentConfigFactory);
    m_eventAnticipator = m_mockEventIpcManager.getEventAnticipator();
    // ((TransactionAwareEventForwarder)m_provisioner.getEventForwarder()).setEventForwarder(m_mockEventIpcManager);
    m_provisioner.start();
    m_foreignSource = new ForeignSource();
    m_foreignSource.setName("noRescanOnImport");
    m_foreignSource.setScanInterval(Duration.standardDays(1));
    final PluginConfig icmpDetector = new PluginConfig("ICMP", IcmpDetector.class.getName());
    icmpDetector.addParameter("timeout", "500");
    icmpDetector.addParameter("retries", "0");
    m_foreignSource.addDetector(icmpDetector);
    final PluginConfig snmpDetector = new PluginConfig("SNMP", SnmpDetector.class.getName());
    snmpDetector.addParameter("timeout", "500");
    snmpDetector.addParameter("retries", "0");
    m_foreignSource.addDetector(snmpDetector);
    m_foreignSourceRepository = new MockForeignSourceRepository();
    m_foreignSourceRepository.save(m_foreignSource);
    m_foreignSourceRepository.flush();
    m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
    m_scheduledExecutor.pause();
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) IcmpDetector(org.opennms.netmgt.provision.detector.icmp.IcmpDetector) SnmpDetector(org.opennms.netmgt.provision.detector.snmp.SnmpDetector) ProxySnmpAgentConfigFactory(org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Aggregations

MockForeignSourceRepository (org.opennms.netmgt.provision.persist.MockForeignSourceRepository)10 Before (org.junit.Before)9 ForeignSource (org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)9 PluginConfig (org.opennms.netmgt.provision.persist.foreignsource.PluginConfig)9 ProxySnmpAgentConfigFactory (org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory)2 OnmsDistPoller (org.opennms.netmgt.model.OnmsDistPoller)2 SnmpDetector (org.opennms.netmgt.provision.detector.snmp.SnmpDetector)2 URL (java.net.URL)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 IcmpDetector (org.opennms.netmgt.provision.detector.icmp.IcmpDetector)1 NodeCategorySettingPolicy (org.opennms.netmgt.provision.persist.policies.NodeCategorySettingPolicy)1 Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)1 UrlResource (org.springframework.core.io.UrlResource)1