### Question:
DirectoryReferenceCounter extends Directory { private IndexInput wrap(String name, IndexInput input) { AtomicInteger counter = refs.get(name); if (counter == null) { counter = new AtomicInteger(); refs.put(name, counter); } return new RefIndexInput(input, counter); } DirectoryReferenceCounter(Directory directory, DirectoryReferenceFileGC gc); void deleteFile(String name); IndexOutput createOutput(String name); IndexInput openInput(String name); IndexInput openInput(String name, int bufferSize); @SuppressWarnings("deprecation") void touchFile(String name); @SuppressWarnings("deprecation") void sync(String name); void sync(Collection<String> names); void clearLock(String name); void close(); void setLockFactory(LockFactory lockFactory); String getLockID(); void copy(Directory to, String src, String dest); boolean fileExists(String name); @SuppressWarnings("deprecation") long fileModified(String name); long fileLength(String name); LockFactory getLockFactory(); String[] listAll(); Lock makeLock(String name); String toString();  }### Answer:
@Test public void testDirectoryReferenceCounterTestError() throws CorruptIndexException, IOException { Directory directory = wrap(new RAMDirectory()); IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_36, new KeywordAnalyzer()); IndexWriter writer = new IndexWriter(directory, conf); int size = 100; IndexReader[] readers = new IndexReader[size]; for (int i = 0; i < size; i++) { writer.addDocument(getDoc()); readers[i] = IndexReader.open(writer, true); writer.forceMerge(1); } try { for (int i = 0; i < size; i++) { checkReader(readers[i], i); } fail(); } catch (Exception e) { } }