You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/02/24 16:48:04 UTC

(commons-net) branch master updated (2de5d64a -> 562df314)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git


    from 2de5d64a Merge pull request #168 from jkbkupczyk/mock_tcp_test_server_daytimetcpclient_tests
     new 30b7e4f1 Sort members
     new 7e6f5230 Sort imports
     new 562df314 Use final

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/net/daytime/DaytimeTCPClientTest.java  | 62 +++++++++++-----------
 .../commons/net/daytime/MockDaytimeTCPServer.java  | 28 +++++-----
 2 files changed, 45 insertions(+), 45 deletions(-)


(commons-net) 01/03: Sort members

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit 30b7e4f168f70570bae2f8604d4e768fffd184fd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Feb 24 11:46:30 2024 -0500

    Sort members
---
 .../commons/net/daytime/DaytimeTCPClientTest.java  | 42 +++++++++++-----------
 .../commons/net/daytime/MockDaytimeTCPServer.java  | 20 +++++------
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/src/test/java/org/apache/commons/net/daytime/DaytimeTCPClientTest.java b/src/test/java/org/apache/commons/net/daytime/DaytimeTCPClientTest.java
index 8e3a1767..d4d70aa8 100644
--- a/src/test/java/org/apache/commons/net/daytime/DaytimeTCPClientTest.java
+++ b/src/test/java/org/apache/commons/net/daytime/DaytimeTCPClientTest.java
@@ -42,12 +42,9 @@ class DaytimeTCPClientTest {
 
     private static MockDaytimeTCPServer mockDaytimeTCPServer;
 
-    private static Stream<Arguments> daytimeMockData() {
-        return Stream.of(
-                Arguments.of("Thursday, February 2, 2006, 13:45:51-PST", ZoneId.of("PST", ZoneId.SHORT_IDS), LocalDateTime.of(2006, 2, 2, 13, 45, 51)),
-                Arguments.of("Thursday, January 1, 2004, 00:00:00-UTC", ZoneId.of("UTC"), LocalDate.of(2004, 1, 1).atStartOfDay()),
-                Arguments.of("Friday, July 28, 2023, 06:06:50-JST", ZoneId.of("JST", ZoneId.SHORT_IDS), LocalDateTime.of(2023, 7, 28, 6, 6, 50, 999))
-        );
+    @AfterAll
+    public static void afterAll() throws IOException {
+        mockDaytimeTCPServer.stop();
     }
 
     @BeforeAll
@@ -56,26 +53,17 @@ class DaytimeTCPClientTest {
         mockDaytimeTCPServer.start();
     }
 
-    @AfterAll
-    public static void afterAll() throws IOException {
-        mockDaytimeTCPServer.stop();
+    private static Stream<Arguments> daytimeMockData() {
+        return Stream.of(
+                Arguments.of("Thursday, February 2, 2006, 13:45:51-PST", ZoneId.of("PST", ZoneId.SHORT_IDS), LocalDateTime.of(2006, 2, 2, 13, 45, 51)),
+                Arguments.of("Thursday, January 1, 2004, 00:00:00-UTC", ZoneId.of("UTC"), LocalDate.of(2004, 1, 1).atStartOfDay()),
+                Arguments.of("Friday, July 28, 2023, 06:06:50-JST", ZoneId.of("JST", ZoneId.SHORT_IDS), LocalDateTime.of(2023, 7, 28, 6, 6, 50, 999))
+        );
     }
 
     private DaytimeTCPClient daytimeTCPClient;
     private InetAddress localHost;
 
-    @BeforeEach
-    public void setUp() throws UnknownHostException {
-        localHost = InetAddress.getLocalHost();
-    }
-
-    @AfterEach
-    public void tearDown() throws IOException {
-        if (daytimeTCPClient != null && daytimeTCPClient.isConnected()) {
-            daytimeTCPClient.disconnect();
-        }
-    }
-
     @Test
     public void constructDaytimeTcpClient() {
         final DaytimeTCPClient daytimeTCPClient = new DaytimeTCPClient();
@@ -97,5 +85,17 @@ class DaytimeTCPClientTest {
         assertEquals(expectedDaytimeString, time);
     }
 
+    @BeforeEach
+    public void setUp() throws UnknownHostException {
+        localHost = InetAddress.getLocalHost();
+    }
+
+    @AfterEach
+    public void tearDown() throws IOException {
+        if (daytimeTCPClient != null && daytimeTCPClient.isConnected()) {
+            daytimeTCPClient.disconnect();
+        }
+    }
+
 }
 
diff --git a/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java b/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java
index 4a8c6977..8dde69b3 100644
--- a/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java
+++ b/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java
@@ -84,16 +84,6 @@ public final class MockDaytimeTCPServer extends MockTcpServer {
         super(port, serverAddress);
     }
 
-    @Override
-    protected void processClientSocket(final Socket clientSocket) throws Exception {
-        try (final PrintWriter pw = new PrintWriter(clientSocket.getOutputStream())) {
-            final Clock nextClock = Objects.requireNonNull(responseQueue.poll(5, TimeUnit.SECONDS), "Could not obtain next clock for DaytimeTCPMockServer");
-            final ZonedDateTime dateTime = ZonedDateTime.now(nextClock);
-            pw.write(dateTime.format(DAYTIME_DATA_FORMAT));
-            pw.flush();
-        }
-    }
-
     /**
      * Queues clock that will be used in next accepted {@link Socket}
      * to return Daytime data, as defined in <a href="https://datatracker.ietf.org/doc/html/rfc867">RFC 867</a> spec
@@ -106,5 +96,15 @@ public final class MockDaytimeTCPServer extends MockTcpServer {
         return clock;
     }
 
+    @Override
+    protected void processClientSocket(final Socket clientSocket) throws Exception {
+        try (final PrintWriter pw = new PrintWriter(clientSocket.getOutputStream())) {
+            final Clock nextClock = Objects.requireNonNull(responseQueue.poll(5, TimeUnit.SECONDS), "Could not obtain next clock for DaytimeTCPMockServer");
+            final ZonedDateTime dateTime = ZonedDateTime.now(nextClock);
+            pw.write(dateTime.format(DAYTIME_DATA_FORMAT));
+            pw.flush();
+        }
+    }
+
 }
 


(commons-net) 02/03: Sort imports

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit 7e6f5230a3e6d7c04cc7d940616deea093273090
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Feb 24 11:46:48 2024 -0500

    Sort imports
---
 .../commons/net/daytime/DaytimeTCPClientTest.java    | 20 ++++++++++----------
 .../commons/net/daytime/MockDaytimeTCPServer.java    |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/test/java/org/apache/commons/net/daytime/DaytimeTCPClientTest.java b/src/test/java/org/apache/commons/net/daytime/DaytimeTCPClientTest.java
index d4d70aa8..986bdc2b 100644
--- a/src/test/java/org/apache/commons/net/daytime/DaytimeTCPClientTest.java
+++ b/src/test/java/org/apache/commons/net/daytime/DaytimeTCPClientTest.java
@@ -17,15 +17,7 @@
 
 package org.apache.commons.net.daytime;
 
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Timeout;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 import java.net.InetAddress;
@@ -36,7 +28,15 @@ import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.stream.Stream;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 class DaytimeTCPClientTest {
 
diff --git a/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java b/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java
index 8dde69b3..0dac4057 100644
--- a/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java
+++ b/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java
@@ -17,8 +17,6 @@
 
 package org.apache.commons.net.daytime;
 
-import org.apache.commons.net.MockTcpServer;
-
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.net.InetAddress;
@@ -32,6 +30,8 @@ import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.commons.net.MockTcpServer;
+
 /**
  * The MockDaytimeTCPServer class is a simple TCP implementation of a server for the Daytime Protocol described in <a href="https://datatracker.ietf.org/doc/html/rfc867">RFC 867</a>.
  * <p>


(commons-net) 03/03: Use final

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit 562df3146cff13de2c227b5eb4de350732a368a0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Feb 24 11:48:03 2024 -0500

    Use final
---
 .../java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java b/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java
index 0dac4057..19d0a31e 100644
--- a/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java
+++ b/src/test/java/org/apache/commons/net/daytime/MockDaytimeTCPServer.java
@@ -69,7 +69,7 @@ public final class MockDaytimeTCPServer extends MockTcpServer {
      * @param port the port number the server will bind to, or 0 to use a port number that is automatically allocated
      * @throws IOException if an I/O error occurs when opening the socket.
      */
-    public MockDaytimeTCPServer(int port) throws IOException {
+    public MockDaytimeTCPServer(final int port) throws IOException {
         super(port);
     }
 
@@ -80,7 +80,7 @@ public final class MockDaytimeTCPServer extends MockTcpServer {
      * @param serverAddress the InetAddress the server will bind to
      * @throws IOException if an I/O error occurs when opening the socket.
      */
-    public MockDaytimeTCPServer(int port, InetAddress serverAddress) throws IOException {
+    public MockDaytimeTCPServer(final int port, final InetAddress serverAddress) throws IOException {
         super(port, serverAddress);
     }