4545 * @version $Id: $Id
4646 * @since 3.4.0
4747 */
48- public class DirectoryScannerTest extends FileBasedTestCase {
49- private static String testDir = getTestDirectory ().getPath ();
48+ class DirectoryScannerTest extends FileBasedTestCase {
49+ private static final String testDir = getTestDirectory ().getPath ();
5050
5151 /**
5252 * <p>setUp.</p>
5353 */
5454 @ BeforeEach
55- public void setUp () {
55+ void setUp () {
5656 try {
5757 FileUtils .deleteDirectory (testDir );
5858 } catch (IOException e ) {
@@ -67,7 +67,7 @@ public void setUp() {
6767 * @throws java.net.URISyntaxException if any.
6868 */
6969 @ Test
70- public void testCrossPlatformIncludesString () throws IOException , URISyntaxException {
70+ void crossPlatformIncludesString () throws IOException , URISyntaxException {
7171 DirectoryScanner ds = new DirectoryScanner ();
7272 ds .setBasedir (new File (getTestResourcesDir () + File .separator + "directory-scanner" ).getCanonicalFile ());
7373
@@ -93,7 +93,7 @@ public void testCrossPlatformIncludesString() throws IOException, URISyntaxExcep
9393 * @throws java.net.URISyntaxException if any.
9494 */
9595 @ Test
96- public void testCrossPlatformExcludesString () throws IOException , URISyntaxException {
96+ void crossPlatformExcludesString () throws IOException , URISyntaxException {
9797 DirectoryScanner ds = new DirectoryScanner ();
9898 ds .setBasedir (new File (getTestResourcesDir () + File .separator + "directory-scanner" ).getCanonicalFile ());
9999 ds .setIncludes (new String [] {"**" });
@@ -156,11 +156,10 @@ private boolean checkTestFilesSymlinks() {
156156 }
157157 return true ;
158158 } catch (IOException e ) {
159- System .err .println (String .format (
160- "The unit test '%s.%s' will be skipped, reason: %s" ,
161- this .getClass ().getSimpleName (), getTestMethodName (), e .getMessage ()));
162- System .out .println (
163- String .format ("This test requires symlinks files in '%s' directory." , symlinksDirectory .getPath ()));
159+ System .err .printf (
160+ "The unit test '%s.%s' will be skipped, reason: %s%n" ,
161+ this .getClass ().getSimpleName (), getTestMethodName (), e .getMessage ());
162+ System .out .printf ("This test requires symlinks files in '%s' directory.%n" , symlinksDirectory .getPath ());
164163 System .out .println ("On some OS (like Windows 10), files are present only if the clone/checkout is done"
165164 + " in administrator mode, and correct (symlinks and not flat file/directory)"
166165 + " if symlinks option are used (for git: git clone -c core.symlinks=true [url])" );
@@ -174,7 +173,7 @@ private boolean checkTestFilesSymlinks() {
174173 * @throws java.io.IOException if any.
175174 */
176175 @ Test
177- public void testGeneral () throws IOException {
176+ void general () throws IOException {
178177 this .createTestFiles ();
179178
180179 String includes = "scanner1.dat,scanner2.dat,scanner3.dat,scanner4.dat,scanner5.dat" ;
@@ -194,7 +193,7 @@ public void testGeneral() throws IOException {
194193 * @throws java.io.IOException if any.
195194 */
196195 @ Test
197- public void testIncludesExcludesWithWhiteSpaces () throws IOException {
196+ void includesExcludesWithWhiteSpaces () throws IOException {
198197 this .createTestFiles ();
199198
200199 String includes = "scanner1.dat,\n \n ,scanner2.dat \n \r , scanner3.dat\n , \t scanner4.dat,scanner5.dat\n ," ;
@@ -213,7 +212,7 @@ public void testIncludesExcludesWithWhiteSpaces() throws IOException {
213212 * <p>testFollowSymlinksFalse.</p>
214213 */
215214 @ Test
216- public void testFollowSymlinksFalse () {
215+ void followSymlinksFalse () {
217216 assumeTrue (checkTestFilesSymlinks ());
218217
219218 DirectoryScanner ds = new DirectoryScanner ();
@@ -248,7 +247,7 @@ private void assertAlwaysIncluded(List<String> included) {
248247 * <p>testFollowSymlinks.</p>
249248 */
250249 @ Test
251- public void testFollowSymlinks () {
250+ void followSymlinks () {
252251 assumeTrue (checkTestFilesSymlinks ());
253252
254253 DirectoryScanner ds = new DirectoryScanner ();
@@ -295,7 +294,7 @@ private void createTestDirectories() throws IOException {
295294 * @throws java.io.IOException if any.
296295 */
297296 @ Test
298- public void testDirectoriesWithHyphens () throws IOException {
297+ void directoriesWithHyphens () throws IOException {
299298 this .createTestDirectories ();
300299
301300 DirectoryScanner ds = new DirectoryScanner ();
@@ -317,7 +316,7 @@ public void testDirectoriesWithHyphens() throws IOException {
317316 * @throws java.io.IOException if any.
318317 */
319318 @ Test
320- public void testAntExcludesOverrideIncludes () throws IOException {
319+ void antExcludesOverrideIncludes () throws IOException {
321320 printTestHeader ();
322321
323322 File dir = new File (testDir , "regex-dir" );
@@ -354,8 +353,8 @@ public void testAntExcludesOverrideIncludes() throws IOException {
354353 *
355354 * @throws java.io.IOException if any.
356355 */
357- @ org . junit . jupiter . api . Test
358- public void testAntExcludesOverrideIncludesWithExplicitAntPrefix () throws IOException {
356+ @ Test
357+ void antExcludesOverrideIncludesWithExplicitAntPrefix () throws IOException {
359358 printTestHeader ();
360359
361360 File dir = new File (testDir , "regex-dir" );
@@ -393,8 +392,8 @@ public void testAntExcludesOverrideIncludesWithExplicitAntPrefix() throws IOExce
393392 *
394393 * @throws java.io.IOException if any.
395394 */
396- @ org . junit . jupiter . api . Test
397- public void testRegexIncludeWithExcludedPrefixDirs () throws IOException {
395+ @ Test
396+ void regexIncludeWithExcludedPrefixDirs () throws IOException {
398397 printTestHeader ();
399398
400399 File dir = new File (testDir , "regex-dir" );
@@ -427,14 +426,14 @@ public void testRegexIncludeWithExcludedPrefixDirs() throws IOException {
427426 *
428427 * @throws java.io.IOException if any.
429428 */
430- @ org . junit . jupiter . api . Test
431- public void testRegexExcludeWithNegativeLookahead () throws IOException {
429+ @ Test
430+ void regexExcludeWithNegativeLookahead () throws IOException {
432431 printTestHeader ();
433432
434433 File dir = new File (testDir , "regex-dir" );
435434 try {
436435 FileUtils .deleteDirectory (dir );
437- } catch (IOException e ) {
436+ } catch (IOException ignored ) {
438437 }
439438
440439 dir .mkdirs ();
@@ -467,13 +466,13 @@ public void testRegexExcludeWithNegativeLookahead() throws IOException {
467466 * @throws java.io.IOException if any.
468467 */
469468 @ Test
470- public void testRegexWithSlashInsideCharacterClass () throws IOException {
469+ void regexWithSlashInsideCharacterClass () throws IOException {
471470 printTestHeader ();
472471
473472 File dir = new File (testDir , "regex-dir" );
474473 try {
475474 FileUtils .deleteDirectory (dir );
476- } catch (IOException e ) {
475+ } catch (IOException ignored ) {
477476 }
478477
479478 dir .mkdirs ();
@@ -508,7 +507,7 @@ public void testRegexWithSlashInsideCharacterClass() throws IOException {
508507 * @throws java.io.IOException if occurs an I/O error.
509508 */
510509 @ Test
511- public void testDoNotScanUnnecesaryDirectories () throws IOException {
510+ void doNotScanUnnecesaryDirectories () throws IOException {
512511 createTestDirectories ();
513512
514513 // create additional directories 'anotherDir1', 'anotherDir2' and 'anotherDir3' with a 'file1.dat' file
@@ -547,7 +546,7 @@ public void testDoNotScanUnnecesaryDirectories() throws IOException {
547546 "directoryTest" + File .separator + "test-dir-123" + File .separator + "file1.dat"
548547 };
549548
550- final Set <String > scannedDirSet = new HashSet <String >();
549+ final Set <String > scannedDirSet = new HashSet <>();
551550
552551 DirectoryScanner ds = new DirectoryScanner () {
553552 @ Override
@@ -566,7 +565,7 @@ protected void scandir(File dir, String vpath, boolean fast) {
566565 assertInclusionsAndExclusions (ds .getIncludedFiles (), excludedPaths , includedPaths );
567566
568567 Set <String > expectedScannedDirSet =
569- new HashSet <String >(Arrays .asList ("io" , "directoryTest" , "testDir123" , "test_dir_123" , "test-dir-123" ));
568+ new HashSet <>(Arrays .asList ("io" , "directoryTest" , "testDir123" , "test_dir_123" , "test-dir-123" ));
570569
571570 assertEquals (expectedScannedDirSet , scannedDirSet );
572571 }
@@ -577,7 +576,7 @@ protected void scandir(File dir, String vpath, boolean fast) {
577576 * @throws java.io.IOException if any.
578577 */
579578 @ Test
580- public void testIsSymbolicLink () throws IOException {
579+ void isSymbolicLink () throws IOException {
581580 assumeTrue (checkTestFilesSymlinks ());
582581
583582 final File directory = new File ("src/test/resources/symlinks/src" );
@@ -594,7 +593,7 @@ public void testIsSymbolicLink() throws IOException {
594593 * @throws java.io.IOException if any.
595594 */
596595 @ Test
597- public void testIsParentSymbolicLink () throws IOException {
596+ void isParentSymbolicLink () throws IOException {
598597 assumeTrue (checkTestFilesSymlinks ());
599598
600599 final File directory = new File ("src/test/resources/symlinks/src" );
@@ -622,7 +621,7 @@ private void assertInclusionsAndExclusions(String[] files, String[] excludedPath
622621 System .out .println (file );
623622 }
624623
625- List <String > failedToExclude = new ArrayList <String >();
624+ List <String > failedToExclude = new ArrayList <>();
626625 for (String excludedPath : excludedPaths ) {
627626 String alt = excludedPath .replace ('/' , '\\' );
628627 System .out .println ("Searching for exclusion as: " + excludedPath + "\n or: " + alt );
@@ -631,7 +630,7 @@ private void assertInclusionsAndExclusions(String[] files, String[] excludedPath
631630 }
632631 }
633632
634- List <String > failedToInclude = new ArrayList <String >();
633+ List <String > failedToInclude = new ArrayList <>();
635634 for (String includedPath : includedPaths ) {
636635 String alt = includedPath .replace ('/' , '\\' );
637636 System .out .println ("Searching for inclusion as: " + includedPath + "\n or: " + alt );
0 commit comments