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


The following commit(s) were added to refs/heads/master by this push:
     new 09a1cf2f Better tests
09a1cf2f is described below

commit 09a1cf2f13fedeb545af65d68e2c5bd7a8badbff
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Tue May 28 17:24:06 2024 -0400

    Better tests
---
 src/test/java/org/apache/commons/net/tftp/TFTPTest.java | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

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 fac02389..c1e45797 100644
--- a/src/test/java/org/apache/commons/net/tftp/TFTPTest.java
+++ b/src/test/java/org/apache/commons/net/tftp/TFTPTest.java
@@ -25,6 +25,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 
 import junit.framework.TestCase;
 
@@ -114,15 +115,20 @@ public class TFTPTest extends TestCase {
         }
     }
 
-    public void testDiscardPackets() {
+    public void testDiscardPackets() throws IOException {
         try (TFTP tftp = new TFTP()) {
             assertThrows(NullPointerException.class, tftp::discardPackets);
+            tftp.open();
+            tftp.discardPackets();
         }
     }
 
-    public void testSend() {
+    public void testSend() throws IOException {
         try (TFTP tftp = new TFTP()) {
-            assertThrows(NullPointerException.class, () -> tftp.send(new 
TFTPDataPacket(InetAddress.getLocalHost(), 0, 0, new byte[0])));
+            final TFTPDataPacket packet = new 
TFTPDataPacket(InetAddress.getLocalHost(), 0, 0, new byte[0]);
+            assertThrows(NullPointerException.class, () -> tftp.send(packet));
+            tftp.open();
+            tftp.send(packet);
         }
     }
 

Reply via email to