use of org.opennms.netmgt.snmp.SnmpWalker in project opennms by OpenNMS.
the class MockSnmpStrategyTest method walk.
private SnmpWalker walk(final CollectionTracker c, final int maxVarsPerPdu, final int maxRepetitions) throws Exception {
final SnmpAgentConfig config = getAgentConfig();
final SnmpWalker walker = SnmpUtils.createWalker(config, "test", c);
assertNotNull(walker);
return walker;
}
use of org.opennms.netmgt.snmp.SnmpWalker in project opennms by OpenNMS.
the class MockSnmpStrategyTest method testCallbackOnTrackerTimeout.
@Test
public void testCallbackOnTrackerTimeout() throws Exception {
// Expect an exception on get
expectedEx.expect(Exception.class);
expectedEx.expectMessage("Timeout retrieving 'test' for 127.0.0.1");
final CountingColumnTracker ct = new CountingColumnTracker(SnmpObjId.get(".1.3.5.1.1"));
final SnmpAgentConfig sac = getAgentConfig();
sac.setPort(12345);
try (final SnmpWalker walker = SnmpUtils.createWalker(sac, "test", ct)) {
walker.start();
final CompletableFuture<Long> future = toCompletableFuture(ct, walker);
future.get();
}
}
use of org.opennms.netmgt.snmp.SnmpWalker in project opennms by OpenNMS.
the class MockSnmpStrategyTest method testCallbackOnTrackerSuccess.
@Test
public void testCallbackOnTrackerSuccess() throws Exception {
final CountingColumnTracker ct = new CountingColumnTracker(SnmpObjId.get(".1.3.5.1.1"));
try (final SnmpWalker walker = walk(ct, 10, 3)) {
final CompletableFuture<Long> future = toCompletableFuture(ct, walker);
walker.start();
assertEquals("number of columns returned must match test data", Long.valueOf(9), future.get());
}
}
Aggregations