Added a timeout for the UdpClient so that the test cannot hang.

I noticed the build "hanging/halting" on the test when running the cobertura code coverage Eclipse plugin.
This commit is contained in:
Daniel Bevenius 2011-02-10 13:29:53 +01:00 committed by Trustin Lee
parent b26f13d3b9
commit 98db0d3908
2 changed files with 3 additions and 2 deletions

View File

@ -112,7 +112,7 @@ public class NioDatagramChannelTest {
assertFalse("The payload should have been cleared", expectedPayload
.equals(new String(dp.getData())));
udpClient.receive(dp);
udpClient.receive(dp, 4000);
assertEquals(expectedPayload, new String(dp.getData()));
udpClient.close();

View File

@ -48,7 +48,8 @@ public class UdpClient {
return dp;
}
public void receive(final DatagramPacket dp) throws IOException {
public void receive(final DatagramPacket dp, final int timeout) throws IOException {
clientSocket.setSoTimeout(timeout);
clientSocket.receive(dp);
}