@@ -34,6 +34,7 @@ public class FileSystemUtilsTestCase extends FileBasedTestCase {
3434
3535 //-----------------------------------------------------------------------
3636 @ Test
37+ @ SuppressWarnings ("deprecation" ) // testing decrecated code
3738 public void testGetFreeSpace_String () throws Exception {
3839 // test coverage, as we can't check value
3940 if (File .separatorChar == '/' ) {
@@ -52,32 +53,24 @@ public void testGetFreeSpace_String() throws Exception {
5253 }
5354 final Process proc = Runtime .getRuntime ().exec (cmd );
5455 boolean kilobyteBlock = true ;
55- BufferedReader r = null ;
56- try {
57- r = new BufferedReader (new InputStreamReader (proc .getInputStream ()));
56+ try (BufferedReader r = new BufferedReader (new InputStreamReader (proc .getInputStream ()))){
5857 final String line = r .readLine ();
5958 Assert .assertNotNull ("Unexpected null line" , line );
6059 if (line .contains ("512" )) {
6160 kilobyteBlock = false ;
6261 }
63- } finally {
64- IOUtils .closeQuietly (r );
6562 }
6663
6764 // now perform the test
68- @ SuppressWarnings ("deprecation" )
69- final
70- long free = FileSystemUtils .freeSpace ("/" );
65+ final long free = FileSystemUtils .freeSpace ("/" );
7166 final long kb = FileSystemUtils .freeSpaceKb ("/" );
7267 if (kilobyteBlock ) {
7368 assertEquals (free , kb , 256d );
7469 } else {
7570 assertEquals (free / 2d , kb , 256d );
7671 }
7772 } else {
78- @ SuppressWarnings ("deprecation" )
79- final
80- long bytes = FileSystemUtils .freeSpace ("" );
73+ final long bytes = FileSystemUtils .freeSpace ("" );
8174 final long kb = FileSystemUtils .freeSpaceKb ("" );
8275 assertEquals ((double ) bytes / 1024 , kb , 256d );
8376 }
0 commit comments