use of org.opennms.protocols.nsclient.config.NSClientPeerFactory 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);
}
Aggregations