Buggy code:
public class TestDocValuesIndexing extends LuceneTestCase { public void testDocValuesSimple ( ) throws IOException { Directory dir = newDirectory ( ) ; IndexWriter writer = new IndexWriter ( dir , writerConfig ( false ) ) ; for ( int i = 0 ; i < 5 ; i ++ ) { Document doc = new Document ( ) ; doc . add ( new PackedLongDocValuesField ( "docId" , i ) ) ; doc . add ( new org . apache . lucene . document . TextField ( "docId" , ( "" + i ) , Store . NO ) ) ; writer . addDocument ( doc ) ; } writer . commit ( ) ; writer . forceMerge ( 1 , true ) ; writer . close ( true ) ; DirectoryReader reader = DirectoryReader . open ( dir , 1 ) ; <START_BUG> assertEquals ( 1 , reader . getSequentialSubReaders ( ) . size ( ) ) ; <END_BUG> IndexSearcher searcher = new IndexSearcher ( reader ) ; BooleanQuery query = new BooleanQuery ( ) ; query . add ( new org . apache . lucene . search . TermQuery ( new Term ( "docId" , "0" ) ) , SHOULD ) ; query . add ( new org . apache . lucene . search . TermQuery ( new Term ( "docId" , "1" ) ) , SHOULD ) ; query . add ( new org . apache . lucene . search . TermQuery ( new Term ( "docId" , "2" ) ) , SHOULD ) ; query . add ( new org . apache . lucene . search . TermQuery ( new Term ( "docId" , "3" ) ) , SHOULD ) ; query . add ( new org . apache . lucene . search . TermQuery ( new Term ( "docId" , "4" ) ) , SHOULD ) ; TopDocs search = searcher . search ( query , 10 ) ; assertEquals ( 5 , search . totalHits ) ; ScoreDoc [ ] scoreDocs = search . scoreDocs ; DocValues docValues = MultiDocValues . getDocValues ( reader , "docId" ) ; Source source = docValues . getSource ( ) ; for ( int i = 0 ; i < ( scoreDocs . length ) ; i ++ ) { assertEquals ( i , scoreDocs [ i ] . doc ) ; assertEquals ( i , source . getInt ( scoreDocs [ i ] . doc ) ) ; } reader . close ( ) ; dir . close ( ) ; } public void testIndexBytesNoDeletes ( ) throws IOException { } public void testIndexBytesDeletes ( ) throws IOException { } public void testIndexNumericsNoDeletes ( ) throws IOException { } public void testIndexNumericsDeletes ( ) throws IOException { } public void testAddIndexes ( ) throws IOException { } public void testAddIndexesRandom ( ) throws IOException { } private IndexWriterConfig writerConfig ( boolean useCompoundFile ) { } @ SuppressWarnings ( "fallthrough" ) public void runTestNumerics ( IndexWriterConfig cfg , boolean withDeletions ) throws IOException { } public void runTestIndexBytes ( IndexWriterConfig cfg , boolean withDeletions ) throws IOException { } public void testGetArrayNumerics ( ) throws IOException { } public void testGetArrayBytes ( ) throws IOException { } private DocValues getDocValues ( IndexReader reader , String field ) throws IOException { } @ SuppressWarnings ( "fallthrough" ) private Source getSource ( DocValues values ) throws IOException { } private static EnumSet < Type > BYTES = EnumSet . of ( BYTES_FIXED_DEREF , BYTES_FIXED_STRAIGHT , BYTES_VAR_DEREF , BYTES_VAR_STRAIGHT , BYTES_FIXED_SORTED , BYTES_VAR_SORTED ) ; private static EnumSet < Type > NUMERICS = EnumSet . of ( VAR_INTS , FIXED_INTS_16 , FIXED_INTS_32 , FIXED_INTS_64 , FIXED_INTS_8 , FLOAT_32 , FLOAT_64 ) ; private FixedBitSet indexValues ( IndexWriter w , int numValues , Type valueType , List < Type > valueVarList , boolean withDeletions , int bytesSize ) throws IOException { } public void testMultiValuedDocValuesField ( ) throws Exception { } public void testDifferentTypedDocValuesField ( ) throws Exception { } public void testSortedBytes ( ) throws IOException { } public int docId ( AtomicReader reader , Term term ) throws IOException { } public void testWithThreads ( ) throws Exception { } public void testLengthPrefixAcrossTwoPages ( ) throws Exception { } public void testFixedLengthNotReallyFixed ( ) throws IOException { } }

Fix:
assertEquals ( 1 , reader . leaves ( ) . size ( ) ) ;