Polish SerializationTestUtils, clean up warnings, etc.

This commit is contained in:
Sam Brannen
2020-06-20 18:17:03 +02:00
parent 9d5881e0ad
commit ab0e651547
43 changed files with 133 additions and 126 deletions

View File

@@ -75,10 +75,10 @@ class SocketUtilsTests {
}
@Test
@SuppressWarnings("try")
void findAvailableTcpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
int port = SocketUtils.findAvailableTcpPort();
try (ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(port, 1, InetAddress.getByName("localhost"))) {
assertThat(socket).isNotNull();
// will only look for the exact port
assertThatIllegalStateException().isThrownBy(() ->
SocketUtils.findAvailableTcpPort(port, port))
@@ -149,10 +149,10 @@ class SocketUtilsTests {
}
@Test
@SuppressWarnings("try")
void findAvailableUdpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
int port = SocketUtils.findAvailableUdpPort();
try (DatagramSocket socket = new DatagramSocket(port, InetAddress.getByName("localhost"))) {
assertThat(socket).isNotNull();
// will only look for the exact port
assertThatIllegalStateException().isThrownBy(() ->
SocketUtils.findAvailableUdpPort(port, port))