You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/09/16 15:29:24 UTC
[commons-net] branch master updated (b77cc287 -> cd0aa017)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git
from b77cc287 Merge pull request #183 from apache/dependabot/github_actions/github/codeql-action-2.21.7
new 5e137c62 Partial patch: Bulletproof TFTPServerPathTest #173 from Jakub Kupczyk
new cd0aa017 Reuse FileUtils#contentEquals(File,File) in tests
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/commons/net/tftp/TFTPServer.java | 13 +++++++--
.../java/org/apache/commons/net/tftp/TFTPTest.java | 33 +++-------------------
2 files changed, 15 insertions(+), 31 deletions(-)
[commons-net] 02/02: Reuse FileUtils#contentEquals(File,File) in tests
Posted by gg...@apache.org.
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 cd0aa01783cc7c0459f24ac9139b952f144c110b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Sep 16 11:29:20 2023 -0400
Reuse FileUtils#contentEquals(File,File) in tests
---
.../java/org/apache/commons/net/tftp/TFTPTest.java | 33 +++-------------------
1 file changed, 4 insertions(+), 29 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 36c17f80..63f8f0a1 100644
--- a/src/test/java/org/apache/commons/net/tftp/TFTPTest.java
+++ b/src/test/java/org/apache/commons/net/tftp/TFTPTest.java
@@ -76,33 +76,8 @@ public class TFTPTest extends TestCase {
return file;
}
- private boolean filesIdentical(final File a, final File b) throws IOException {
- if (!a.exists() || !b.exists()) {
- return false;
- }
-
- if (a.length() != b.length()) {
- return false;
- }
-
- try (final InputStream fisA = new BufferedInputStream(new FileInputStream(a));
- final InputStream fisB = new BufferedInputStream(new FileInputStream(b))) {
-
- int aBit = fisA.read();
- int bBit = fisB.read();
-
- while (aBit != -1) {
- if (aBit != bBit) {
- fisA.close();
- fisB.close();
- return false;
- }
- aBit = fisA.read();
- bBit = fisB.read();
- }
-
- }
- return true;
+ private boolean contentEquals(final File a, final File b) throws IOException {
+ return FileUtils.contentEquals(a, b);
}
@Override
@@ -155,7 +130,7 @@ public class TFTPTest extends TestCase {
}
assertTrue("file not created", out.exists());
- assertTrue("FILES not identical on file " + file, filesIdentical(out, file));
+ assertTrue("FILES not identical on file " + file, contentEquals(out, file));
// delete the downloaded file
out.delete();
@@ -208,7 +183,7 @@ public class TFTPTest extends TestCase {
// close out its file buffers, etc.
Thread.sleep(100);
assertTrue("file not created", in.exists());
- assertTrue("FILES not identical on file " + file, filesIdentical(file, in));
+ assertTrue("FILES not identical on file " + file, contentEquals(file, in));
in.delete();
}
[commons-net] 01/02: Partial patch: Bulletproof TFTPServerPathTest #173 from Jakub Kupczyk
Posted by gg...@apache.org.
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 5e137c62d5110cc735b4e71f7cf679417765d980
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Sep 16 11:27:11 2023 -0400
Partial patch: Bulletproof TFTPServerPathTest #173 from Jakub Kupczyk
---
src/test/java/org/apache/commons/net/tftp/TFTPServer.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/test/java/org/apache/commons/net/tftp/TFTPServer.java b/src/test/java/org/apache/commons/net/tftp/TFTPServer.java
index c6fc2efe..ffd26d72 100644
--- a/src/test/java/org/apache/commons/net/tftp/TFTPServer.java
+++ b/src/test/java/org/apache/commons/net/tftp/TFTPServer.java
@@ -610,7 +610,7 @@ public class TFTPServer implements Runnable, AutoCloseable {
}
/**
- * Get the current value for maxTimeoutRetries
+ * Gets the current value for maxTimeoutRetries
*
* @return the max allowed number of retries
*/
@@ -619,7 +619,16 @@ public class TFTPServer implements Runnable, AutoCloseable {
}
/**
- * The current socket timeout used during transfers in milliseconds.
+ * Gets the server port number
+ *
+ * @return the server port number
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * Gets the current socket timeout used during transfers in milliseconds.
*
* @return the timeout value
*/