You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by st...@apache.org on 2017/09/27 21:57:09 UTC
[1/3] commons-io git commit: Avoid fine-sensitivity when testing
freeSpace
Repository: commons-io
Updated Branches:
refs/heads/master a43d2fa2f -> 958657f3c
Avoid fine-sensitivity when testing freeSpace
Instead of a fixed delta of 256 kB, assume disk space does not change by
more than 1% between calling freeSpacfe and the second call to
freeSpaceKb - e.g. 1 GB on a 100 GB drive. 1% is still small enough to
detect if the code accidentally changes from kibibytes (1024) to
kilobytes (1000)
Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/e460f4f9
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/e460f4f9
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/e460f4f9
Branch: refs/heads/master
Commit: e460f4f93817bea10b2fba8aaddeb892421d2668
Parents: 14b52eb
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed Sep 27 22:22:52 2017 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Sep 27 22:48:15 2017 +0100
----------------------------------------------------------------------
.../org/apache/commons/io/FileSystemUtilsTestCase.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-io/blob/e460f4f9/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java
index 96f0013..399c4ce 100644
--- a/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java
@@ -78,15 +78,22 @@ public class FileSystemUtilsTestCase {
// now perform the test
final long free = FileSystemUtils.freeSpace("/");
final long kb = FileSystemUtils.freeSpaceKb("/");
+ // Assume disk space does not fluctuate
+ // more than 1% between the above two calls;
+ // this also also small enough to verifiy freeSpaceKb uses
+ // kibibytes (1024) instead of SI kilobytes (1000)
+ double acceptableDelta = kb * 0.01d;
if (kilobyteBlock) {
- assertEquals(free, kb, 256d);
+ assertEquals(free, kb, acceptableDelta);
} else {
- assertEquals(free / 2d, kb, 256d);
+ assertEquals(free / 2d, kb, acceptableDelta);
}
} else {
final long bytes = FileSystemUtils.freeSpace("");
final long kb = FileSystemUtils.freeSpaceKb("");
- assertEquals((double) bytes / 1024, kb, 256d);
+ // Assume disk space does not fluctuate more than 1%
+ double acceptableDelta = kb * 0.01d;
+ assertEquals((double) bytes / 1024, kb, acceptableDelta);
}
}
[2/3] commons-io git commit: IO-506: javadoc that freeSpaceKb returns
kibibytes
Posted by st...@apache.org.
IO-506: javadoc that freeSpaceKb returns kibibytes
.. not pre-1998 kilobytes -- it was misleadingly named before.
Also fix @deprecated as it is not actually removed in 2.6, just deprecated
Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/3af25efa
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/3af25efa
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/3af25efa
Branch: refs/heads/master
Commit: 3af25efa4e252240caac206899f68bdaa20e14ed
Parents: e460f4f
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed Sep 27 22:49:09 2017 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Sep 27 22:51:38 2017 +0100
----------------------------------------------------------------------
.../org/apache/commons/io/FileSystemUtils.java | 22 +++++++++++---------
1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-io/blob/3af25efa/src/main/java/org/apache/commons/io/FileSystemUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/io/FileSystemUtils.java b/src/main/java/org/apache/commons/io/FileSystemUtils.java
index 861cc66..06e90c2 100644
--- a/src/main/java/org/apache/commons/io/FileSystemUtils.java
+++ b/src/main/java/org/apache/commons/io/FileSystemUtils.java
@@ -145,8 +145,8 @@ public class FileSystemUtils {
//-----------------------------------------------------------------------
/**
- * Returns the free space on a drive or volume in kilobytes by invoking
- * the command line.
+ * Returns the free space on a drive or volume in kibibytes (1024 bytes)
+ * by invoking the command line.
* <pre>
* FileSystemUtils.freeSpaceKb("C:"); // Windows
* FileSystemUtils.freeSpaceKb("/volume"); // *nix
@@ -167,15 +167,15 @@ public class FileSystemUtils {
* @throws IllegalStateException if an error occurred in initialisation
* @throws IOException if an error occurs when finding the free space
* @since 1.2, enhanced OS support in 1.3
- * @deprecated As of 2.6 removed without replacement. Please use {@link java.nio.file.FileStore#getUsableSpace()}.
+ * @deprecated As of 2.6 deprecated without replacement. Please use {@link java.nio.file.FileStore#getUsableSpace()}.
*/
@Deprecated
public static long freeSpaceKb(final String path) throws IOException {
return freeSpaceKb(path, -1);
}
/**
- * Returns the free space on a drive or volume in kilobytes by invoking
- * the command line.
+ * Returns the free space on a drive or volume in kibibytes (1024 bytes)
+ * by invoking the command line.
* <pre>
* FileSystemUtils.freeSpaceKb("C:"); // Windows
* FileSystemUtils.freeSpaceKb("/volume"); // *nix
@@ -198,7 +198,7 @@ public class FileSystemUtils {
* @throws IllegalStateException if an error occurred in initialisation
* @throws IOException if an error occurs when finding the free space
* @since 2.0
- * @deprecated As of 2.6 removed without replacement. Please use {@link java.nio.file.FileStore#getUsableSpace()}.
+ * @deprecated As of 2.6 deprecated without replacement. Please use {@link java.nio.file.FileStore#getUsableSpace()}.
*/
@Deprecated
public static long freeSpaceKb(final String path, final long timeout) throws IOException {
@@ -206,7 +206,8 @@ public class FileSystemUtils {
}
/**
- * Returns the disk size of the volume which holds the working directory.
+ * Returns the free space for the working directory
+ * in kibibytes (1024 bytes) by invoking the command line.
* <p>
* Identical to:
* <pre>
@@ -216,7 +217,7 @@ public class FileSystemUtils {
* @throws IllegalStateException if an error occurred in initialisation
* @throws IOException if an error occurs when finding the free space
* @since 2.0
- * @deprecated As of 2.6 removed without replacement. Please use {@link java.nio.file.FileStore#getUsableSpace()}.
+ * @deprecated As of 2.6 deprecated without replacement. Please use {@link java.nio.file.FileStore#getUsableSpace()}.
*/
@Deprecated
public static long freeSpaceKb() throws IOException {
@@ -224,7 +225,8 @@ public class FileSystemUtils {
}
/**
- * Returns the disk size of the volume which holds the working directory.
+ * Returns the free space for the working directory
+ * in kibibytes (1024 bytes) by invoking the command line.
* <p>
* Identical to:
* <pre>
@@ -236,7 +238,7 @@ public class FileSystemUtils {
* @throws IllegalStateException if an error occurred in initialisation
* @throws IOException if an error occurs when finding the free space
* @since 2.0
- * @deprecated As of 2.6 removed without replacement. Please use {@link java.nio.file.FileStore#getUsableSpace()}.
+ * @deprecated As of 2.6 deprecated without replacement. Please use {@link java.nio.file.FileStore#getUsableSpace()}.
*/
@Deprecated
public static long freeSpaceKb(final long timeout) throws IOException {
[3/3] commons-io git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/commons-io
Posted by st...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/commons-io
Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/958657f3
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/958657f3
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/958657f3
Branch: refs/heads/master
Commit: 958657f3c7cdf1f1d81a139b312c032020d582f0
Parents: 3af25ef a43d2fa
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed Sep 27 22:56:45 2017 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Sep 27 22:56:45 2017 +0100
----------------------------------------------------------------------
.../org/apache/commons/io/CopyUtilsTest.java | 11 -------
.../commons/io/FileDeleteStrategyTestCase.java | 7 -----
.../commons/io/FileSystemUtilsTestCase.java | 9 ------
.../io/FileUtilsCleanDirectoryTestCase.java | 32 +++-----------------
.../io/FileUtilsCleanSymlinksTestCase.java | 20 +++---------
.../io/FileUtilsDirectoryContainsTestCase.java | 25 +++++----------
.../commons/io/FileUtilsFileNewerTestCase.java | 30 +++++-------------
.../commons/io/FileUtilsListFilesTestCase.java | 27 +++--------------
.../apache/commons/io/FileUtilsTestCase.java | 30 ++++++------------
.../commons/io/FilenameUtilsTestCase.java | 16 ----------
.../org/apache/commons/io/IOCaseTestCase.java | 9 ------
.../apache/commons/io/IOUtilsCopyTestCase.java | 9 ------
.../org/apache/commons/io/IOUtilsTestCase.java | 21 +++----------
.../apache/commons/io/IOUtilsWriteTestCase.java | 10 ------
.../apache/commons/io/LineIteratorTestCase.java | 14 +++------
.../comparator/ComparatorAbstractTestCase.java | 14 ---------
.../io/filefilter/FileFilterTestCase.java | 12 --------
.../io/filefilter/RegexFileFilterTestCase.java | 23 ++------------
.../org/apache/commons/io/input/TailerTest.java | 3 --
.../io/monitor/AbstractMonitorTestCase.java | 6 ----
.../io/output/FileWriterWithEncodingTest.java | 9 ------
.../io/output/LockableFileWriterTest.java | 10 ------
22 files changed, 50 insertions(+), 297 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-io/blob/958657f3/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java
----------------------------------------------------------------------