@Test(expected = EndPointStatusException.class) @JUnitSnmpAgent(host = "192.168.254.10", resource = "/horizon_duo_walk.properties") public void dwoTestLinkMonitorHorizonDuoCapacity3DownModemLossSignal() throws UnknownHostException, EndPointStatusException { SnmpUtils.set( getAgentConfig("192.168.254.10"), SnmpObjId.get(HORIZON_DUO_MODEM_LOSS_OF_SIGNAL), SnmpUtils.getValueFactory().getCounter32(2)); SnmpUtils.set( getAgentConfig("192.168.254.10"), SnmpObjId.get(HORIZON_DUO_SYSTEM_CAPACITY), SnmpUtils.getValueFactory().getCounter32(3)); EndPoint endPoint = getEndPoint(HORIZON_DUO_SYS_OID, "192.168.254.10"); m_configDao.getValidator().validate(endPoint); }
@Test(expected = EndPointStatusException.class) @JUnitSnmpAgent(host = "192.168.255.31", resource = "/horizon_compact_walk.properties") public void dwoTestLinkMonitorHorizonCompactDownEthernetLinkDown() throws EndPointStatusException, UnknownHostException { SnmpUtils.set( getAgentConfig("192.168.255.31"), SnmpObjId.get(HORIZON_COMPACT_MODEM_LOSS_OF_SIGNAL), SnmpUtils.getValueFactory().getCounter32(1)); SnmpUtils.set( getAgentConfig("192.168.255.31"), SnmpObjId.get(HORIZON_COMPACT_ETHERNET_LINK_DOWN), SnmpUtils.getValueFactory().getCounter32(2)); EndPoint endPoint = getEndPoint(HORIZON_COMPACT_SYS_OID, "192.168.255.31"); m_configDao.getValidator().validate(endPoint); }
@Test(expected = EndPointStatusException.class) @JUnitSnmpAgent(host = "192.168.255.10", resource = "classpath:/airPairR3_walk.properties") public void dwoTestLinkMonitorAirPair3DownLossOfSignal() throws UnknownHostException, EndPointStatusException { SnmpUtils.set( getAgentConfig("192.168.255.10"), SnmpObjId.get(AIR_PAIR_MODEM_LOSS_OF_SIGNAL), SnmpUtils.getValueFactory().getCounter32(2)); SnmpUtils.set( getAgentConfig("192.168.255.10"), SnmpObjId.get(AIR_PAIR_R3_DUPLEX_MISMATCH), SnmpUtils.getValueFactory().getCounter32(1)); EndPointImpl endPoint = getEndPoint(AIR_PAIR_R3_SYS_OID, "192.168.255.10"); m_configDao.getValidator().validate(endPoint); }
/** * Constructs a new SnmpVarBind with the specified name and value. The value will be encoded as * an SnmpObjectId. The value is assumed to have been encoded with the specified encoding (only * XML_ENCODING_TEXT is supported). * * @param name The name (a.k.a. "id") of the variable binding to be created * @param encoding Describes the way in which the value content has been encoded (i.e. * XML_ENCODING_TEXT, or XML_ENCODING_BASE64) * @param value The variable binding value * @return The newly-created variable binding * @exception Throws SnmpTrapHelperException if the variable binding cannot be created for any * reason (e.g. encoding not supported, invalid value, etc.). */ @Override public void addVarBind(SnmpTrapBuilder trap, String name, String encoding, String value) throws SnmpTrapHelperException { if (EventConstants.XML_ENCODING_TEXT.equals(encoding)) { trap.addVarBind( SnmpObjId.get(name), SnmpUtils.getValueFactory().getObjectId(SnmpObjId.get(value))); } else { throw new SnmpTrapHelperException("Encoding " + encoding + "is invalid for SnmpObjectId"); } }
/** * Constructs a new SnmpVarBind with the specified name and value. The value will be encoded as * an SnmpOpaque. The value is assumed to have been encoded with the specified encoding (only * XML_ENCODING_BASE64 is supported). * * @param name The name (a.k.a. "id") of the variable binding to be created * @param encoding Describes the way in which the value content has been encoded (i.e. * XML_ENCODING_TEXT, or XML_ENCODING_BASE64) * @param value The variable binding value * @return The newly-created variable binding * @exception Throws SnmpTrapHelperException if the variable binding cannot be created for any * reason (e.g. encoding not supported, invalid value, etc.). */ @Override public void addVarBind(SnmpTrapBuilder trap, String name, String encoding, String value) throws SnmpTrapHelperException { if (EventConstants.XML_ENCODING_BASE64.equals(encoding)) { trap.addVarBind( SnmpObjId.get(name), SnmpUtils.getValueFactory().getOpaque(Base64.decodeBase64(value.toCharArray()))); } else { throw new SnmpTrapHelperException("Encoding " + encoding + "is invalid for SnmpOpaque"); } }
@Test @Ignore @JUnitSnmpAgent(host = "192.168.255.20", resource = "/airPairR4_walk.properties") public void dwoTestLinkMonitorAirPairR4() throws UnknownHostException { SnmpUtils.set( getAgentConfig("192.168.255.20"), SnmpObjId.get(AIR_PAIR_MODEM_LOSS_OF_SIGNAL), SnmpUtils.getValueFactory().getCounter32(1)); SnmpUtils.set( getAgentConfig("192.168.255.20"), SnmpObjId.get(AIR_PAIR_R4_MODEM_LOSS_OF_SIGNAL), SnmpUtils.getValueFactory().getCounter32(1)); EndPointImpl endPoint = getEndPoint(AIR_PAIR_R4_SYS_OID, "192.168.255.20"); try { m_configDao.getValidator().validate(endPoint); } catch (EndPointStatusException e) { assertTrue("An EndPointStatusException was caught resulting in a failed test", false); } }
@Test @JUnitSnmpAgent(host = "192.168.255.10", resource = "classpath:/airPairR3_walk.properties") public void dwoTestLinkMonitorAirPairR3() throws UnknownHostException { SnmpUtils.set( getAgentConfig("192.168.255.10"), SnmpObjId.get(AIR_PAIR_MODEM_LOSS_OF_SIGNAL), SnmpUtils.getValueFactory().getCounter32(1)); SnmpUtils.set( getAgentConfig("192.168.255.10"), SnmpObjId.get(AIR_PAIR_R3_DUPLEX_MISMATCH), SnmpUtils.getValueFactory().getCounter32(1)); EndPointImpl endPoint = getEndPoint(AIR_PAIR_R3_SYS_OID, "192.168.255.10"); EndPointTypeValidator validator = m_configDao.getValidator(); try { validator.validate(endPoint); } catch (EndPointStatusException e) { assertTrue(false); } }
@Test @JUnitSnmpAgent(host = "192.168.255.31", resource = "/horizon_compact_walk.properties") public void dwoTestLinkMonitorHorizonCompact() throws UnknownHostException { SnmpUtils.set( getAgentConfig("192.168.255.31"), SnmpObjId.get(HORIZON_COMPACT_MODEM_LOSS_OF_SIGNAL), SnmpUtils.getValueFactory().getCounter32(1)); SnmpUtils.set( getAgentConfig("192.168.255.31"), SnmpObjId.get(HORIZON_COMPACT_ETHERNET_LINK_DOWN), SnmpUtils.getValueFactory().getCounter32(1)); EndPointImpl endPoint = getEndPoint(HORIZON_COMPACT_SYS_OID, "192.168.255.31"); try { m_configDao.getValidator().validate(endPoint); } catch (Throwable e) { assertTrue( "An EndPointStatusException was thrown which shouldn't have and thats why the test failed", false); } }
/** * Constructs a new SnmpVarBind with the specified name and value. The value will be encoded as * an SnmpIPAddress. The value is assumed to have been encoded with the specified encoding (only * XML_ENCODING_TEXT is supported). * * @param name The name (a.k.a. "id") of the variable binding to be created * @param encoding Describes the way in which the value content has been encoded (i.e. * XML_ENCODING_TEXT, or XML_ENCODING_BASE64) * @param value The variable binding value * @return The newly-created variable binding * @exception Throws SnmpTrapHelperException if the variable binding cannot be created for any * reason (e.g. encoding not supported, invalid value, etc.). */ @Override public void addVarBind(SnmpTrapBuilder trap, String name, String encoding, String value) throws SnmpTrapHelperException { if (EventConstants.XML_ENCODING_TEXT.equals(encoding)) { final InetAddress addr = InetAddressUtils.addr(value); if (addr == null) { throw new SnmpTrapHelperException( "Value " + value + "is invalid, or host unknown for SnmpIPAddress"); } trap.addVarBind(SnmpObjId.get(name), SnmpUtils.getValueFactory().getIpAddress(addr)); } else { throw new SnmpTrapHelperException("Encoding " + encoding + "is invalid for SnmpIPAddress"); } }
/** * Constructs a new SnmpVarBind with the specified name and value. The value will be encoded as * an SnmpCounter64. The value is assumed to have been encoded with the specified encoding (only * XML_ENCODING_TEXT is supported). * * @param name The name (a.k.a. "id") of the variable binding to be created * @param encoding Describes the way in which the value content has been encoded (i.e. * XML_ENCODING_TEXT, or XML_ENCODING_BASE64) * @param value The variable binding value * @return The newly-created variable binding * @exception Throws SnmpTrapHelperException if the variable binding cannot be created for any * reason (e.g. encoding not supported, invalid value, etc.). */ @Override public void addVarBind(SnmpTrapBuilder trap, String name, String encoding, String value) throws SnmpTrapHelperException { if (EventConstants.XML_ENCODING_TEXT.equals(encoding)) { try { trap.addVarBind( SnmpObjId.get(name), SnmpUtils.getValueFactory().getCounter64(new BigInteger(value))); } catch (IllegalArgumentException e) { throw new SnmpTrapHelperException("Value " + value + "is invalid for SnmpCounter64"); } catch (NullPointerException e) { throw new SnmpTrapHelperException("Value is null for SnmpCounter64"); } } else { throw new SnmpTrapHelperException("Encoding " + encoding + "is invalid for SnmpCounter64"); } }
/** * Constructs a new SnmpVarBind with the specified name and value. The value will be encoded as * an SnmpOctetString. The value is assumed to have been encoded with the specified encoding * (i.e. XML_ENCODING_TEXT, XML_ENCODING_BASE64, or XML_ENCODING_MAC_ADDRESS). * * @param name The name (a.k.a. "id") of the variable binding to be created * @param encoding Describes the way in which the value content has been encoded (i.e. * XML_ENCODING_TEXT, XML_ENCODING_BASE64, or XML_ENCODING_MAC_ADDRESS) * @param value The variable binding value * @return The newly-created variable binding * @exception Throws SnmpTrapHelperException if the variable binding cannot be created for any * reason (e.g. encoding not supported, invalid value, etc.). */ @Override public void addVarBind(SnmpTrapBuilder trap, String name, String encoding, String value) throws SnmpTrapHelperException { byte[] contents; if (EventConstants.XML_ENCODING_TEXT.equals(encoding)) { contents = value.getBytes(); } else if (EventConstants.XML_ENCODING_BASE64.equals(encoding)) { contents = Base64.decodeBase64(value.toCharArray()); } else if (EventConstants.XML_ENCODING_MAC_ADDRESS.equals(encoding)) { contents = InetAddressUtils.macAddressStringToBytes(value); } else { throw new SnmpTrapHelperException( "Encoding " + encoding + "is invalid for SnmpOctetString"); } trap.addVarBind(SnmpObjId.get(name), SnmpUtils.getValueFactory().getOctetString(contents)); }
/** * Constructs a new SnmpVarBind with the specified name and value. The value will be encoded as * an SnmpNull.The value and encoding parameters are ignored. * * @param name The name (a.k.a. "id") of the variable binding to be created * @param encoding This parameter value is ignored. * @param value This parameter value is ignored. * @return The newly-created variable binding */ @Override public void addVarBind(SnmpTrapBuilder trap, String name, String encoding, String value) { trap.addVarBind(SnmpObjId.get(name), SnmpUtils.getValueFactory().getNull()); }