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 75da8c2d801721203b2065e61c33f4e9e14cdb1f Author: Gary Gregory <[email protected]> AuthorDate: Wed Jul 19 12:18:10 2023 -0400 Reuse FileUtils in tests --- src/test/java/org/apache/commons/net/tftp/TFTPServerMain.java | 4 +++- src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java | 3 ++- src/test/java/org/apache/commons/net/tftp/TFTPTest.java | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/apache/commons/net/tftp/TFTPServerMain.java b/src/test/java/org/apache/commons/net/tftp/TFTPServerMain.java index 027d2208..fa14d4dc 100644 --- a/src/test/java/org/apache/commons/net/tftp/TFTPServerMain.java +++ b/src/test/java/org/apache/commons/net/tftp/TFTPServerMain.java @@ -23,6 +23,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Random; +import org.apache.commons.io.FileUtils; + /** * Main class for TFTPServer. This allows CLI use of the server. * @@ -37,7 +39,7 @@ public class TFTPServerMain { int port = 6901; int argc; final Map<String, String> opts = new HashMap<>(); - opts.put("-p", System.getProperty("java.io.tmpdir")); + opts.put("-p", FileUtils.getTempDirectoryPath()); // Parse options for (argc = 0; argc < args.length; argc++) { final String arg = args[argc]; diff --git a/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java b/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java index cd39fd5b..f21c6ed0 100644 --- a/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java +++ b/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java @@ -25,6 +25,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import org.apache.commons.io.FileUtils; import org.apache.commons.net.tftp.TFTPServer.ServerMode; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -38,7 +39,7 @@ public class TFTPServerPathTest { private static final int SERVER_PORT = 6901; String filePrefix = "tftp-"; - File serverDirectory = new File(System.getProperty("java.io.tmpdir")); + File serverDirectory = FileUtils.getTempDirectory(); private File file; private File out; 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 c5e3f19a..36c17f80 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.IOException; import java.io.InputStream; import java.io.OutputStream; +import org.apache.commons.io.FileUtils; import org.apache.commons.net.tftp.TFTPServer.ServerMode; import junit.framework.TestCase; @@ -35,7 +36,7 @@ import junit.framework.TestCase; public class TFTPTest extends TestCase { private static final int SERVER_PORT = 6902; private static TFTPServer tftpS; - private static final File SERVER_DIR = new File(System.getProperty("java.io.tmpdir")); + private static final File SERVER_DIR = FileUtils.getTempDirectory(); private static final String FILE_PREFIX = "tftp-"; private static final File[] FILES = new File[8];
