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

Reply via email to