@Test public void testSendEventOneParm() { Date date = new Date(); String parmZeroName = "foo"; String parmZeroContent = "bar"; String parmZeroType = "string"; Hashtable<String, String> eventMap = basicEventMap(date); addRpcParm(eventMap, 0, parmZeroName, parmZeroContent, parmZeroType); m_anticipator.anticipateCall("sendEvent", eventMap); EventBuilder bldr = basicEventBuilder(date); bldr.addParam(parmZeroName, parmZeroContent, parmZeroType, "text"); assertTrue("notifier sendEvent", m_notifier.sendEvent(bldr.getEvent())); finishUp(); }
public boolean sendEvent(final Event event) { Assert.notNull(event, "event object must not be null"); final Vector<Object> params = new Vector<Object>(); final Hashtable<String, String> table = new Hashtable<String, String>(); params.addElement(table); final String source = event.getSource(); if (source != null) { table.put("source", source); } final String label = getLabelForEventNode(event); if (label != null) { table.put("nodeLabel", label); } final String host = getEventHost(event); if (host != null) { table.put("host", host); } table.put("time", String.valueOf(event.getTime())); table.put("uei", String.valueOf(event.getUei())); table.put("nodeId", Long.toString(event.getNodeid())); final String intf = event.getInterface(); if (intf != null) { table.put("interface", intf); } final String service = event.getService(); if (service != null) { table.put("service", service); } final String descr = event.getDescr(); if (descr != null) { table.put("description", descr); } final String severity = event.getSeverity(); if (severity != null) { table.put("severity", event.getSeverity()); } final List<Parm> eventParams = event.getParmCollection(); if (eventParams != null) { final int numParams = eventParams.size(); for (int i = 0; i < numParams; i++) { final Parm p = eventParams.get(i); final Value v = p.getValue(); table.put("param" + i + " name", p.getParmName()); table.put("param" + i + " type", v.getType()); table.put("param" + i + " value", v.getContent()); } } if (event.getSnmp() == null) { return sendXmlrpcRequest(XMLRPC_GENERIC_COMMAND, params); } else { final Snmp trapInfo = event.getSnmp(); table.put("communityString", String.valueOf(trapInfo.getCommunity())); table.put("genericTrapNumber", Integer.toString(trapInfo.getGeneric())); table.put("enterpriseId", String.valueOf(trapInfo.getId())); if (trapInfo.getIdtext() != null) { table.put("enterpriseIdText", trapInfo.getIdtext()); } table.put("specificTrapNumber", Integer.toString(trapInfo.getSpecific())); table.put("timeStamp", Long.toString(trapInfo.getTimeStamp())); table.put("version", String.valueOf(trapInfo.getVersion())); return sendXmlrpcRequest(XMLRPC_SNMP_TRAP_COMMAND, params); } }
XmlRpcNotifier { public boolean sendEvent(final Event event) { Assert.notNull(event, "event object must not be null"); final Vector<Object> params = new Vector<Object>(); final Hashtable<String, String> table = new Hashtable<String, String>(); params.addElement(table); final String source = event.getSource(); if (source != null) { table.put("source", source); } final String label = getLabelForEventNode(event); if (label != null) { table.put("nodeLabel", label); } final String host = getEventHost(event); if (host != null) { table.put("host", host); } table.put("time", String.valueOf(event.getTime())); table.put("uei", String.valueOf(event.getUei())); table.put("nodeId", Long.toString(event.getNodeid())); final String intf = event.getInterface(); if (intf != null) { table.put("interface", intf); } final String service = event.getService(); if (service != null) { table.put("service", service); } final String descr = event.getDescr(); if (descr != null) { table.put("description", descr); } final String severity = event.getSeverity(); if (severity != null) { table.put("severity", event.getSeverity()); } final List<Parm> eventParams = event.getParmCollection(); if (eventParams != null) { final int numParams = eventParams.size(); for (int i = 0; i < numParams; i++) { final Parm p = eventParams.get(i); final Value v = p.getValue(); table.put("param" + i + " name", p.getParmName()); table.put("param" + i + " type", v.getType()); table.put("param" + i + " value", v.getContent()); } } if (event.getSnmp() == null) { return sendXmlrpcRequest(XMLRPC_GENERIC_COMMAND, params); } else { final Snmp trapInfo = event.getSnmp(); table.put("communityString", String.valueOf(trapInfo.getCommunity())); table.put("genericTrapNumber", Integer.toString(trapInfo.getGeneric())); table.put("enterpriseId", String.valueOf(trapInfo.getId())); if (trapInfo.getIdtext() != null) { table.put("enterpriseIdText", trapInfo.getIdtext()); } table.put("specificTrapNumber", Integer.toString(trapInfo.getSpecific())); table.put("timeStamp", Long.toString(trapInfo.getTimeStamp())); table.put("version", String.valueOf(trapInfo.getVersion())); return sendXmlrpcRequest(XMLRPC_SNMP_TRAP_COMMAND, params); } } }
XmlRpcNotifier { public boolean sendEvent(final Event event) { Assert.notNull(event, "event object must not be null"); final Vector<Object> params = new Vector<Object>(); final Hashtable<String, String> table = new Hashtable<String, String>(); params.addElement(table); final String source = event.getSource(); if (source != null) { table.put("source", source); } final String label = getLabelForEventNode(event); if (label != null) { table.put("nodeLabel", label); } final String host = getEventHost(event); if (host != null) { table.put("host", host); } table.put("time", String.valueOf(event.getTime())); table.put("uei", String.valueOf(event.getUei())); table.put("nodeId", Long.toString(event.getNodeid())); final String intf = event.getInterface(); if (intf != null) { table.put("interface", intf); } final String service = event.getService(); if (service != null) { table.put("service", service); } final String descr = event.getDescr(); if (descr != null) { table.put("description", descr); } final String severity = event.getSeverity(); if (severity != null) { table.put("severity", event.getSeverity()); } final List<Parm> eventParams = event.getParmCollection(); if (eventParams != null) { final int numParams = eventParams.size(); for (int i = 0; i < numParams; i++) { final Parm p = eventParams.get(i); final Value v = p.getValue(); table.put("param" + i + " name", p.getParmName()); table.put("param" + i + " type", v.getType()); table.put("param" + i + " value", v.getContent()); } } if (event.getSnmp() == null) { return sendXmlrpcRequest(XMLRPC_GENERIC_COMMAND, params); } else { final Snmp trapInfo = event.getSnmp(); table.put("communityString", String.valueOf(trapInfo.getCommunity())); table.put("genericTrapNumber", Integer.toString(trapInfo.getGeneric())); table.put("enterpriseId", String.valueOf(trapInfo.getId())); if (trapInfo.getIdtext() != null) { table.put("enterpriseIdText", trapInfo.getIdtext()); } table.put("specificTrapNumber", Integer.toString(trapInfo.getSpecific())); table.put("timeStamp", Long.toString(trapInfo.getTimeStamp())); table.put("version", String.valueOf(trapInfo.getVersion())); return sendXmlrpcRequest(XMLRPC_SNMP_TRAP_COMMAND, params); } } XmlRpcNotifier(final XmlrpcServer[] rpcServers, final int retries, final int elapseTime, final boolean verifyServer, final String localServer); }
XmlRpcNotifier { public boolean sendEvent(final Event event) { Assert.notNull(event, "event object must not be null"); final Vector<Object> params = new Vector<Object>(); final Hashtable<String, String> table = new Hashtable<String, String>(); params.addElement(table); final String source = event.getSource(); if (source != null) { table.put("source", source); } final String label = getLabelForEventNode(event); if (label != null) { table.put("nodeLabel", label); } final String host = getEventHost(event); if (host != null) { table.put("host", host); } table.put("time", String.valueOf(event.getTime())); table.put("uei", String.valueOf(event.getUei())); table.put("nodeId", Long.toString(event.getNodeid())); final String intf = event.getInterface(); if (intf != null) { table.put("interface", intf); } final String service = event.getService(); if (service != null) { table.put("service", service); } final String descr = event.getDescr(); if (descr != null) { table.put("description", descr); } final String severity = event.getSeverity(); if (severity != null) { table.put("severity", event.getSeverity()); } final List<Parm> eventParams = event.getParmCollection(); if (eventParams != null) { final int numParams = eventParams.size(); for (int i = 0; i < numParams; i++) { final Parm p = eventParams.get(i); final Value v = p.getValue(); table.put("param" + i + " name", p.getParmName()); table.put("param" + i + " type", v.getType()); table.put("param" + i + " value", v.getContent()); } } if (event.getSnmp() == null) { return sendXmlrpcRequest(XMLRPC_GENERIC_COMMAND, params); } else { final Snmp trapInfo = event.getSnmp(); table.put("communityString", String.valueOf(trapInfo.getCommunity())); table.put("genericTrapNumber", Integer.toString(trapInfo.getGeneric())); table.put("enterpriseId", String.valueOf(trapInfo.getId())); if (trapInfo.getIdtext() != null) { table.put("enterpriseIdText", trapInfo.getIdtext()); } table.put("specificTrapNumber", Integer.toString(trapInfo.getSpecific())); table.put("timeStamp", Long.toString(trapInfo.getTimeStamp())); table.put("version", String.valueOf(trapInfo.getVersion())); return sendXmlrpcRequest(XMLRPC_SNMP_TRAP_COMMAND, params); } } XmlRpcNotifier(final XmlrpcServer[] rpcServers, final int retries, final int elapseTime, final boolean verifyServer, final String localServer); boolean notifySuccess(final long txNo, final String uei, final String message); boolean notifyFailure(final long txNo, final String uei, final String reason); boolean notifyReceivedEvent(final long txNo, final String uei, final String message); boolean sendServiceDownEvent(final Event event); boolean sendServiceUpEvent(final Event event); boolean sendInterfaceDownEvent(final Event event); boolean sendInterfaceUpEvent(final Event event); boolean sendNodeDownEvent(final Event event); boolean sendNodeUpEvent(final Event event); boolean sendEvent(final Event event); void createConnection(); }
XmlRpcNotifier { public boolean sendEvent(final Event event) { Assert.notNull(event, "event object must not be null"); final Vector<Object> params = new Vector<Object>(); final Hashtable<String, String> table = new Hashtable<String, String>(); params.addElement(table); final String source = event.getSource(); if (source != null) { table.put("source", source); } final String label = getLabelForEventNode(event); if (label != null) { table.put("nodeLabel", label); } final String host = getEventHost(event); if (host != null) { table.put("host", host); } table.put("time", String.valueOf(event.getTime())); table.put("uei", String.valueOf(event.getUei())); table.put("nodeId", Long.toString(event.getNodeid())); final String intf = event.getInterface(); if (intf != null) { table.put("interface", intf); } final String service = event.getService(); if (service != null) { table.put("service", service); } final String descr = event.getDescr(); if (descr != null) { table.put("description", descr); } final String severity = event.getSeverity(); if (severity != null) { table.put("severity", event.getSeverity()); } final List<Parm> eventParams = event.getParmCollection(); if (eventParams != null) { final int numParams = eventParams.size(); for (int i = 0; i < numParams; i++) { final Parm p = eventParams.get(i); final Value v = p.getValue(); table.put("param" + i + " name", p.getParmName()); table.put("param" + i + " type", v.getType()); table.put("param" + i + " value", v.getContent()); } } if (event.getSnmp() == null) { return sendXmlrpcRequest(XMLRPC_GENERIC_COMMAND, params); } else { final Snmp trapInfo = event.getSnmp(); table.put("communityString", String.valueOf(trapInfo.getCommunity())); table.put("genericTrapNumber", Integer.toString(trapInfo.getGeneric())); table.put("enterpriseId", String.valueOf(trapInfo.getId())); if (trapInfo.getIdtext() != null) { table.put("enterpriseIdText", trapInfo.getIdtext()); } table.put("specificTrapNumber", Integer.toString(trapInfo.getSpecific())); table.put("timeStamp", Long.toString(trapInfo.getTimeStamp())); table.put("version", String.valueOf(trapInfo.getVersion())); return sendXmlrpcRequest(XMLRPC_SNMP_TRAP_COMMAND, params); } } XmlRpcNotifier(final XmlrpcServer[] rpcServers, final int retries, final int elapseTime, final boolean verifyServer, final String localServer); boolean notifySuccess(final long txNo, final String uei, final String message); boolean notifyFailure(final long txNo, final String uei, final String reason); boolean notifyReceivedEvent(final long txNo, final String uei, final String message); boolean sendServiceDownEvent(final Event event); boolean sendServiceUpEvent(final Event event); boolean sendInterfaceDownEvent(final Event event); boolean sendInterfaceUpEvent(final Event event); boolean sendNodeDownEvent(final Event event); boolean sendNodeUpEvent(final Event event); boolean sendEvent(final Event event); void createConnection();  }