// of trap loss.
// We set the priority of the DaemonTaskServer to
// Thread.NORM_PRIORITY so that emptying the socket takes
// precedence over trap processing.
//
final DaemonTaskServer taskServer = new DaemonTaskServer();
taskServer.start(Thread.NORM_PRIORITY);
// Create a listener and dispatcher for SNMP traps
// (SnmpEventReportDispatcher).
// SnmpEventReportDispatcher is run as a thread and listens
// for traps in UDP port = agent port + 1.
// Add TrapListenerImpl as SnmpTrapListener.
// TrapListenerImpl will receive a callback when a valid trap
// PDU is received.
//
final SnmpEventReportDispatcher trapAgent =
new SnmpEventReportDispatcher((this.getTrapSnmpPort()),
null, taskServer, null);
SNMPTrapListenerImpl trapListener = new SNMPTrapListenerImpl();
trapAgent.addTrapListener(trapListener);
final Thread trapThread = new Thread(trapAgent);
trapThread.setPriority(Thread.MAX_PRIORITY);
trapThread.start();
// One Trap
this.setDown();
int trapNumbers = trapListener.getNumberV1Traps();
// Should received 1 traps
assertEquals(trapNumbers, 1);
trapAgent.close();
taskServer.terminate();
return;
} catch (Exception e) {
fail("SyncManager::main: " +