Search in sources :

Example 6 with MockCollectionAgent

use of org.opennms.core.collection.test.MockCollectionAgent in project opennms by OpenNMS.

the class HttpDataCollectionIT method setUp.

/**
 * Sets the up.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    DefaultDataCollectionConfigDao dao = new DefaultDataCollectionConfigDao();
    dao.setConfigDirectory("src/test/resources/etc/datacollection");
    dao.setConfigResource(new FileSystemResource("src/test/resources/etc/datacollection-config.xml"));
    dao.afterPropertiesSet();
    DataCollectionConfigFactory.setInstance(dao);
    m_rrdStrategy = new JRobinRrdStrategy();
    m_resourceStorageDao = new FilesystemResourceStorageDao();
    m_resourceStorageDao.setRrdDirectory(m_temporaryFolder.getRoot());
    m_temporaryFolder.newFolder("snmp");
    m_persisterFactory = new RrdPersisterFactory();
    m_persisterFactory.setResourceStorageDao(m_resourceStorageDao);
    m_persisterFactory.setRrdStrategy(m_rrdStrategy);
    m_collectionAgent = new MockCollectionAgent(1, "mynode.local", InetAddrUtils.addr("127.0.0.1"));
    m_nodeDao = EasyMock.createMock(NodeDao.class);
    OnmsNode node = new OnmsNode();
    node.setId(1);
    node.setLabel("mynode.local");
    node.setAssetRecord(new OnmsAssetRecord());
    EasyMock.expect(m_nodeDao.get(1)).andReturn(node).anyTimes();
    EasyMock.replay(m_nodeDao);
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsAssetRecord(org.opennms.netmgt.model.OnmsAssetRecord) FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) RrdPersisterFactory(org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory) MockCollectionAgent(org.opennms.core.collection.test.MockCollectionAgent) FileSystemResource(org.springframework.core.io.FileSystemResource) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) DefaultDataCollectionConfigDao(org.opennms.netmgt.config.DefaultDataCollectionConfigDao) Before(org.junit.Before)

Example 7 with MockCollectionAgent

use of org.opennms.core.collection.test.MockCollectionAgent in project opennms by OpenNMS.

the class XmlCollectorITCase method setUp.

/**
 * Sets the up.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    initializeRrdStrategy();
    initializeDocumentBuilder();
    m_collectionAgent = new MockCollectionAgent(1, "mynode.local", InetAddrUtils.addr("127.0.0.1"));
    m_eventProxy = EasyMock.createMock(EventProxy.class);
    m_xmlCollectionDao = new XmlDataCollectionConfigDaoJaxb();
    Resource resource = new FileSystemResource(getConfigFileName());
    m_xmlCollectionDao.setConfigResource(resource);
    m_xmlCollectionDao.afterPropertiesSet();
    EasyMock.replay(m_eventProxy);
}
Also used : Resource(org.springframework.core.io.Resource) FileSystemResource(org.springframework.core.io.FileSystemResource) MockCollectionAgent(org.opennms.core.collection.test.MockCollectionAgent) FileSystemResource(org.springframework.core.io.FileSystemResource) XmlDataCollectionConfigDaoJaxb(org.opennms.protocols.xml.dao.jaxb.XmlDataCollectionConfigDaoJaxb) EventProxy(org.opennms.netmgt.events.api.EventProxy) Before(org.junit.Before)

Example 8 with MockCollectionAgent

use of org.opennms.core.collection.test.MockCollectionAgent in project opennms by OpenNMS.

the class JMXCollectorTest method setUp.

@Before
public void setUp() throws Exception {
    System.setProperty("opennms.home", new File("src/test/resources").getAbsolutePath());
    jmxDataCollectionConfigDao = new JMXDataCollectionConfigDao();
    jmxNodeInfo = new JMXNodeInfo(0);
    jmxCollector = new JMXCollectorImpl();
    jmxCollector.setJmxConfigDao(new JmxConfigDaoJaxb());
    jmxCollector.setJmxDataCollectionConfigDao(jmxDataCollectionConfigDao);
    platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
    ObjectName objectName = new ObjectName("org.opennms.netmgt.collectd.jmxhelper:type=JmxTest");
    JmxTestMBean testMBean = new JmxTest();
    platformMBeanServer.registerMBean(testMBean, objectName);
    collectionAgent = new MockCollectionAgent(1, "node", "fs", "fid", InetAddress.getLoopbackAddress());
}
Also used : JmxConfigDaoJaxb(org.opennms.netmgt.dao.jmx.JmxConfigDaoJaxb) JMXDataCollectionConfigDao(org.opennms.netmgt.config.JMXDataCollectionConfigDao) JmxTest(org.opennms.netmgt.collectd.jmxhelper.JmxTest) MockCollectionAgent(org.opennms.core.collection.test.MockCollectionAgent) JmxTestMBean(org.opennms.netmgt.collectd.jmxhelper.JmxTestMBean) File(java.io.File) ObjectName(javax.management.ObjectName) Before(org.junit.Before)

Aggregations

MockCollectionAgent (org.opennms.core.collection.test.MockCollectionAgent)8 Before (org.junit.Before)5 FileSystemResource (org.springframework.core.io.FileSystemResource)4 File (java.io.File)3 RrdPersisterFactory (org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory)3 FilesystemResourceStorageDao (org.opennms.netmgt.dao.support.FilesystemResourceStorageDao)3 JRobinRrdStrategy (org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy)3 Test (org.junit.Test)2 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)2 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)2 CollectionSetBuilder (org.opennms.netmgt.collection.support.builder.CollectionSetBuilder)2 InterfaceLevelResource (org.opennms.netmgt.collection.support.builder.InterfaceLevelResource)2 NodeLevelResource (org.opennms.netmgt.collection.support.builder.NodeLevelResource)2 DefaultDataCollectionConfigDao (org.opennms.netmgt.config.DefaultDataCollectionConfigDao)2 NodeDao (org.opennms.netmgt.dao.api.NodeDao)2 EventProxy (org.opennms.netmgt.events.api.EventProxy)2 OnmsAssetRecord (org.opennms.netmgt.model.OnmsAssetRecord)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 XmlDataCollectionConfigDaoJaxb (org.opennms.protocols.xml.dao.jaxb.XmlDataCollectionConfigDaoJaxb)2 Resource (org.springframework.core.io.Resource)2