1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.io; 18 19 import static org.junit.jupiter.api.Assertions.assertEquals; 20 import static org.junit.jupiter.api.Assertions.assertNotNull; 21 import static org.junit.jupiter.api.Assertions.assertThrows; 22 23 import java.io.BufferedReader; 24 import java.io.ByteArrayInputStream; 25 import java.io.File; 26 import java.io.IOException; 27 import java.io.InputStream; 28 import java.io.InputStreamReader; 29 import java.io.OutputStream; 30 import java.time.Duration; 31 import java.util.Locale; 32 33 import org.junit.jupiter.api.Test; 34 35 /** 36 * Tests {@link FileSystemUtils}. 37 */ 38 @SuppressWarnings("deprecation") // testing deprecated class 39 public class FileSystemUtilsTest { 40 41 static class MockFileSystemUtils extends FileSystemUtils { 42 private final int exitCode; 43 private final byte[] bytes; 44 private final String cmd; 45 MockFileSystemUtils(final int exitCode, final String lines)46 public MockFileSystemUtils(final int exitCode, final String lines) { 47 this(exitCode, lines, null); 48 } 49 MockFileSystemUtils(final int exitCode, final String lines, final String cmd)50 public MockFileSystemUtils(final int exitCode, final String lines, final String cmd) { 51 this.exitCode = exitCode; 52 this.bytes = lines.getBytes(); 53 this.cmd = cmd; 54 } 55 56 @Override openProcess(final String[] params)57 Process openProcess(final String[] params) { 58 if (cmd != null) { 59 assertEquals(cmd, params[params.length - 1]); 60 } 61 return new Process() { 62 @Override 63 public void destroy() { 64 } 65 66 @Override 67 public int exitValue() { 68 return exitCode; 69 } 70 71 @Override 72 public InputStream getErrorStream() { 73 return null; 74 } 75 76 @Override 77 public InputStream getInputStream() { 78 return new ByteArrayInputStream(bytes); 79 } 80 81 @Override 82 public OutputStream getOutputStream() { 83 return null; 84 } 85 86 @Override 87 public int waitFor() throws InterruptedException { 88 return exitCode; 89 } 90 }; 91 } 92 } 93 94 private static final Duration NEG_1_TIMEOUT = Duration.ofMillis(-1); 95 96 @Test 97 public void testGetFreeSpace_String() throws Exception { 98 // test coverage, as we can't check value 99 if (File.separatorChar == '/') { 100 // have to figure out Unix block size 101 final String[] cmd; 102 String osName = System.getProperty("os.name"); 103 osName = osName.toLowerCase(Locale.ENGLISH); 104 105 if (osName.contains("hp-ux") || osName.contains("aix")) { 106 cmd = new String[]{"df", "-P", "/"}; 107 } else if (osName.contains("sunos") || osName.contains("sun os") 108 || osName.contains("solaris")) { 109 cmd = new String[]{"/usr/xpg4/bin/df", "-P", "/"}; 110 } else { 111 cmd = new String[]{"df", "/"}; 112 } 113 final Process proc = Runtime.getRuntime().exec(cmd); 114 boolean kilobyteBlock = true; 115 try (BufferedReader r = new BufferedReader(new InputStreamReader(proc.getInputStream()))){ 116 final String line = r.readLine(); 117 assertNotNull(line, "Unexpected null line"); 118 if (line.contains("512")) { 119 kilobyteBlock = false; 120 } 121 } 122 123 // now perform the test 124 final long free = FileSystemUtils.freeSpace("/"); 125 final long kb = FileSystemUtils.freeSpaceKb("/"); 126 // Assume disk space does not fluctuate 127 // more than 1% between the above two calls; 128 // this is also small enough to verify freeSpaceKb uses 129 // kibibytes (1024) instead of SI kilobytes (1000) 130 final double acceptableDelta = kb * 0.01d; 131 if (kilobyteBlock) { 132 assertEquals(free, kb, acceptableDelta); 133 } else { 134 assertEquals(free / 2d, kb, acceptableDelta); 135 } 136 } else { 137 final long bytes = FileSystemUtils.freeSpace(""); 138 final long kb = FileSystemUtils.freeSpaceKb(""); 139 // Assume disk space does not fluctuate more than 1% 140 final double acceptableDelta = kb * 0.01d; 141 assertEquals((double) bytes / 1024, kb, acceptableDelta); 142 } 143 } 144 145 @Test 146 public void testGetFreeSpaceOS_String_InitError() throws Exception { 147 final FileSystemUtils fsu = new FileSystemUtils(); 148 assertThrows(IllegalStateException.class, () -> fsu.freeSpaceOS("", -1, false, NEG_1_TIMEOUT)); 149 assertThrows(IllegalStateException.class, () -> fsu.freeSpaceOS("", -1, true, NEG_1_TIMEOUT)); 150 } 151 152 @Test 153 public void testGetFreeSpaceOS_String_NullPath() throws Exception { 154 final FileSystemUtils fsu = new FileSystemUtils(); 155 assertThrows(NullPointerException.class, () -> fsu.freeSpaceOS(null, 1, false, NEG_1_TIMEOUT)); 156 assertThrows(NullPointerException.class, () -> fsu.freeSpaceOS(null, 1, true, NEG_1_TIMEOUT)); 157 } 158 159 @Test 160 public void testGetFreeSpaceOS_String_Other() throws Exception { 161 final FileSystemUtils fsu = new FileSystemUtils(); 162 assertThrows(IllegalStateException.class, () -> fsu.freeSpaceOS("", 0, false, NEG_1_TIMEOUT)); 163 assertThrows(NullPointerException.class, () -> fsu.freeSpaceOS(null, 1, true, NEG_1_TIMEOUT)); 164 assertThrows(IllegalStateException.class, () -> fsu.freeSpaceOS("", 0, true, NEG_1_TIMEOUT)); 165 } 166 167 @Test 168 public void testGetFreeSpaceOS_String_Unix() throws Exception { 169 final FileSystemUtils fsu = new FileSystemUtils() { 170 @Override 171 protected long freeSpaceUnix(final String path, final boolean kb, final boolean posix, final Duration timeout) throws IOException { 172 return kb ? 12345L : 54321; 173 } 174 }; 175 assertEquals(54321L, fsu.freeSpaceOS("", 2, false, NEG_1_TIMEOUT)); 176 assertEquals(12345L, fsu.freeSpaceOS("", 2, true, NEG_1_TIMEOUT)); 177 } 178 179 @Test 180 public void testGetFreeSpaceOS_String_Windows() throws Exception { 181 final FileSystemUtils fsu = new FileSystemUtils() { 182 @Override 183 protected long freeSpaceWindows(final String path, final Duration timeout) throws IOException { 184 return 12345L; 185 } 186 }; 187 assertEquals(12345L, fsu.freeSpaceOS("", 1, false, NEG_1_TIMEOUT)); 188 assertEquals(12345L / 1024, fsu.freeSpaceOS("", 1, true, NEG_1_TIMEOUT)); 189 } 190 191 @Test 192 public void testGetFreeSpaceUnix_String_EmptyPath() throws Exception { 193 final String lines = 194 "Filesystem 1K-blocks Used Available Use% Mounted on\n" + 195 "xxx:/home/users/s 14428928 12956424 1472504 90% /home/users/s"; 196 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 197 assertThrows(IllegalArgumentException.class, () -> fsu.freeSpaceUnix("", false, false, NEG_1_TIMEOUT)); 198 assertThrows(IllegalArgumentException.class, () -> fsu.freeSpaceUnix("", true, false, NEG_1_TIMEOUT)); 199 assertThrows(IllegalArgumentException.class, () -> fsu.freeSpaceUnix("", true, true, NEG_1_TIMEOUT)); 200 assertThrows(IllegalArgumentException.class, () -> fsu.freeSpaceUnix("", false, true, NEG_1_TIMEOUT)); 201 } 202 203 @Test 204 205 public void testGetFreeSpaceUnix_String_EmptyResponse() { 206 final String lines = ""; 207 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 208 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, false, NEG_1_TIMEOUT)); 209 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, false, NEG_1_TIMEOUT)); 210 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, true, NEG_1_TIMEOUT)); 211 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, true, NEG_1_TIMEOUT)); 212 } 213 214 @Test 215 public void testGetFreeSpaceUnix_String_InvalidResponse1() { 216 final String lines = 217 "Filesystem 1K-blocks Used Available Use% Mounted on\n" + 218 " 14428928 12956424 100"; 219 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 220 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, false, NEG_1_TIMEOUT)); 221 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, false, NEG_1_TIMEOUT)); 222 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, true, NEG_1_TIMEOUT)); 223 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, true, NEG_1_TIMEOUT)); 224 } 225 226 @Test 227 public void testGetFreeSpaceUnix_String_InvalidResponse2() { 228 final String lines = 229 "Filesystem 1K-blocks Used Available Use% Mounted on\n" + 230 "xxx:/home/users/s 14428928 12956424 nnnnnnn 90% /home/users/s"; 231 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 232 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, false, NEG_1_TIMEOUT)); 233 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, false, NEG_1_TIMEOUT)); 234 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, true, NEG_1_TIMEOUT)); 235 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, true, NEG_1_TIMEOUT)); 236 } 237 238 @Test 239 public void testGetFreeSpaceUnix_String_InvalidResponse3() { 240 final String lines = 241 "Filesystem 1K-blocks Used Available Use% Mounted on\n" + 242 "xxx:/home/users/s 14428928 12956424 -1 90% /home/users/s"; 243 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 244 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, false, NEG_1_TIMEOUT)); 245 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, false, NEG_1_TIMEOUT)); 246 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, true, NEG_1_TIMEOUT)); 247 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, true, NEG_1_TIMEOUT)); 248 } 249 250 @Test 251 public void testGetFreeSpaceUnix_String_InvalidResponse4() { 252 final String lines = 253 "Filesystem 1K-blocks Used Available Use% Mounted on\n" + 254 "xxx-yyyyyyy-zzz:/home/users/s"; 255 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 256 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, false, NEG_1_TIMEOUT)); 257 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, false, NEG_1_TIMEOUT)); 258 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", false, true, NEG_1_TIMEOUT)); 259 assertThrows(IOException.class, () -> fsu.freeSpaceUnix("/home/users/s", true, true, NEG_1_TIMEOUT)); 260 } 261 262 @Test 263 public void testGetFreeSpaceUnix_String_LongResponse() throws Exception { 264 final String lines = 265 "Filesystem 1K-blocks Used Available Use% Mounted on\n" + 266 "xxx-yyyyyyy-zzz:/home/users/s\n" + 267 " 14428928 12956424 1472504 90% /home/users/s"; 268 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 269 assertEquals(1472504L, fsu.freeSpaceUnix("/home/users/s", false, false, NEG_1_TIMEOUT)); 270 } 271 272 @Test 273 public void testGetFreeSpaceUnix_String_LongResponseKb() throws Exception { 274 final String lines = 275 "Filesystem 1K-blocks Used Available Use% Mounted on\n" + 276 "xxx-yyyyyyy-zzz:/home/users/s\n" + 277 " 14428928 12956424 1472504 90% /home/users/s"; 278 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 279 assertEquals(1472504L, fsu.freeSpaceUnix("/home/users/s", true, false, NEG_1_TIMEOUT)); 280 } 281 282 @Test 283 public void testGetFreeSpaceUnix_String_NormalResponseFreeBSD() throws Exception { 284 // from Apache 'FreeBSD 6.1-RELEASE (SMP-turbo)' 285 final String lines = 286 "Filesystem 1K-blocks Used Avail Capacity Mounted on\n" + 287 "/dev/xxxxxx 128990 102902 15770 87% /"; 288 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 289 assertEquals(15770L, fsu.freeSpaceUnix("/", false, false, NEG_1_TIMEOUT)); 290 } 291 292 @Test 293 public void testGetFreeSpaceUnix_String_NormalResponseKbFreeBSD() throws Exception { 294 // from Apache 'FreeBSD 6.1-RELEASE (SMP-turbo)' 295 // df and df -k are identical, but df -kP uses 512 blocks (not relevant as not used) 296 final String lines = 297 "Filesystem 1K-blocks Used Avail Capacity Mounted on\n" + 298 "/dev/xxxxxx 128990 102902 15770 87% /"; 299 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 300 assertEquals(15770L, fsu.freeSpaceUnix("/", true, false, NEG_1_TIMEOUT)); 301 } 302 303 @Test 304 public void testGetFreeSpaceUnix_String_NormalResponseKbLinux() throws Exception { 305 // from Sourceforge 'GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)' 306 // df, df -k and df -kP are all identical 307 final String lines = 308 "Filesystem 1K-blocks Used Available Use% Mounted on\n" + 309 "/dev/xxx 497944 308528 189416 62% /"; 310 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 311 assertEquals(189416L, fsu.freeSpaceUnix("/", true, false, NEG_1_TIMEOUT)); 312 } 313 314 @Test 315 public void testGetFreeSpaceUnix_String_NormalResponseKbSolaris() throws Exception { 316 // from IO-91 - ' SunOS et 5.10 Generic_118822-25 sun4u sparc SUNW,Ultra-4' 317 // non-kb response does not contain free space - see IO-91 318 final String lines = 319 "Filesystem kbytes used avail capacity Mounted on\n" + 320 "/dev/dsk/x0x0x0x0 1350955 815754 481163 63%"; 321 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 322 assertEquals(481163L, fsu.freeSpaceUnix("/dev/dsk/x0x0x0x0", true, false, NEG_1_TIMEOUT)); 323 } 324 325 @Test 326 public void testGetFreeSpaceUnix_String_NormalResponseLinux() throws Exception { 327 // from Sourceforge 'GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)' 328 final String lines = 329 "Filesystem 1K-blocks Used Available Use% Mounted on\n" + 330 "/dev/xxx 497944 308528 189416 62% /"; 331 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 332 assertEquals(189416L, fsu.freeSpaceUnix("/", false, false, NEG_1_TIMEOUT)); 333 } 334 335 @Test 336 public void testGetFreeSpaceWindows_String_EmptyMultiLineResponse() { 337 final String lines = "\n\n"; 338 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 339 assertThrows(IOException.class, () -> fsu.freeSpaceWindows("C:", NEG_1_TIMEOUT)); 340 } 341 342 @Test 343 public void testGetFreeSpaceWindows_String_EmptyPath() throws Exception { 344 final String lines = 345 " Volume in drive C is HDD\n" + 346 " Volume Serial Number is XXXX-YYYY\n" + 347 "\n" + 348 " Directory of C:\\Documents and Settings\\Xxxx\n" + 349 "\n" + 350 "19/08/2005 22:43 <DIR> .\n" + 351 "19/08/2005 22:43 <DIR> ..\n" + 352 "11/08/2005 01:07 81 build.properties\n" + 353 "17/08/2005 21:44 <DIR> Desktop\n" + 354 " 7 File(s) 180260 bytes\n" + 355 " 10 Dir(s) 41411551232 bytes free"; 356 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c "); 357 assertEquals(41411551232L, fsu.freeSpaceWindows("", NEG_1_TIMEOUT)); 358 } 359 360 @Test 361 public void testGetFreeSpaceWindows_String_EmptyResponse() { 362 final String lines = ""; 363 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 364 assertThrows(IOException.class, () -> fsu.freeSpaceWindows("C:", NEG_1_TIMEOUT)); 365 } 366 367 @Test 368 public void testGetFreeSpaceWindows_String_InvalidTextResponse() { 369 final String lines = "BlueScreenOfDeath"; 370 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 371 assertThrows(IOException.class, () -> fsu.freeSpaceWindows("C:", NEG_1_TIMEOUT)); 372 } 373 374 @Test 375 public void testGetFreeSpaceWindows_String_NormalResponse() throws Exception { 376 final String lines = 377 " Volume in drive C is HDD\n" + 378 " Volume Serial Number is XXXX-YYYY\n" + 379 "\n" + 380 " Directory of C:\\Documents and Settings\\Xxxx\n" + 381 "\n" + 382 "19/08/2005 22:43 <DIR> .\n" + 383 "19/08/2005 22:43 <DIR> ..\n" + 384 "11/08/2005 01:07 81 build.properties\n" + 385 "17/08/2005 21:44 <DIR> Desktop\n" + 386 " 7 File(s) 180260 bytes\n" + 387 " 10 Dir(s) 41411551232 bytes free"; 388 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\""); 389 assertEquals(41411551232L, fsu.freeSpaceWindows("C:", NEG_1_TIMEOUT)); 390 } 391 @Test 392 public void testGetFreeSpaceWindows_String_NoSuchDirectoryResponse() { 393 final String lines = 394 " Volume in drive C is HDD\n" + 395 " Volume Serial Number is XXXX-YYYY\n" + 396 "\n" + 397 " Directory of C:\\Documents and Settings\\empty" + 398 "\n"; 399 final FileSystemUtils fsu = new MockFileSystemUtils(1, lines); 400 assertThrows(IOException.class, () -> fsu.freeSpaceWindows("C:", NEG_1_TIMEOUT)); 401 } 402 403 @Test 404 public void testGetFreeSpaceWindows_String_ParseCommaFormatBytes() throws Exception { 405 // this is the format of response when calling dir /c 406 // we have now switched to dir /-c, so we should never get this 407 final String lines = 408 " Volume in drive C is HDD\n" + 409 " Volume Serial Number is XXXX-YYYY\n" + 410 "\n" + 411 " Directory of C:\\Documents and Settings\\Xxxx\n" + 412 "\n" + 413 "19/08/2005 22:43 <DIR> .\n" + 414 "19/08/2005 22:43 <DIR> ..\n" + 415 "11/08/2005 01:07 81 build.properties\n" + 416 "17/08/2005 21:44 <DIR> Desktop\n" + 417 " 7 File(s) 180,260 bytes\n" + 418 " 10 Dir(s) 41,411,551,232 bytes free"; 419 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 420 assertEquals(41411551232L, fsu.freeSpaceWindows("", NEG_1_TIMEOUT)); 421 } 422 423 @Test 424 public void testGetFreeSpaceWindows_String_ParseCommaFormatBytes_Big() throws Exception { 425 // test with very large free space 426 final String lines = 427 " Volume in drive C is HDD\n" + 428 " Volume Serial Number is XXXX-YYYY\n" + 429 "\n" + 430 " Directory of C:\\Documents and Settings\\Xxxx\n" + 431 "\n" + 432 "19/08/2005 22:43 <DIR> .\n" + 433 "19/08/2005 22:43 <DIR> ..\n" + 434 "11/08/2005 01:07 81 build.properties\n" + 435 "17/08/2005 21:44 <DIR> Desktop\n" + 436 " 7 File(s) 180,260 bytes\n" + 437 " 10 Dir(s) 141,411,551,232 bytes free"; 438 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 439 assertEquals(141411551232L, fsu.freeSpaceWindows("", NEG_1_TIMEOUT)); 440 } 441 442 @Test 443 public void testGetFreeSpaceWindows_String_ParseCommaFormatBytes_Small() throws Exception { 444 // test with very large free space 445 final String lines = 446 " Volume in drive C is HDD\n" + 447 " Volume Serial Number is XXXX-YYYY\n" + 448 "\n" + 449 " Directory of C:\\Documents and Settings\\Xxxx\n" + 450 "\n" + 451 "19/08/2005 22:43 <DIR> .\n" + 452 "19/08/2005 22:43 <DIR> ..\n" + 453 "11/08/2005 01:07 81 build.properties\n" + 454 "17/08/2005 21:44 <DIR> Desktop\n" + 455 " 7 File(s) 180,260 bytes\n" + 456 " 10 Dir(s) 1,232 bytes free"; 457 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); 458 assertEquals(1232L, fsu.freeSpaceWindows("", NEG_1_TIMEOUT)); 459 } 460 461 @Test 462 public void testGetFreeSpaceWindows_String_quoted() throws Exception { 463 final String lines = 464 " Volume in drive C is HDD\n" + 465 " Volume Serial Number is XXXX-YYYY\n" + 466 "\n" + 467 " Directory of C:\\Documents and Settings\\Xxxx\n" + 468 "\n" + 469 "19/08/2005 22:43 <DIR> .\n" + 470 "19/08/2005 22:43 <DIR> ..\n" + 471 "11/08/2005 01:07 81 build.properties\n" + 472 "17/08/2005 21:44 <DIR> Desktop\n" + 473 " 7 File(s) 180260 bytes\n" + 474 " 10 Dir(s) 41411551232 bytes free"; 475 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\\somedir\""); 476 assertEquals(41411551232L, fsu.freeSpaceWindows("\"C:\\somedir\"", NEG_1_TIMEOUT)); 477 } 478 479 @Test 480 public void testGetFreeSpaceWindows_String_StripDrive() throws Exception { 481 final String lines = 482 " Volume in drive C is HDD\n" + 483 " Volume Serial Number is XXXX-YYYY\n" + 484 "\n" + 485 " Directory of C:\\Documents and Settings\\Xxxx\n" + 486 "\n" + 487 "19/08/2005 22:43 <DIR> .\n" + 488 "19/08/2005 22:43 <DIR> ..\n" + 489 "11/08/2005 01:07 81 build.properties\n" + 490 "17/08/2005 21:44 <DIR> Desktop\n" + 491 " 7 File(s) 180260 bytes\n" + 492 " 10 Dir(s) 41411551232 bytes free"; 493 final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\\somedir\""); 494 assertEquals(41411551232L, fsu.freeSpaceWindows("C:\\somedir", NEG_1_TIMEOUT)); 495 } 496 497 } 498