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 <garydgreg...@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(); + } + } + }