TrapListener extends Thread implements CommandResponder, RegisterTrapCallback { @Override public void processPdu(CommandResponderEvent event) { String senderAddress = event.getPeerAddress().toString(); String sender = senderAddress.substring(0, senderAddress.indexOf("/")); if (m_callbacks.containsKey(sender)) { m_callbacks.get(sender).processTrap(event); } }  @Override void registerCallBackForTrapUpdates(ProcessTrapCallBack trapCallBack, String ipAddr, String port); @Override void unRegisterCallBackForTrapUpdates(ProcessTrapCallBack trapCallBack, String ipAddr, String port); void startup(); void run(); void shutdown(); @Override void processPdu(CommandResponderEvent event);  }
@Test public void testProcessPdu() throws Exception { m_trapListener.registerCallBackForTrapUpdates(m_trapCallback, "0.0.0.0", "162"); InetAddress inetAddress = InetAddress.getByName("0.0.0.0"); Address address = new UdpAddress(inetAddress, 162); when( event.getPeerAddress()).thenReturn(address); m_trapListener.processPdu(event); verify(m_trapCallback).processTrap(event); }