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 5e92a099 Add tests 5e92a099 is described below commit 5e92a099c569e4e262db9a1823bdaf2c22e606e7 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Tue May 28 09:31:00 2024 -0400 Add tests --- .../apache/commons/net/time/TimeUDPClientTest.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/org/apache/commons/net/time/TimeUDPClientTest.java b/src/test/java/org/apache/commons/net/time/TimeUDPClientTest.java index b41e8b47..2b40f520 100644 --- a/src/test/java/org/apache/commons/net/time/TimeUDPClientTest.java +++ b/src/test/java/org/apache/commons/net/time/TimeUDPClientTest.java @@ -18,6 +18,10 @@ package org.apache.commons.net.time; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.net.InetAddress; + import org.junit.jupiter.api.Test; /** @@ -32,6 +36,24 @@ public class TimeUDPClientTest { } } + @Test + public void testGetDate() { + try (TimeUDPClient client = new TimeUDPClient()) { + // Not connected failures + assertThrows(NullPointerException.class, () -> client.getDate(InetAddress.getLocalHost())); + assertThrows(NullPointerException.class, () -> client.getDate(InetAddress.getLocalHost(), TimeUDPClient.DEFAULT_PORT)); + } + } + + @Test + public void testGetTime() { + try (TimeUDPClient client = new TimeUDPClient()) { + // Not connected failures + assertThrows(NullPointerException.class, () -> client.getTime(InetAddress.getLocalHost())); + assertThrows(NullPointerException.class, () -> client.getTime(InetAddress.getLocalHost(), TimeUDPClient.DEFAULT_PORT)); + } + } + @Test public void testToTime() { final byte[] timeData = new byte[4];