You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2011/08/23 20:18:39 UTC

svn commit: r1160832 - /lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java

Author: mikemccand
Date: Tue Aug 23 18:18:39 2011
New Revision: 1160832

URL: http://svn.apache.org/viewvc?rev=1160832&view=rev
Log:
add CFS test case

Modified:
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java?rev=1160832&r1=1160831&r2=1160832&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java Tue Aug 23 18:18:39 2011
@@ -767,4 +767,41 @@ public class TestCompoundFile extends Lu
     newDir.close();
     
   }
+
+  // Make sure we don't somehow use more than 1 descriptor
+  // when reading a CFS with many subs:
+  public void testManySubFiles() throws IOException {
+
+    final Directory d = newFSDirectory(_TestUtil.getTempDir("CFSManySubFiles"));
+    final int FILE_COUNT = 10000;
+
+    for(int fileIdx=0;fileIdx<FILE_COUNT;fileIdx++) {
+      IndexOutput out = d.createOutput("file." + fileIdx, newIOContext(random));
+      out.writeByte((byte) fileIdx);
+      out.close();
+    }
+    
+    final CompoundFileDirectory cfd = d.createCompoundOutput("c.cfs", newIOContext(random));
+    for(int fileIdx=0;fileIdx<FILE_COUNT;fileIdx++) {
+      final String fileName = "file." + fileIdx;
+      d.copy(cfd, fileName, fileName, newIOContext(random));
+    }
+    cfd.close();
+
+    final IndexInput[] ins = new IndexInput[FILE_COUNT];
+    final CompoundFileDirectory cfr = d.openCompoundInput("c.cfs", newIOContext(random));
+    for(int fileIdx=0;fileIdx<FILE_COUNT;fileIdx++) {
+      ins[fileIdx] = cfr.openInput("file." + fileIdx, newIOContext(random));
+    }
+
+    for(int fileIdx=0;fileIdx<FILE_COUNT;fileIdx++) {
+      assertEquals((byte) fileIdx, ins[fileIdx].readByte());
+    }
+
+    for(int fileIdx=0;fileIdx<FILE_COUNT;fileIdx++) {
+      ins[fileIdx].close();
+    }
+    cfr.close();
+    d.close();
+  }
 }