Added DocBits length test.

Change-Id: I1b5e98088dcdc881e6c4c5c801b5decccaae8392
diff --git a/Changes b/Changes
index 9ed843c..d48d3ac 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.58.0 2018-08-23
+0.58.0 2018-09-03
     - [feature] Implemented referencing cached collection (margaretha)
     - [feature] Implemented deserialization of collection with array values
       and cache option (margaretha)
@@ -18,6 +18,8 @@
     - [cleanup] Move caching mechanism to toFilter() phase (diewald)
     - [cleanup] Rewrite test suite for caching to be part of
       regular test suite (diewald)
+    - [bugfix] Fixed missing docs in VC cache (margaretha)
+    
 
 0.57 2018-04-05
     - [feature] Support text queries in metadata
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestDocBits.java b/src/test/java/de/ids_mannheim/korap/collection/TestDocBits.java
new file mode 100644
index 0000000..300a4f1
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestDocBits.java
@@ -0,0 +1,38 @@
+package de.ids_mannheim.korap.collection;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.util.BitDocIdSet;
+import org.apache.lucene.util.FixedBitSet;
+import org.junit.Test;
+
+import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.KrillIndex;
+import de.ids_mannheim.korap.util.QueryException;
+
+public class TestDocBits {
+
+    private KrillIndex ki;
+
+    @Test
+    public void testRecreatedDocBitsLength () throws IOException, QueryException {
+        ki = new KrillIndex();
+        ki.addDoc(TestKrillCollectionIndex.createDoc1());
+        ki.addDoc(TestKrillCollectionIndex.createDoc2());
+        ki.addDoc(TestKrillCollectionIndex.createDoc3());
+        ki.commit();
+
+        KrillCollection kc = new KrillCollection();
+        List<LeafReaderContext> leaves = this.ki.reader().leaves();
+        for (LeafReaderContext context : leaves) {
+            FixedBitSet bitset = kc.bits(context);
+            DocBits docBits = new DocBits(bitset.getBits(), bitset.length());
+            BitDocIdSet bitDocIdSet = docBits.createBitDocIdSet();
+            assertEquals(bitset.length(), bitDocIdSet.bits().length());
+        }
+    }
+}
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
index 89009cc..ee33795 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
@@ -1380,7 +1380,7 @@
     
     
 
-    private FieldDocument createDoc1 () {
+    public static FieldDocument createDoc1 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("UID", "1");
         fd.addString("ID", "doc-1");
@@ -1394,7 +1394,7 @@
     };
 
 
-    private FieldDocument createDoc2 () {
+    public static FieldDocument createDoc2 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("UID", "2");
 		fd.addString("ID", "doc-2");
@@ -1408,7 +1408,7 @@
     };
 
 
-    private FieldDocument createDoc3 () {
+    public static FieldDocument createDoc3 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("UID", "3");
 		fd.addString("ID", "doc-3");