45
45
* @version $Id: $Id
46
46
* @since 3.4.0
47
47
*/
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 ();
50
50
51
51
/**
52
52
* <p>setUp.</p>
53
53
*/
54
54
@ BeforeEach
55
- public void setUp () {
55
+ void setUp () {
56
56
try {
57
57
FileUtils .deleteDirectory (testDir );
58
58
} catch (IOException e ) {
@@ -67,7 +67,7 @@ public void setUp() {
67
67
* @throws java.net.URISyntaxException if any.
68
68
*/
69
69
@ Test
70
- public void testCrossPlatformIncludesString () throws IOException , URISyntaxException {
70
+ void crossPlatformIncludesString () throws IOException , URISyntaxException {
71
71
DirectoryScanner ds = new DirectoryScanner ();
72
72
ds .setBasedir (new File (getTestResourcesDir () + File .separator + "directory-scanner" ).getCanonicalFile ());
73
73
@@ -93,7 +93,7 @@ public void testCrossPlatformIncludesString() throws IOException, URISyntaxExcep
93
93
* @throws java.net.URISyntaxException if any.
94
94
*/
95
95
@ Test
96
- public void testCrossPlatformExcludesString () throws IOException , URISyntaxException {
96
+ void crossPlatformExcludesString () throws IOException , URISyntaxException {
97
97
DirectoryScanner ds = new DirectoryScanner ();
98
98
ds .setBasedir (new File (getTestResourcesDir () + File .separator + "directory-scanner" ).getCanonicalFile ());
99
99
ds .setIncludes (new String [] {"**" });
@@ -156,11 +156,10 @@ private boolean checkTestFilesSymlinks() {
156
156
}
157
157
return true ;
158
158
} 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 ());
164
163
System .out .println ("On some OS (like Windows 10), files are present only if the clone/checkout is done"
165
164
+ " in administrator mode, and correct (symlinks and not flat file/directory)"
166
165
+ " if symlinks option are used (for git: git clone -c core.symlinks=true [url])" );
@@ -174,7 +173,7 @@ private boolean checkTestFilesSymlinks() {
174
173
* @throws java.io.IOException if any.
175
174
*/
176
175
@ Test
177
- public void testGeneral () throws IOException {
176
+ void general () throws IOException {
178
177
this .createTestFiles ();
179
178
180
179
String includes = "scanner1.dat,scanner2.dat,scanner3.dat,scanner4.dat,scanner5.dat" ;
@@ -194,7 +193,7 @@ public void testGeneral() throws IOException {
194
193
* @throws java.io.IOException if any.
195
194
*/
196
195
@ Test
197
- public void testIncludesExcludesWithWhiteSpaces () throws IOException {
196
+ void includesExcludesWithWhiteSpaces () throws IOException {
198
197
this .createTestFiles ();
199
198
200
199
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 {
213
212
* <p>testFollowSymlinksFalse.</p>
214
213
*/
215
214
@ Test
216
- public void testFollowSymlinksFalse () {
215
+ void followSymlinksFalse () {
217
216
assumeTrue (checkTestFilesSymlinks ());
218
217
219
218
DirectoryScanner ds = new DirectoryScanner ();
@@ -248,7 +247,7 @@ private void assertAlwaysIncluded(List<String> included) {
248
247
* <p>testFollowSymlinks.</p>
249
248
*/
250
249
@ Test
251
- public void testFollowSymlinks () {
250
+ void followSymlinks () {
252
251
assumeTrue (checkTestFilesSymlinks ());
253
252
254
253
DirectoryScanner ds = new DirectoryScanner ();
@@ -295,7 +294,7 @@ private void createTestDirectories() throws IOException {
295
294
* @throws java.io.IOException if any.
296
295
*/
297
296
@ Test
298
- public void testDirectoriesWithHyphens () throws IOException {
297
+ void directoriesWithHyphens () throws IOException {
299
298
this .createTestDirectories ();
300
299
301
300
DirectoryScanner ds = new DirectoryScanner ();
@@ -317,7 +316,7 @@ public void testDirectoriesWithHyphens() throws IOException {
317
316
* @throws java.io.IOException if any.
318
317
*/
319
318
@ Test
320
- public void testAntExcludesOverrideIncludes () throws IOException {
319
+ void antExcludesOverrideIncludes () throws IOException {
321
320
printTestHeader ();
322
321
323
322
File dir = new File (testDir , "regex-dir" );
@@ -354,8 +353,8 @@ public void testAntExcludesOverrideIncludes() throws IOException {
354
353
*
355
354
* @throws java.io.IOException if any.
356
355
*/
357
- @ org . junit . jupiter . api . Test
358
- public void testAntExcludesOverrideIncludesWithExplicitAntPrefix () throws IOException {
356
+ @ Test
357
+ void antExcludesOverrideIncludesWithExplicitAntPrefix () throws IOException {
359
358
printTestHeader ();
360
359
361
360
File dir = new File (testDir , "regex-dir" );
@@ -393,8 +392,8 @@ public void testAntExcludesOverrideIncludesWithExplicitAntPrefix() throws IOExce
393
392
*
394
393
* @throws java.io.IOException if any.
395
394
*/
396
- @ org . junit . jupiter . api . Test
397
- public void testRegexIncludeWithExcludedPrefixDirs () throws IOException {
395
+ @ Test
396
+ void regexIncludeWithExcludedPrefixDirs () throws IOException {
398
397
printTestHeader ();
399
398
400
399
File dir = new File (testDir , "regex-dir" );
@@ -427,14 +426,14 @@ public void testRegexIncludeWithExcludedPrefixDirs() throws IOException {
427
426
*
428
427
* @throws java.io.IOException if any.
429
428
*/
430
- @ org . junit . jupiter . api . Test
431
- public void testRegexExcludeWithNegativeLookahead () throws IOException {
429
+ @ Test
430
+ void regexExcludeWithNegativeLookahead () throws IOException {
432
431
printTestHeader ();
433
432
434
433
File dir = new File (testDir , "regex-dir" );
435
434
try {
436
435
FileUtils .deleteDirectory (dir );
437
- } catch (IOException e ) {
436
+ } catch (IOException ignored ) {
438
437
}
439
438
440
439
dir .mkdirs ();
@@ -467,13 +466,13 @@ public void testRegexExcludeWithNegativeLookahead() throws IOException {
467
466
* @throws java.io.IOException if any.
468
467
*/
469
468
@ Test
470
- public void testRegexWithSlashInsideCharacterClass () throws IOException {
469
+ void regexWithSlashInsideCharacterClass () throws IOException {
471
470
printTestHeader ();
472
471
473
472
File dir = new File (testDir , "regex-dir" );
474
473
try {
475
474
FileUtils .deleteDirectory (dir );
476
- } catch (IOException e ) {
475
+ } catch (IOException ignored ) {
477
476
}
478
477
479
478
dir .mkdirs ();
@@ -508,7 +507,7 @@ public void testRegexWithSlashInsideCharacterClass() throws IOException {
508
507
* @throws java.io.IOException if occurs an I/O error.
509
508
*/
510
509
@ Test
511
- public void testDoNotScanUnnecesaryDirectories () throws IOException {
510
+ void doNotScanUnnecesaryDirectories () throws IOException {
512
511
createTestDirectories ();
513
512
514
513
// create additional directories 'anotherDir1', 'anotherDir2' and 'anotherDir3' with a 'file1.dat' file
@@ -547,7 +546,7 @@ public void testDoNotScanUnnecesaryDirectories() throws IOException {
547
546
"directoryTest" + File .separator + "test-dir-123" + File .separator + "file1.dat"
548
547
};
549
548
550
- final Set <String > scannedDirSet = new HashSet <String >();
549
+ final Set <String > scannedDirSet = new HashSet <>();
551
550
552
551
DirectoryScanner ds = new DirectoryScanner () {
553
552
@ Override
@@ -566,7 +565,7 @@ protected void scandir(File dir, String vpath, boolean fast) {
566
565
assertInclusionsAndExclusions (ds .getIncludedFiles (), excludedPaths , includedPaths );
567
566
568
567
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" ));
570
569
571
570
assertEquals (expectedScannedDirSet , scannedDirSet );
572
571
}
@@ -577,7 +576,7 @@ protected void scandir(File dir, String vpath, boolean fast) {
577
576
* @throws java.io.IOException if any.
578
577
*/
579
578
@ Test
580
- public void testIsSymbolicLink () throws IOException {
579
+ void isSymbolicLink () throws IOException {
581
580
assumeTrue (checkTestFilesSymlinks ());
582
581
583
582
final File directory = new File ("src/test/resources/symlinks/src" );
@@ -594,7 +593,7 @@ public void testIsSymbolicLink() throws IOException {
594
593
* @throws java.io.IOException if any.
595
594
*/
596
595
@ Test
597
- public void testIsParentSymbolicLink () throws IOException {
596
+ void isParentSymbolicLink () throws IOException {
598
597
assumeTrue (checkTestFilesSymlinks ());
599
598
600
599
final File directory = new File ("src/test/resources/symlinks/src" );
@@ -622,7 +621,7 @@ private void assertInclusionsAndExclusions(String[] files, String[] excludedPath
622
621
System .out .println (file );
623
622
}
624
623
625
- List <String > failedToExclude = new ArrayList <String >();
624
+ List <String > failedToExclude = new ArrayList <>();
626
625
for (String excludedPath : excludedPaths ) {
627
626
String alt = excludedPath .replace ('/' , '\\' );
628
627
System .out .println ("Searching for exclusion as: " + excludedPath + "\n or: " + alt );
@@ -631,7 +630,7 @@ private void assertInclusionsAndExclusions(String[] files, String[] excludedPath
631
630
}
632
631
}
633
632
634
- List <String > failedToInclude = new ArrayList <String >();
633
+ List <String > failedToInclude = new ArrayList <>();
635
634
for (String includedPath : includedPaths ) {
636
635
String alt = includedPath .replace ('/' , '\\' );
637
636
System .out .println ("Searching for inclusion as: " + includedPath + "\n or: " + alt );
0 commit comments