commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pascalschumac...@apache.org
Subject commons-io git commit: fix warnings in FileBasedTestCase
Date Tue, 15 Nov 2016 18:55:08 GMT
Repository: commons-io
Updated Branches:
  refs/heads/master 8fce0fa77 -> 933796e93


fix warnings in FileBasedTestCase

(side-effects: close #15, close #16)


Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/933796e9
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/933796e9
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/933796e9

Branch: refs/heads/master
Commit: 933796e9330ed5043ad8e76d9fa2cb8b1d3a8e3a
Parents: 8fce0fa
Author: pascalschumacher <pascalschumacher@gmx.net>
Authored: Tue Nov 15 19:54:55 2016 +0100
Committer: pascalschumacher <pascalschumacher@gmx.net>
Committed: Tue Nov 15 19:54:55 2016 +0100

----------------------------------------------------------------------
 .../apache/commons/io/FileSystemUtilsTestCase.java   | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/933796e9/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 9840cfb..5e279c8 100644
--- a/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java
@@ -34,6 +34,7 @@ public class FileSystemUtilsTestCase extends FileBasedTestCase {
 
     //-----------------------------------------------------------------------
     @Test
+    @SuppressWarnings("deprecation") // testing decrecated code
     public void testGetFreeSpace_String() throws Exception {
         // test coverage, as we can't check value
         if (File.separatorChar == '/') {
@@ -52,22 +53,16 @@ public class FileSystemUtilsTestCase extends FileBasedTestCase {
             }
             final Process proc = Runtime.getRuntime().exec(cmd);
             boolean kilobyteBlock = true;
-            BufferedReader r = null;
-            try {
-                r = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+            try (BufferedReader r = new BufferedReader(new InputStreamReader(proc.getInputStream()))){
                 final String line = r.readLine();
                 Assert.assertNotNull("Unexpected null line", line);
                 if (line.contains("512")) {
                     kilobyteBlock = false;
                 }
-            } finally {
-                IOUtils.closeQuietly(r);
             }
 
             // now perform the test
-            @SuppressWarnings("deprecation")
-            final
-            long free = FileSystemUtils.freeSpace("/");
+            final long free = FileSystemUtils.freeSpace("/");
             final long kb = FileSystemUtils.freeSpaceKb("/");
             if (kilobyteBlock) {
                 assertEquals(free, kb, 256d);
@@ -75,9 +70,7 @@ public class FileSystemUtilsTestCase extends FileBasedTestCase {
                 assertEquals(free / 2d, kb, 256d);
             }
         } else {
-            @SuppressWarnings("deprecation")
-            final
-            long bytes = FileSystemUtils.freeSpace("");
+            final long bytes = FileSystemUtils.freeSpace("");
             final long kb = FileSystemUtils.freeSpaceKb("");
             assertEquals((double) bytes / 1024, kb, 256d);
         }


Mime
View raw message