@Test
public void testExistingDir() throws IOException, InterruptedException {

  File tmpdir = FileUtil.mktempdir();
  File subDir = new File(tmpdir, "subdir");
  subDir.mkdirs();
  TailDirSource src = new TailDirSource(tmpdir, ".*");
  AccumulatorSink cnt = new AccumulatorSink("tailcount");
  DirectDriver drv = new DirectDriver(src, cnt);
  genFiles(tmpdir, "foo", 10, 100);
  drv.start();
  Clock.sleep(1000);
  assertEquals(1000, cnt.getCount());
  drv.stop();
  FileUtil.rmr(tmpdir);
  // only did 10 files, ignored the dir.
  assertEquals(Long.valueOf(10),
      src.getMetrics().getLongMetric(TailDirSource.A_FILESADDED));
}