From 42455830c0b186042f4073b9dccaaee824cc7a86 Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Sun, 11 Oct 2020 11:14:36 +0200 Subject: [PATCH] BAEL-4504: Fix PR comments --- .../java/com/baeldung/socket/FindFreePortUnitTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java index 6402a086e6..d045f753ea 100644 --- a/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java +++ b/core-java-modules/core-java-networking-3/src/test/java/com/baeldung/socket/FindFreePortUnitTest.java @@ -21,7 +21,7 @@ public class FindFreePortUnitTest { @BeforeAll public static void getExplicitFreePortNumberAndRange() { - try (ServerSocket serverSocket = new ServerSocket(0);) { + try (ServerSocket serverSocket = new ServerSocket(0)) { FREE_PORT_NUMBER = serverSocket.getLocalPort(); FREE_PORT_RANGE = new int[] {FREE_PORT_NUMBER, FREE_PORT_NUMBER + 1, FREE_PORT_NUMBER + 2}; } catch (IOException e) { @@ -31,7 +31,7 @@ public class FindFreePortUnitTest { @Test public void givenExplicitFreePort_whenCreatingServerSocket_thenThatPortIsAssigned() { - try (ServerSocket serverSocket = new ServerSocket(FREE_PORT_NUMBER);) { + try (ServerSocket serverSocket = new ServerSocket(FREE_PORT_NUMBER)) { assertThat(serverSocket).isNotNull(); assertThat(serverSocket.getLocalPort()).isEqualTo(FREE_PORT_NUMBER); } catch (IOException e) { @@ -54,7 +54,7 @@ public class FindFreePortUnitTest { for (int port : FREE_PORT_RANGE) { try (ServerSocket serverSocket = new ServerSocket(port)) { assertThat(serverSocket).isNotNull(); - assertThat(serverSocket.getLocalPort()).isGreaterThan(0); + assertThat(serverSocket.getLocalPort()).isEqualTo(port); return; } catch (IOException e) { assertThat(e).hasMessageContaining("Address already in use"); @@ -78,7 +78,7 @@ public class FindFreePortUnitTest { int port = SocketUtils.findAvailableTcpPort(); try (ServerSocket serverSocket = new ServerSocket(port)) { assertThat(serverSocket).isNotNull(); - assertThat(serverSocket.getLocalPort()).isGreaterThan(0); + assertThat(serverSocket.getLocalPort()).isEqualTo(port); } catch (IOException e) { fail("Port is not available"); }