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:
parent
b26f13d3b9
commit
98db0d3908
@ -112,7 +112,7 @@ public class NioDatagramChannelTest {
|
|||||||
assertFalse("The payload should have been cleared", expectedPayload
|
assertFalse("The payload should have been cleared", expectedPayload
|
||||||
.equals(new String(dp.getData())));
|
.equals(new String(dp.getData())));
|
||||||
|
|
||||||
udpClient.receive(dp);
|
udpClient.receive(dp, 4000);
|
||||||
|
|
||||||
assertEquals(expectedPayload, new String(dp.getData()));
|
assertEquals(expectedPayload, new String(dp.getData()));
|
||||||
udpClient.close();
|
udpClient.close();
|
||||||
|
@ -48,7 +48,8 @@ public class UdpClient {
|
|||||||
return dp;
|
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);
|
clientSocket.receive(dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user