@@ -405,6 +405,44 @@ public void testRegexWithSlashInsideCharacterClass()
405
405
assertInclusionsAndExclusions ( ds .getIncludedFiles (), excludedPaths , includedPaths );
406
406
}
407
407
408
+ public void testIsSymbolicLink ()
409
+ throws IOException
410
+ {
411
+ // TODO: Uncomment when PR #25 merged
412
+ // if ( !checkTestFilesSymlinks() )
413
+ // {
414
+ // return;
415
+ // }
416
+
417
+ final File directory = new File ( "src/test/resources/symlinks/src" );
418
+ DirectoryScanner ds = new DirectoryScanner ();
419
+ assertTrue ( ds .isSymbolicLink ( directory , "symR" ) );
420
+ assertTrue ( ds .isSymbolicLink ( directory , "symDir" ) );
421
+ assertFalse ( ds .isSymbolicLink ( directory , "fileR.txt" ) );
422
+ assertFalse ( ds .isSymbolicLink ( directory , "aRegularDir" ) );
423
+ }
424
+
425
+ public void testIsParentSymbolicLink ()
426
+ throws IOException
427
+ {
428
+ // TODO: Uncomment when PR #25 merged
429
+ // if ( !checkTestFilesSymlinks() )
430
+ // {
431
+ // return;
432
+ // }
433
+
434
+ final File directory = new File ( "src/test/resources/symlinks/src" );
435
+ DirectoryScanner ds = new DirectoryScanner ();
436
+ assertFalse ( ds .isParentSymbolicLink ( directory , "symR" ) );
437
+ assertFalse ( ds .isParentSymbolicLink ( directory , "symDir" ) );
438
+ assertFalse ( ds .isParentSymbolicLink ( directory , "fileR.txt" ) );
439
+ assertFalse ( ds .isParentSymbolicLink ( directory , "aRegularDir" ) );
440
+ assertFalse ( ds .isParentSymbolicLink ( new File ( directory , "aRegularDir" ), "aRegulatFile.txt" ) );
441
+ assertTrue ( ds .isParentSymbolicLink ( new File ( directory , "symDir" ), "targetFile.txt" ) );
442
+ assertTrue ( ds .isParentSymbolicLink ( new File ( directory , "symLinkToDirOnTheOutside" ),
443
+ "FileInDirOnTheOutside.txt" ) );
444
+ }
445
+
408
446
private void printTestHeader ()
409
447
{
410
448
StackTraceElement ste = new Throwable ().getStackTrace ()[1 ];
@@ -446,8 +484,7 @@ private void assertInclusionsAndExclusions( String[] files, String[] excludedPat
446
484
StringBuilder buffer = new StringBuilder ();
447
485
if ( !failedToExclude .isEmpty () )
448
486
{
449
- buffer .append ( "Should NOT have included:\n " ).append (
450
- StringUtils .join ( failedToExclude .iterator (),
487
+ buffer .append ( "Should NOT have included:\n " ).append ( StringUtils .join ( failedToExclude .iterator (),
451
488
"\n \t - " ) );
452
489
}
453
490
@@ -458,8 +495,8 @@ private void assertInclusionsAndExclusions( String[] files, String[] excludedPat
458
495
buffer .append ( "\n \n " );
459
496
}
460
497
461
- buffer .append ( "Should have included:\n " )
462
- . append ( StringUtils . join ( failedToInclude . iterator (), "\n \t - " ) );
498
+ buffer .append ( "Should have included:\n " ). append ( StringUtils . join ( failedToInclude . iterator (),
499
+ "\n \t - " ) );
463
500
}
464
501
465
502
if ( buffer .length () > 0 )
0 commit comments