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/05/28 14:35:54 UTC

(commons-net) branch master updated (ff5bc6bc -> b8acc8b5)

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 ff5bc6bc Normalize test class visiblity
     new 50ce52b6 Remove obsolete comment
     new ca3a6ded Use Java style declaration
     new ebd83245 Javadoc
     new 84a96495 Add tests
     new f3cc1baa Whitespace
     new 3880fee7 Add tests
     new b8acc8b5 Add tests

The 7 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/chargen/CharGenTCPClient.java      |  5 ++++
 .../commons/net/chargen/CharGenUDPClient.java      |  6 ++++-
 .../commons/net/daytime/DaytimeUDPClient.java      | 25 ++++++++---------
 .../CharGenTCPClientTest.java}                     | 20 +++++++++-----
 .../CharGenUDPClientTest.java}                     | 31 +++++++++++++---------
 .../DaytimeUDPClientTest.java}                     | 30 ++++++++++++---------
 6 files changed, 71 insertions(+), 46 deletions(-)
 copy src/test/java/org/apache/commons/net/{echo/EchoTCPClientTest.java => chargen/CharGenTCPClientTest.java} (65%)
 copy src/test/java/org/apache/commons/net/{echo/EchoUDPClientTest.java => chargen/CharGenUDPClientTest.java} (60%)
 copy src/test/java/org/apache/commons/net/{echo/EchoUDPClientTest.java => daytime/DaytimeUDPClientTest.java} (65%)


(commons-net) 02/07: Use Java style declaration

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 ca3a6ded81dd7b4e5acf347b8111c4300c6a8d29
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 28 10:18:24 2024 -0400

    Use Java style declaration
---
 .../java/org/apache/commons/net/daytime/DaytimeUDPClient.java    | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java b/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
index 026e1cae..4de18f0a 100644
--- a/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
+++ b/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
@@ -60,15 +60,10 @@ public final class DaytimeUDPClient extends DatagramSocketClient {
      * @throws IOException If an error occurs while retrieving the time.
      */
     public String getTime(final InetAddress host, final int port) throws IOException {
-        final DatagramPacket sendPacket;
-        final DatagramPacket receivePacket;
-
-        sendPacket = new DatagramPacket(dummyData, dummyData.length, host, port);
-        receivePacket = new DatagramPacket(timeData, timeData.length);
-
+        final DatagramPacket sendPacket = new DatagramPacket(dummyData, dummyData.length, host, port);
+        final DatagramPacket receivePacket = new DatagramPacket(timeData, timeData.length);
         checkOpen().send(sendPacket);
         checkOpen().receive(receivePacket);
-
         return new String(receivePacket.getData(), 0, receivePacket.getLength(), getCharset());
     }
 


(commons-net) 03/07: Javadoc

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 ebd832459b9b50e42b72015f2fefb290f236051f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 28 10:20:33 2024 -0400

    Javadoc
    
    Whitespace
---
 .../org/apache/commons/net/daytime/DaytimeUDPClient.java   | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java b/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
index 4de18f0a..bbfd94ea 100644
--- a/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
+++ b/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
@@ -33,15 +33,21 @@ import org.apache.commons.net.DatagramSocketClient;
  * @see DaytimeTCPClient
  */
 public final class DaytimeUDPClient extends DatagramSocketClient {
-    /** The default daytime port. It is set to 13 according to RFC 867. */
+
+    /**
+     * The default daytime port. It is set to 13 according to RFC 867.
+     */
     public static final int DEFAULT_PORT = 13;
 
     private final byte[] dummyData = new byte[1];
-    // Received dates should be less than 256 bytes
+
+    /**
+     * Received dates should be less than 256 bytes.
+     */
     private final byte[] timeData = new byte[256];
 
     /**
-     * Same as <code>getTime(host, DaytimeUDPClient.DEFAULT_PORT);</code>
+     * Shorthand for <code>getTime(host, DaytimeUDPClient.DEFAULT_PORT);</code>
      *
      * @param host the host
      * @return the time
@@ -52,7 +58,7 @@ public final class DaytimeUDPClient extends DatagramSocketClient {
     }
 
     /**
-     * Retrieves the time string from the specified server and port and returns it.
+     * Gets the time string from the specified server and port and returns it.
      *
      * @param host The address of the server.
      * @param port The port of the service.


(commons-net) 06/07: Add tests

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 3880fee76c937d75c8a752ed6b212e33fe07a59d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 28 10:31:27 2024 -0400

    Add tests
---
 .../commons/net/chargen/CharGenTCPClientTest.java  | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/src/test/java/org/apache/commons/net/chargen/CharGenTCPClientTest.java b/src/test/java/org/apache/commons/net/chargen/CharGenTCPClientTest.java
new file mode 100644
index 00000000..faa9e0f8
--- /dev/null
+++ b/src/test/java/org/apache/commons/net/chargen/CharGenTCPClientTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.net.chargen;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link CharGenTCPClient}.
+ */
+public class CharGenTCPClientTest {
+
+    @Test
+    public void testConstructor() {
+        assertDoesNotThrow(CharGenTCPClient::new);
+    }
+
+    @Test
+    public void testDefaultPort() {
+        assertEquals(CharGenTCPClient.DEFAULT_PORT, new CharGenTCPClient().getDefaultPort());
+    }
+
+    @Test
+    public void testGetInputStream() throws IOException {
+        try (InputStream inputStream = new CharGenTCPClient().getInputStream()) {
+            assertNull(inputStream);
+        }
+    }
+
+}


(commons-net) 07/07: Add tests

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 b8acc8b54b96fd843b4a5d213b503ecd00735093
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 28 10:35:48 2024 -0400

    Add tests
    
    Whiteapace
---
 .../commons/net/chargen/CharGenUDPClient.java      |  6 ++-
 .../commons/net/chargen/CharGenUDPClientTest.java  | 54 ++++++++++++++++++++++
 2 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/net/chargen/CharGenUDPClient.java b/src/main/java/org/apache/commons/net/chargen/CharGenUDPClient.java
index 8253bcbb..5d1fce36 100644
--- a/src/main/java/org/apache/commons/net/chargen/CharGenUDPClient.java
+++ b/src/main/java/org/apache/commons/net/chargen/CharGenUDPClient.java
@@ -37,16 +37,20 @@ import org.apache.commons.net.util.NetConstants;
  *
  * @see CharGenTCPClient
  */
-
 public final class CharGenUDPClient extends DatagramSocketClient {
+
     /** The systat port value of 11 according to RFC 866. */
     public static final int SYSTAT_PORT = 11;
+
     /** The netstat port value of 19. */
     public static final int NETSTAT_PORT = 15;
+
     /** The quote of the day port value of 17 according to RFC 865. */
     public static final int QUOTE_OF_DAY_PORT = 17;
+
     /** The character generator port value of 19 according to RFC 864. */
     public static final int CHARGEN_PORT = 19;
+
     /** The default chargen port. It is set to 19 according to RFC 864. */
     public static final int DEFAULT_PORT = 19;
 
diff --git a/src/test/java/org/apache/commons/net/chargen/CharGenUDPClientTest.java b/src/test/java/org/apache/commons/net/chargen/CharGenUDPClientTest.java
new file mode 100644
index 00000000..a2fd4f31
--- /dev/null
+++ b/src/test/java/org/apache/commons/net/chargen/CharGenUDPClientTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.net.chargen;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.io.IOException;
+import java.net.InetAddress;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link CharGenUDPClient}.
+ */
+public class CharGenUDPClientTest {
+
+    @SuppressWarnings("resource")
+    @Test
+    public void testConstructor() {
+        assertDoesNotThrow(CharGenUDPClient::new);
+    }
+
+    @Test
+    public void testReceiver() throws IOException {
+        try (CharGenUDPClient client = new CharGenUDPClient()) {
+            assertThrows(NullPointerException.class, client::receive);
+        }
+    }
+
+    @Test
+    public void testSend() throws IOException {
+        try (CharGenUDPClient client = new CharGenUDPClient()) {
+            assertThrows(NullPointerException.class, () -> client.send(InetAddress.getLocalHost()));
+            assertThrows(NullPointerException.class, () -> client.send(InetAddress.getLocalHost(), CharGenUDPClient.DEFAULT_PORT));
+        }
+    }
+
+}


(commons-net) 04/07: Add tests

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 84a96495af7ca72611236755a80671d6817c582c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 28 10:25:51 2024 -0400

    Add tests
---
 .../commons/net/daytime/DaytimeUDPClientTest.java  | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/src/test/java/org/apache/commons/net/daytime/DaytimeUDPClientTest.java b/src/test/java/org/apache/commons/net/daytime/DaytimeUDPClientTest.java
new file mode 100644
index 00000000..8cfaa9f0
--- /dev/null
+++ b/src/test/java/org/apache/commons/net/daytime/DaytimeUDPClientTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.net.daytime;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.net.InetAddress;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link DaytimeUDPClient}.
+ */
+public class DaytimeUDPClientTest {
+
+    @SuppressWarnings("resource")
+    @Test
+    public void testConstructor() {
+        assertDoesNotThrow(DaytimeUDPClient::new);
+    }
+
+    @Test
+    public void testClose() {
+        try (DaytimeUDPClient client = new DaytimeUDPClient()) {
+            // empty
+        }
+    }
+
+    @Test
+    public void testGetTime() {
+        try (DaytimeUDPClient client = new DaytimeUDPClient()) {
+            // Not connected
+            assertThrows(NullPointerException.class, () -> client.getTime(InetAddress.getLocalHost()));
+            assertThrows(NullPointerException.class, () -> client.getTime(InetAddress.getLocalHost(), 0));
+        }
+    }
+}


(commons-net) 05/07: Whitespace

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 f3cc1baacbb8dbc3363863cd6f5757f8b8365d55
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 28 10:26:32 2024 -0400

    Whitespace
---
 src/main/java/org/apache/commons/net/chargen/CharGenTCPClient.java | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/main/java/org/apache/commons/net/chargen/CharGenTCPClient.java b/src/main/java/org/apache/commons/net/chargen/CharGenTCPClient.java
index 51129250..2f0a37f3 100644
--- a/src/main/java/org/apache/commons/net/chargen/CharGenTCPClient.java
+++ b/src/main/java/org/apache/commons/net/chargen/CharGenTCPClient.java
@@ -35,14 +35,19 @@ import org.apache.commons.net.SocketClient;
  */
 
 public final class CharGenTCPClient extends SocketClient {
+
     /** The systat port value of 11 according to RFC 866. */
     public static final int SYSTAT_PORT = 11;
+
     /** The netstat port value of 19. */
     public static final int NETSTAT_PORT = 15;
+
     /** The quote of the day port value of 17 according to RFC 865. */
     public static final int QUOTE_OF_DAY_PORT = 17;
+
     /** The character generator port value of 19 according to RFC 864. */
     public static final int CHARGEN_PORT = 19;
+
     /** The default chargen port. It is set to 19 according to RFC 864. */
     public static final int DEFAULT_PORT = 19;
 


(commons-net) 01/07: Remove obsolete comment

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 50ce52b6ed1455d18c1c3db4de1286e17168a576
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 28 10:17:34 2024 -0400

    Remove obsolete comment
---
 src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java b/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
index 84495441..026e1cae 100644
--- a/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
+++ b/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
@@ -69,7 +69,7 @@ public final class DaytimeUDPClient extends DatagramSocketClient {
         checkOpen().send(sendPacket);
         checkOpen().receive(receivePacket);
 
-        return new String(receivePacket.getData(), 0, receivePacket.getLength(), getCharset()); // Java 1.6 can use getCharset()
+        return new String(receivePacket.getData(), 0, receivePacket.getLength(), getCharset());
     }
 
 }