Skip to content

Commit 622709f

Browse files
committed
Update DatagramSocketTests
1 parent 4f90e6d commit 622709f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

examples/demo/src/main/java/com/datagramSocket/DatagramSocketTests.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,27 @@ public void testOk() throws Exception {
2121
ds.close();
2222
}
2323

24-
public void testSendingAfterDisconnecting() throws Exception {
24+
public void testBindTwice() throws Exception {
2525
DatagramSocket ds = new DatagramSocket(8080);
26-
ds.connect(null);
27-
ds.disconnect();
28-
ds.send(null); // error
26+
ds.bind(null); // error
2927
}
3028

3129
public void testBindingAfterAlreadyBound() throws Exception {
3230
DatagramSocket ds = new DatagramSocket(8080);
3331
ds.bind(null); // error
3432
}
33+
34+
public void testConnectingAfterClosing() throws Exception {
35+
DatagramSocket ds = new DatagramSocket(8080);
36+
ds.connect(null);
37+
ds.close();
38+
ds.connect(null); // error
39+
}
40+
41+
public void testBound() throws Exception {
42+
DatagramSocket ds = new DatagramSocket(8080);
43+
if (!ds.isBound()) {
44+
ds.bind(null); // this should not be an error
45+
}
46+
}
3547
}

0 commit comments

Comments
 (0)