### Question:
SimpleLuceneIndexCreator extends AbstractLuceneIndexCreator { public boolean createIndex(File indexPath, Iterator<String> docIterator) { LOGGER.info("Starting index creation..."); IndexWriter writer = null; indexPath.mkdirs(); Analyzer analyzer = new SimpleAnalyzer(true); try { IndexWriterConfig config = new IndexWriterConfig(version, analyzer); config.setOpenMode(OpenMode.CREATE); FieldType fieldType = new FieldType(TextField.TYPE_NOT_STORED); fieldType.setIndexed(true); fieldType.setIndexOptions(IndexOptions.DOCS_AND_FREQS); fieldType.freeze(); writer = new IndexWriter(FSDirectory.open(indexPath), config); String text; int count = 0; while (docIterator.hasNext()) { text = docIterator.next(); if (text.length() > 0) { writer.addDocument(toLuceneDocument(analyzer, text, fieldType)); ++count; if (count >= commitInterval) { writer.commit(); System.gc(); count = 0; } } else { LOGGER.warn("Got a document without content."); } } LOGGER.info("Finished index creation."); } catch (IOException e) { LOGGER.error("Error while creating Index. Aborting.", e); return false; } finally { if (writer != null) { try { writer.close(); } catch (Exception e) { } } } return true; } SimpleLuceneIndexCreator(String fieldName);  SimpleLuceneIndexCreator(String textFieldName, int commitInterval); boolean createIndex(File indexPath, Iterator<String> docIterator);  }### Answer:
@Test public void test() throws CorruptIndexException, IOException { File indexDir = createTempDirectory(); Iterator<String> docIterator = Arrays.asList(DOCUMENTS).iterator(); SimpleLuceneIndexCreator creator = new SimpleLuceneIndexCreator(Palmetto.DEFAULT_TEXT_INDEX_FIELD_NAME); Assert.assertTrue(creator.createIndex(indexDir, docIterator)); LuceneCorpusAdapter adapter = LuceneCorpusAdapter.create(indexDir.getAbsolutePath(), Palmetto.DEFAULT_TEXT_INDEX_FIELD_NAME); ObjectObjectOpenHashMap<String, IntArrayList> wordDocMapping = new ObjectObjectOpenHashMap<String, IntArrayList>(); for (int i = 0; i < TEST_WORDS.length; ++i) { wordDocMapping.put(TEST_WORDS[i], new IntArrayList()); } adapter.getDocumentsWithWords(wordDocMapping); int retrievedDocs; for (int i = 0; i < TEST_WORDS.length; ++i) { retrievedDocs = wordDocMapping.get(TEST_WORDS[i]).elementsCount; Assert.assertEquals("Expected " + EXPECTED_DOC_COUNTS[i] + " documents containing the word \"" + TEST_WORDS[i] + "\", but got " + retrievedDocs + " documents form the index.", EXPECTED_DOC_COUNTS[i], retrievedDocs); } }