Search in sources :

Example 1 with NSClientDataCollectionConfigFactory

use of org.opennms.protocols.nsclient.config.NSClientDataCollectionConfigFactory in project opennms by OpenNMS.

the class NsclientCollectorTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    startServer("None&8&", "10");
    // Initialize Mocks
    m_transactionManager = new MockPlatformTransactionManager();
    m_ipInterfaceDao = EasyMock.createMock(IpInterfaceDao.class);
    m_eventProxy = EasyMock.createMock(EventProxy.class);
    NetworkBuilder builder = new NetworkBuilder();
    builder.addNode("winsrv");
    builder.addInterface(getServer().getInetAddress().getHostAddress()).addSnmpInterface(1).setCollectionEnabled(true);
    builder.getCurrentNode().setId(1);
    OnmsIpInterface iface = builder.getCurrentNode().getIpInterfaces().iterator().next();
    iface.setIsSnmpPrimary(PrimaryType.PRIMARY);
    iface.setId(1);
    EasyMock.expect(m_ipInterfaceDao.load(1)).andReturn(iface).anyTimes();
    EasyMock.replay(m_ipInterfaceDao, m_eventProxy);
    // Initialize NSClient Configuration
    String nsclient_config = "<nsclient-config port=\"" + getServer().getLocalPort() + "\" retry=\"1\" timeout=\"3000\" />";
    NSClientPeerFactory.setInstance(new NSClientPeerFactory(new ByteArrayInputStream(nsclient_config.getBytes())));
    NSClientDataCollectionConfigFactory.setInstance(new NSClientDataCollectionConfigFactory("src/test/resources/nsclient-datacollection-config.xml"));
    // Initialize Collection Agent
    m_collectionAgent = DefaultCollectionAgent.create(1, m_ipInterfaceDao, m_transactionManager);
}
Also used : NSClientPeerFactory(org.opennms.protocols.nsclient.config.NSClientPeerFactory) NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) NSClientDataCollectionConfigFactory(org.opennms.protocols.nsclient.config.NSClientDataCollectionConfigFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) MockPlatformTransactionManager(org.opennms.core.test.MockPlatformTransactionManager) EventProxy(org.opennms.netmgt.events.api.EventProxy) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) Before(org.junit.Before)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 Before (org.junit.Before)1 MockPlatformTransactionManager (org.opennms.core.test.MockPlatformTransactionManager)1 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)1 EventProxy (org.opennms.netmgt.events.api.EventProxy)1 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 NSClientDataCollectionConfigFactory (org.opennms.protocols.nsclient.config.NSClientDataCollectionConfigFactory)1 NSClientPeerFactory (org.opennms.protocols.nsclient.config.NSClientPeerFactory)1