use of org.opennms.netmgt.snmp.SnmpValue in project opennms by OpenNMS.
the class SnmpMonitorStrategyTest method testMeetsCriteriaWithIPAddr.
@Test
public void testMeetsCriteriaWithIPAddr() throws Exception {
SnmpValue result = ipAddr("10.1.1.1");
testSyntaxEquals(result, "10.1.1.1", "10.1.1.2");
testSyntaxMatches(result, "10\\.1\\.1\\.[1-5]", "10\\.1\\.1\\.[02-9]");
}
use of org.opennms.netmgt.snmp.SnmpValue in project opennms by OpenNMS.
the class SnmpMonitorStrategyTest method testErrorConditions2.
@Test
public void testErrorConditions2() {
SnmpValue result = int32Value(1);
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new NumberFormatException("For input string: \"abc\""));
try {
monitor.meetsCriteria(result, "<", "abc");
fail("expected an exception");
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.netmgt.snmp.SnmpValue in project opennms by OpenNMS.
the class SnmpMonitorStrategyTest method testMeetsCriteriaWithGauge32.
@Test
public void testMeetsCriteriaWithGauge32() {
SnmpValue result = gauge32Value(1);
testSyntaxEquals(result, "1", "2");
testOrderOperations(result, 1);
}
use of org.opennms.netmgt.snmp.SnmpValue in project opennms by OpenNMS.
the class SnmpMonitorStrategyTest method testNumericString.
@Test
public void testNumericString() {
SnmpValue result = octetString("12345");
testOrderOperations(result, 12345);
}
use of org.opennms.netmgt.snmp.SnmpValue in project opennms by OpenNMS.
the class SyntaxToEventTest method testProcessSyntaxForMacAddresses.
@Test
public void testProcessSyntaxForMacAddresses() {
SnmpValueFactory valueFactory = SnmpUtils.getValueFactory();
assertNotNull(valueFactory);
byte[] macAddr = { 001, 002, 003, 004, 005, 006 };
SnmpValue octetString = valueFactory.getOctetString(macAddr);
Parm parm = SyntaxToEvent.processSyntax("testMacAddress", octetString);
assertEquals("testMacAddress", parm.getParmName());
assertEquals(EventConstants.XML_ENCODING_MAC_ADDRESS, parm.getValue().getEncoding());
assertEquals("01:02:03:04:05:06", parm.getValue().getContent());
macAddr = new byte[] { (byte) 0x80, (byte) 0x81, (byte) 0x8C, (byte) 0x8F, (byte) 0xFF, (byte) 0x05 };
octetString = valueFactory.getOctetString(macAddr);
parm = SyntaxToEvent.processSyntax("testMacAddress", octetString);
assertEquals("testMacAddress", parm.getParmName());
assertEquals(EventConstants.XML_ENCODING_MAC_ADDRESS, parm.getValue().getEncoding());
assertEquals("80:81:8C:8F:FF:05", parm.getValue().getContent());
macAddr = new byte[] { 0101, 0101, 0101, 0101, 0101, 0101 };
octetString = valueFactory.getOctetString(macAddr);
parm = SyntaxToEvent.processSyntax("otherDataType", octetString);
assertEquals("otherDataType", parm.getParmName());
assertEquals(EventConstants.XML_ENCODING_TEXT, parm.getValue().getEncoding());
assertEquals("AAAAAA", parm.getValue().getContent());
parm = SyntaxToEvent.processSyntax("testMacAddress", octetString);
assertEquals("testMacAddress", parm.getParmName());
assertEquals(EventConstants.XML_ENCODING_MAC_ADDRESS, parm.getValue().getEncoding());
assertEquals("41:41:41:41:41:41", parm.getValue().getContent());
}
Aggregations