Indexer { public void indexDirectory(String path) { Collection<File> paths = Arrays.asList(new File(path).listFiles()); Collection<Talk> talks = Collections2.transform(paths, new TalkFromFile()); logger.info("Indexing {} talks", talks.size()); index(talks.toArray(new Talk[talks.size()])); } Indexer(Directory directory); void index(Talk...talks); void indexDirectory(String path); static void main(String [] args);  }
@Test public void indexOneTalkFromDirectory() throws IOException { Path dir = Files.createTempDirectory("indexertest"); Path file = Files.createTempFile(dir, "post", ".properties"); List<String> lines = new ArrayList<>(); lines.add("speaker=Tester"); lines.add("title=Test"); lines.add("content=Content"); lines.add("date=12.06.2012"); lines.add("categories=Test1,Test2"); Files.write(file, lines, Charset.forName("ISO-8859-1")); indexer.indexDirectory(dir.toAbsolutePath().toString()); assertDocumentCount(1); }