writer.addDocument(docs[0]);
writer.optimize();
writer.commit();
IndexReader idxReader = IndexReader.open(idxDir,true);
BoboIndexReader boboReader = BoboIndexReader.getInstance(idxReader,_fconf);
for (int i=1;i<docs.length;++i){
Document doc = docs[i];
int numDocs = boboReader.numDocs();
BoboIndexReader reader = (BoboIndexReader)boboReader.reopen(true);
assertSame(boboReader,reader);
Directory tmpDir = new RAMDirectory();
IndexWriter subWriter = new IndexWriter(tmpDir,new StandardAnalyzer(Version.LUCENE_29),MaxFieldLength.UNLIMITED);
subWriter.addDocument(doc);
subWriter.optimize();
subWriter.close();
writer.addIndexesNoOptimize(new Directory[]{tmpDir});
writer.commit();
reader = (BoboIndexReader)boboReader.reopen();
assertNotSame(boboReader, reader);
assertEquals(numDocs+1,reader.numDocs());
boboReader = reader;
}
writer.deleteDocuments(new Term("id","1"));
writer.commit();
int numDocs = boboReader.numDocs();
BoboIndexReader newReader = (BoboIndexReader)boboReader.reopen();
assertNotSame(newReader,boboReader);
int numDocs2 = newReader.numDocs();
if (boboReader!=newReader){
boboReader.close();
boboReader = newReader;
}
assertEquals(numDocs-1,numDocs2);