@@ -97,59 +97,59 @@ public void testGetFreeSpace_String() throws Exception {
9797 public void testGetFreeSpaceOS_String_NullPath () throws Exception {
9898 FileSystemUtils fsu = new FileSystemUtils ();
9999 try {
100- fsu .freeSpaceOS (null , 1 , false );
100+ fsu .freeSpaceOS (null , 1 , false , - 1 );
101101 fail ();
102102 } catch (IllegalArgumentException ex ) {}
103103 try {
104- fsu .freeSpaceOS (null , 1 , true );
104+ fsu .freeSpaceOS (null , 1 , true , - 1 );
105105 fail ();
106106 } catch (IllegalArgumentException ex ) {}
107107 }
108108
109109 public void testGetFreeSpaceOS_String_InitError () throws Exception {
110110 FileSystemUtils fsu = new FileSystemUtils ();
111111 try {
112- fsu .freeSpaceOS ("" , -1 , false );
112+ fsu .freeSpaceOS ("" , -1 , false , - 1 );
113113 fail ();
114114 } catch (IllegalStateException ex ) {}
115115 try {
116- fsu .freeSpaceOS ("" , -1 , true );
116+ fsu .freeSpaceOS ("" , -1 , true , - 1 );
117117 fail ();
118118 } catch (IllegalStateException ex ) {}
119119 }
120120
121121 public void testGetFreeSpaceOS_String_Other () throws Exception {
122122 FileSystemUtils fsu = new FileSystemUtils ();
123123 try {
124- fsu .freeSpaceOS ("" , 0 , false );
124+ fsu .freeSpaceOS ("" , 0 , false , - 1 );
125125 fail ();
126126 } catch (IllegalStateException ex ) {}
127127 try {
128- fsu .freeSpaceOS ("" , 0 , true );
128+ fsu .freeSpaceOS ("" , 0 , true , - 1 );
129129 fail ();
130130 } catch (IllegalStateException ex ) {}
131131 }
132132
133133 public void testGetFreeSpaceOS_String_Windows () throws Exception {
134134 FileSystemUtils fsu = new FileSystemUtils () {
135135 @ Override
136- protected long freeSpaceWindows (String path ) throws IOException {
136+ protected long freeSpaceWindows (String path , long timeout ) throws IOException {
137137 return 12345L ;
138138 }
139139 };
140- assertEquals (12345L , fsu .freeSpaceOS ("" , 1 , false ));
141- assertEquals (12345L / 1024 , fsu .freeSpaceOS ("" , 1 , true ));
140+ assertEquals (12345L , fsu .freeSpaceOS ("" , 1 , false , - 1 ));
141+ assertEquals (12345L / 1024 , fsu .freeSpaceOS ("" , 1 , true , - 1 ));
142142 }
143143
144144 public void testGetFreeSpaceOS_String_Unix () throws Exception {
145145 FileSystemUtils fsu = new FileSystemUtils () {
146146 @ Override
147- protected long freeSpaceUnix (String path , boolean kb , boolean posix ) throws IOException {
147+ protected long freeSpaceUnix (String path , boolean kb , boolean posix , long timeout ) throws IOException {
148148 return (kb ? 12345L : 54321 );
149149 }
150150 };
151- assertEquals (54321L , fsu .freeSpaceOS ("" , 2 , false ));
152- assertEquals (12345L , fsu .freeSpaceOS ("" , 2 , true ));
151+ assertEquals (54321L , fsu .freeSpaceOS ("" , 2 , false , - 1 ));
152+ assertEquals (12345L , fsu .freeSpaceOS ("" , 2 , true , - 1 ));
153153 }
154154
155155 //-----------------------------------------------------------------------
@@ -169,7 +169,7 @@ public void testGetFreeSpaceWindows_String_ParseCommaFormatBytes() throws Except
169169 " 7 File(s) 180,260 bytes\n " +
170170 " 10 Dir(s) 41,411,551,232 bytes free" ;
171171 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
172- assertEquals (41411551232L , fsu .freeSpaceWindows ("" ));
172+ assertEquals (41411551232L , fsu .freeSpaceWindows ("" , - 1 ));
173173 }
174174
175175 //-----------------------------------------------------------------------
@@ -187,7 +187,7 @@ public void testGetFreeSpaceWindows_String_EmptyPath() throws Exception {
187187 " 7 File(s) 180260 bytes\n " +
188188 " 10 Dir(s) 41411551232 bytes free" ;
189189 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines , "dir /-c " );
190- assertEquals (41411551232L , fsu .freeSpaceWindows ("" ));
190+ assertEquals (41411551232L , fsu .freeSpaceWindows ("" , - 1 ));
191191 }
192192
193193 public void testGetFreeSpaceWindows_String_NormalResponse () throws Exception {
@@ -204,7 +204,7 @@ public void testGetFreeSpaceWindows_String_NormalResponse() throws Exception {
204204 " 7 File(s) 180260 bytes\n " +
205205 " 10 Dir(s) 41411551232 bytes free" ;
206206 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines , "dir /-c C:" );
207- assertEquals (41411551232L , fsu .freeSpaceWindows ("C:" ));
207+ assertEquals (41411551232L , fsu .freeSpaceWindows ("C:" , - 1 ));
208208 }
209209
210210 public void testGetFreeSpaceWindows_String_StripDrive () throws Exception {
@@ -221,14 +221,14 @@ public void testGetFreeSpaceWindows_String_StripDrive() throws Exception {
221221 " 7 File(s) 180260 bytes\n " +
222222 " 10 Dir(s) 41411551232 bytes free" ;
223223 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines , "dir /-c C:" );
224- assertEquals (41411551232L , fsu .freeSpaceWindows ("C:\\ somedir" ));
224+ assertEquals (41411551232L , fsu .freeSpaceWindows ("C:\\ somedir" , - 1 ));
225225 }
226226
227227 public void testGetFreeSpaceWindows_String_EmptyResponse () throws Exception {
228228 String lines = "" ;
229229 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
230230 try {
231- fsu .freeSpaceWindows ("C:" );
231+ fsu .freeSpaceWindows ("C:" , - 1 );
232232 fail ();
233233 } catch (IOException ex ) {}
234234 }
@@ -237,7 +237,7 @@ public void testGetFreeSpaceWindows_String_EmptyMultiLineResponse() throws Excep
237237 String lines = "\n \n " ;
238238 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
239239 try {
240- fsu .freeSpaceWindows ("C:" );
240+ fsu .freeSpaceWindows ("C:" , - 1 );
241241 fail ();
242242 } catch (IOException ex ) {}
243243 }
@@ -246,7 +246,7 @@ public void testGetFreeSpaceWindows_String_InvalidTextResponse() throws Exceptio
246246 String lines = "BlueScreenOfDeath" ;
247247 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
248248 try {
249- fsu .freeSpaceWindows ("C:" );
249+ fsu .freeSpaceWindows ("C:" , - 1 );
250250 fail ();
251251 } catch (IOException ex ) {}
252252 }
@@ -260,7 +260,7 @@ public void testGetFreeSpaceWindows_String_NoSuchDirectoryResponse() throws Exce
260260 "\n " ;
261261 FileSystemUtils fsu = new MockFileSystemUtils (1 , lines );
262262 try {
263- fsu .freeSpaceWindows ("C:" );
263+ fsu .freeSpaceWindows ("C:" , - 1 );
264264 fail ();
265265 } catch (IOException ex ) {}
266266 }
@@ -272,19 +272,19 @@ public void testGetFreeSpaceUnix_String_EmptyPath() throws Exception {
272272 "xxx:/home/users/s 14428928 12956424 1472504 90% /home/users/s" ;
273273 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
274274 try {
275- fsu .freeSpaceUnix ("" , false , false );
275+ fsu .freeSpaceUnix ("" , false , false , - 1 );
276276 fail ();
277277 } catch (IllegalArgumentException ex ) {}
278278 try {
279- fsu .freeSpaceUnix ("" , true , false );
279+ fsu .freeSpaceUnix ("" , true , false , - 1 );
280280 fail ();
281281 } catch (IllegalArgumentException ex ) {}
282282 try {
283- fsu .freeSpaceUnix ("" , true , true );
283+ fsu .freeSpaceUnix ("" , true , true , - 1 );
284284 fail ();
285285 } catch (IllegalArgumentException ex ) {}
286286 try {
287- fsu .freeSpaceUnix ("" , false , true );
287+ fsu .freeSpaceUnix ("" , false , true , - 1 );
288288 fail ();
289289 } catch (IllegalArgumentException ex ) {}
290290
@@ -296,7 +296,7 @@ public void testGetFreeSpaceUnix_String_NormalResponseLinux() throws Exception {
296296 "Filesystem 1K-blocks Used Available Use% Mounted on\n " +
297297 "/dev/xxx 497944 308528 189416 62% /" ;
298298 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
299- assertEquals (189416L , fsu .freeSpaceUnix ("/" , false , false ));
299+ assertEquals (189416L , fsu .freeSpaceUnix ("/" , false , false , - 1 ));
300300 }
301301
302302 public void testGetFreeSpaceUnix_String_NormalResponseFreeBSD () throws Exception {
@@ -305,7 +305,7 @@ public void testGetFreeSpaceUnix_String_NormalResponseFreeBSD() throws Exception
305305 "Filesystem 1K-blocks Used Avail Capacity Mounted on\n " +
306306 "/dev/xxxxxx 128990 102902 15770 87% /" ;
307307 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
308- assertEquals (15770L , fsu .freeSpaceUnix ("/" , false , false ));
308+ assertEquals (15770L , fsu .freeSpaceUnix ("/" , false , false , - 1 ));
309309 }
310310
311311 //-----------------------------------------------------------------------
@@ -316,7 +316,7 @@ public void testGetFreeSpaceUnix_String_NormalResponseKbLinux() throws Exception
316316 "Filesystem 1K-blocks Used Available Use% Mounted on\n " +
317317 "/dev/xxx 497944 308528 189416 62% /" ;
318318 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
319- assertEquals (189416L , fsu .freeSpaceUnix ("/" , true , false ));
319+ assertEquals (189416L , fsu .freeSpaceUnix ("/" , true , false , - 1 ));
320320 }
321321
322322 public void testGetFreeSpaceUnix_String_NormalResponseKbFreeBSD () throws Exception {
@@ -326,7 +326,7 @@ public void testGetFreeSpaceUnix_String_NormalResponseKbFreeBSD() throws Excepti
326326 "Filesystem 1K-blocks Used Avail Capacity Mounted on\n " +
327327 "/dev/xxxxxx 128990 102902 15770 87% /" ;
328328 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
329- assertEquals (15770L , fsu .freeSpaceUnix ("/" , true , false ));
329+ assertEquals (15770L , fsu .freeSpaceUnix ("/" , true , false , - 1 ));
330330 }
331331
332332 public void testGetFreeSpaceUnix_String_NormalResponseKbSolaris () throws Exception {
@@ -336,7 +336,7 @@ public void testGetFreeSpaceUnix_String_NormalResponseKbSolaris() throws Excepti
336336 "Filesystem kbytes used avail capacity Mounted on\n " +
337337 "/dev/dsk/x0x0x0x0 1350955 815754 481163 63%" ;
338338 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
339- assertEquals (481163L , fsu .freeSpaceUnix ("/dev/dsk/x0x0x0x0" , true , false ));
339+ assertEquals (481163L , fsu .freeSpaceUnix ("/dev/dsk/x0x0x0x0" , true , false , - 1 ));
340340 }
341341
342342 public void testGetFreeSpaceUnix_String_LongResponse () throws Exception {
@@ -345,7 +345,7 @@ public void testGetFreeSpaceUnix_String_LongResponse() throws Exception {
345345 "xxx-yyyyyyy-zzz:/home/users/s\n " +
346346 " 14428928 12956424 1472504 90% /home/users/s" ;
347347 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
348- assertEquals (1472504L , fsu .freeSpaceUnix ("/home/users/s" , false , false ));
348+ assertEquals (1472504L , fsu .freeSpaceUnix ("/home/users/s" , false , false , - 1 ));
349349 }
350350
351351 public void testGetFreeSpaceUnix_String_LongResponseKb () throws Exception {
@@ -354,26 +354,26 @@ public void testGetFreeSpaceUnix_String_LongResponseKb() throws Exception {
354354 "xxx-yyyyyyy-zzz:/home/users/s\n " +
355355 " 14428928 12956424 1472504 90% /home/users/s" ;
356356 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
357- assertEquals (1472504L , fsu .freeSpaceUnix ("/home/users/s" , true , false ));
357+ assertEquals (1472504L , fsu .freeSpaceUnix ("/home/users/s" , true , false , - 1 ));
358358 }
359359
360360 public void testGetFreeSpaceUnix_String_EmptyResponse () throws Exception {
361361 String lines = "" ;
362362 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
363363 try {
364- fsu .freeSpaceUnix ("/home/users/s" , false , false );
364+ fsu .freeSpaceUnix ("/home/users/s" , false , false , - 1 );
365365 fail ();
366366 } catch (IOException ex ) {}
367367 try {
368- fsu .freeSpaceUnix ("/home/users/s" , true , false );
368+ fsu .freeSpaceUnix ("/home/users/s" , true , false , - 1 );
369369 fail ();
370370 } catch (IOException ex ) {}
371371 try {
372- fsu .freeSpaceUnix ("/home/users/s" , false , true );
372+ fsu .freeSpaceUnix ("/home/users/s" , false , true , - 1 );
373373 fail ();
374374 } catch (IOException ex ) {}
375375 try {
376- fsu .freeSpaceUnix ("/home/users/s" , true , true );
376+ fsu .freeSpaceUnix ("/home/users/s" , true , true , - 1 );
377377 fail ();
378378 } catch (IOException ex ) {}
379379 }
@@ -384,19 +384,19 @@ public void testGetFreeSpaceUnix_String_InvalidResponse1() throws Exception {
384384 " 14428928 12956424 100" ;
385385 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
386386 try {
387- fsu .freeSpaceUnix ("/home/users/s" , false , false );
387+ fsu .freeSpaceUnix ("/home/users/s" , false , false , - 1 );
388388 fail ();
389389 } catch (IOException ex ) {}
390390 try {
391- fsu .freeSpaceUnix ("/home/users/s" , true , false );
391+ fsu .freeSpaceUnix ("/home/users/s" , true , false , - 1 );
392392 fail ();
393393 } catch (IOException ex ) {}
394394 try {
395- fsu .freeSpaceUnix ("/home/users/s" , false , true );
395+ fsu .freeSpaceUnix ("/home/users/s" , false , true , - 1 );
396396 fail ();
397397 } catch (IOException ex ) {}
398398 try {
399- fsu .freeSpaceUnix ("/home/users/s" , true , true );
399+ fsu .freeSpaceUnix ("/home/users/s" , true , true , - 1 );
400400 fail ();
401401 } catch (IOException ex ) {}
402402 }
@@ -407,19 +407,19 @@ public void testGetFreeSpaceUnix_String_InvalidResponse2() throws Exception {
407407 "xxx:/home/users/s 14428928 12956424 nnnnnnn 90% /home/users/s" ;
408408 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
409409 try {
410- fsu .freeSpaceUnix ("/home/users/s" , false , false );
410+ fsu .freeSpaceUnix ("/home/users/s" , false , false , - 1 );
411411 fail ();
412412 } catch (IOException ex ) {}
413413 try {
414- fsu .freeSpaceUnix ("/home/users/s" , true , false );
414+ fsu .freeSpaceUnix ("/home/users/s" , true , false , - 1 );
415415 fail ();
416416 } catch (IOException ex ) {}
417417 try {
418- fsu .freeSpaceUnix ("/home/users/s" , false , true );
418+ fsu .freeSpaceUnix ("/home/users/s" , false , true , - 1 );
419419 fail ();
420420 } catch (IOException ex ) {}
421421 try {
422- fsu .freeSpaceUnix ("/home/users/s" , true , true );
422+ fsu .freeSpaceUnix ("/home/users/s" , true , true , - 1 );
423423 fail ();
424424 } catch (IOException ex ) {}
425425 }
@@ -430,19 +430,19 @@ public void testGetFreeSpaceUnix_String_InvalidResponse3() throws Exception {
430430 "xxx:/home/users/s 14428928 12956424 -1 90% /home/users/s" ;
431431 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
432432 try {
433- fsu .freeSpaceUnix ("/home/users/s" , false , false );
433+ fsu .freeSpaceUnix ("/home/users/s" , false , false , - 1 );
434434 fail ();
435435 } catch (IOException ex ) {}
436436 try {
437- fsu .freeSpaceUnix ("/home/users/s" , true , false );
437+ fsu .freeSpaceUnix ("/home/users/s" , true , false , - 1 );
438438 fail ();
439439 } catch (IOException ex ) {}
440440 try {
441- fsu .freeSpaceUnix ("/home/users/s" , false , true );
441+ fsu .freeSpaceUnix ("/home/users/s" , false , true , - 1 );
442442 fail ();
443443 } catch (IOException ex ) {}
444444 try {
445- fsu .freeSpaceUnix ("/home/users/s" , true , true );
445+ fsu .freeSpaceUnix ("/home/users/s" , true , true , - 1 );
446446 fail ();
447447 } catch (IOException ex ) {}
448448 }
@@ -453,19 +453,19 @@ public void testGetFreeSpaceUnix_String_InvalidResponse4() throws Exception {
453453 "xxx-yyyyyyy-zzz:/home/users/s" ;
454454 FileSystemUtils fsu = new MockFileSystemUtils (0 , lines );
455455 try {
456- fsu .freeSpaceUnix ("/home/users/s" , false , false );
456+ fsu .freeSpaceUnix ("/home/users/s" , false , false , - 1 );
457457 fail ();
458458 } catch (IOException ex ) {}
459459 try {
460- fsu .freeSpaceUnix ("/home/users/s" , true , false );
460+ fsu .freeSpaceUnix ("/home/users/s" , true , false , - 1 );
461461 fail ();
462462 } catch (IOException ex ) {}
463463 try {
464- fsu .freeSpaceUnix ("/home/users/s" , false , true );
464+ fsu .freeSpaceUnix ("/home/users/s" , false , true , - 1 );
465465 fail ();
466466 } catch (IOException ex ) {}
467467 try {
468- fsu .freeSpaceUnix ("/home/users/s" , true , true );
468+ fsu .freeSpaceUnix ("/home/users/s" , true , true , - 1 );
469469 fail ();
470470 } catch (IOException ex ) {}
471471 }
0 commit comments