Document doc = XMLUtil.createEmptyDocment();
Element elt = doc.createElement("Collector");
elt.setAttribute("address", "localhost");
elt.setAttribute("port", "10000");
UDPServerCollector collector = new UDPServerCollector(elt);
assertTrue(collector.isRunning());
collector.addListener(this);
// Send a packet
line = null;
String test = "This is a test";
byte[] testBytes = test.getBytes("UTF-8");
DatagramPacket request = new DatagramPacket(testBytes, testBytes.length, InetAddress.getLocalHost(), 10000);
DatagramSocket socket = new DatagramSocket();
socket.send(request);
try {
Thread.sleep(500);
} catch (InterruptedException e) {}
assertEquals(line, test);
collector.close();
}