@Test public final void assertThanScanCallsCallbackForEveryMatchingFile() { final File rootDir = new File(getClass().getResource("data/").getPath()); final AtomicInteger noScannedFiles = new AtomicInteger(0); final DirectoryScanner objectUnderTest = new DirectoryScanner(rootDir, ".xml", new DirectoryScanner.Callback() { @Override public void scanned(final File scannedFile) { noScannedFiles.incrementAndGet(); } }); objectUnderTest.scan(); assertEquals( "Scanning directory should have called callback two times for two matching files", 2, noScannedFiles.get()); }
public void scan() { this.log.info( "Scanning files matching [*{}] in subdirectories of [{}] ...", this.suffix, this.rootDirectory); final FileFilter isDirectory = new FileFilter() { @Override public boolean accept(final File arg0) { return arg0.isDirectory(); } }; final File[] subdirs = this.rootDirectory.listFiles(isDirectory); this.log.info( "Found {} subdirectories located in [{}]: {}", new Object[] { subdirs.length, this.rootDirectory, Arrays.toString(subdirs) }); for (final File subdir : subdirs) { scanDirectory(subdir); } this.log.info( "Finished scanning files matching [*{}] in subdirectories of [{}]", this.suffix, this.rootDirectory); }
DirectoryScanner { public void scan() { this.log.info( "Scanning files matching [*{}] in subdirectories of [{}] ...", this.suffix, this.rootDirectory); final FileFilter isDirectory = new FileFilter() { @Override public boolean accept(final File arg0) { return arg0.isDirectory(); } }; final File[] subdirs = this.rootDirectory.listFiles(isDirectory); this.log.info( "Found {} subdirectories located in [{}]: {}", new Object[] { subdirs.length, this.rootDirectory, Arrays.toString(subdirs) }); for (final File subdir : subdirs) { scanDirectory(subdir); } this.log.info( "Finished scanning files matching [*{}] in subdirectories of [{}]", this.suffix, this.rootDirectory); } }
DirectoryScanner { public void scan() { this.log.info( "Scanning files matching [*{}] in subdirectories of [{}] ...", this.suffix, this.rootDirectory); final FileFilter isDirectory = new FileFilter() { @Override public boolean accept(final File arg0) { return arg0.isDirectory(); } }; final File[] subdirs = this.rootDirectory.listFiles(isDirectory); this.log.info( "Found {} subdirectories located in [{}]: {}", new Object[] { subdirs.length, this.rootDirectory, Arrays.toString(subdirs) }); for (final File subdir : subdirs) { scanDirectory(subdir); } this.log.info( "Finished scanning files matching [*{}] in subdirectories of [{}]", this.suffix, this.rootDirectory); } DirectoryScanner(final File rootDirectory, final String suffix,
	        final Callback callback); }
DirectoryScanner { public void scan() { this.log.info( "Scanning files matching [*{}] in subdirectories of [{}] ...", this.suffix, this.rootDirectory); final FileFilter isDirectory = new FileFilter() { @Override public boolean accept(final File arg0) { return arg0.isDirectory(); } }; final File[] subdirs = this.rootDirectory.listFiles(isDirectory); this.log.info( "Found {} subdirectories located in [{}]: {}", new Object[] { subdirs.length, this.rootDirectory, Arrays.toString(subdirs) }); for (final File subdir : subdirs) { scanDirectory(subdir); } this.log.info( "Finished scanning files matching [*{}] in subdirectories of [{}]", this.suffix, this.rootDirectory); } DirectoryScanner(final File rootDirectory, final String suffix,
	        final Callback callback); void scan(); @Override String toString(); }
DirectoryScanner { public void scan() { this.log.info( "Scanning files matching [*{}] in subdirectories of [{}] ...", this.suffix, this.rootDirectory); final FileFilter isDirectory = new FileFilter() { @Override public boolean accept(final File arg0) { return arg0.isDirectory(); } }; final File[] subdirs = this.rootDirectory.listFiles(isDirectory); this.log.info( "Found {} subdirectories located in [{}]: {}", new Object[] { subdirs.length, this.rootDirectory, Arrays.toString(subdirs) }); for (final File subdir : subdirs) { scanDirectory(subdir); } this.log.info( "Finished scanning files matching [*{}] in subdirectories of [{}]", this.suffix, this.rootDirectory); } DirectoryScanner(final File rootDirectory, final String suffix,
	        final Callback callback); void scan(); @Override String toString();  }