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 561b0f39f58a3994885e58c358b05370969a6c4e
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Tue May 28 17:16:42 2024 -0400

    Add tests
---
 .../java/org/apache/commons/net/tftp/TFTPTest.java | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/commons/net/tftp/TFTPTest.java 
b/src/test/java/org/apache/commons/net/tftp/TFTPTest.java
index 36a6e2e6..245b8517 100644
--- a/src/test/java/org/apache/commons/net/tftp/TFTPTest.java
+++ b/src/test/java/org/apache/commons/net/tftp/TFTPTest.java
@@ -16,12 +16,15 @@
  */
 package org.apache.commons.net.tftp;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.net.InetAddress;
 
 import junit.framework.TestCase;
 
@@ -38,7 +41,7 @@ public class TFTPTest extends TestCase {
     private static final String FILE_PREFIX = "tftp-";
     private static final File[] FILES = new File[8];
 
-    static int testsLeftToRun = 6;
+    static int testsLeftToRun = 9; // TODO Nasty hack.
 
     // only want to do this once...
     static {
@@ -111,6 +114,18 @@ public class TFTPTest extends TestCase {
         }
     }
 
+    public void testDiscardPackets() {
+        try (TFTP tftp = new TFTP()) {
+            assertThrows(NullPointerException.class, tftp::discardPackets);
+        }
+    }
+
+    public void testSend() {
+        try (TFTP tftp = new TFTP()) {
+            assertThrows(NullPointerException.class, () -> tftp.send(new 
TFTPDataPacket(InetAddress.getLocalHost(), 0, 0, new byte[0])));
+        }
+    }
+
     private void testDownload(final int mode, final File file) throws 
IOException {
         // Create our TFTP instance to handle the file transfer.
         try (TFTPClient tftp = new TFTPClient()) {
@@ -134,6 +149,11 @@ public class TFTPTest extends TestCase {
             out.delete();
         }
     }
+    
+    public void testGetModeName() {
+        assertNotNull(TFTP.getModeName(0));
+        assertNotNull(TFTP.getModeName(1));
+    }
 
     public void testHugeDownloads() throws Exception {
         // test with the smaller FILES

Reply via email to