Skip to content

Commit

Permalink
Reuse FileUtils in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Jul 19, 2023
1 parent 17d4535 commit 75da8c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
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.
*
Expand All @@ -37,7 +39,7 @@ public static void main(final String[] args) throws Exception {
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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/apache/commons/net/tftp/TFTPTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand All @@ -35,7 +36,7 @@
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];

Expand Down

0 comments on commit 75da8c2

Please sign in to comment.