Added testKrillCollectionWithWrongJson.
Change-Id: Ia37b3f8c7e25fb1207960d3a5f6bb69c6008accc
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 9ec99c2..1361e61 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
@@ -11,21 +11,17 @@
import de.ids_mannheim.korap.response.SearchContext;
import de.ids_mannheim.korap.Krill;
-import de.ids_mannheim.korap.KrillQuery;
import de.ids_mannheim.korap.query.QueryBuilder;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.index.Term;
-import org.apache.lucene.search.spans.SpanOrQuery;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
-import org.apache.lucene.search.spans.SpanQuery;
import static org.junit.Assert.*;
import org.junit.Test;
-import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -35,6 +31,34 @@
@Test
+ public void testKrillCollectionWithWrongJson () throws IOException {
+ ki = new KrillIndex();
+ ki.addDoc(createDoc1());
+ ki.addDoc(createDoc2());
+ ki.addDoc(createDoc3());
+ ki.commit();
+
+ KrillCollection kc = new KrillCollection("{lalala}");
+ kc.setIndex(ki);
+ long docs = 0, tokens = 0, sentences = 0, paragraphs = 0;
+ try {
+ docs = kc.numberOf("documents");
+ tokens = kc.numberOf("tokens");
+ sentences = kc.numberOf("sentences");
+ paragraphs = kc.numberOf("paragraphs");
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertEquals(0, docs);
+ assertEquals(0, tokens);
+ assertEquals(0, sentences);
+ assertEquals(0, paragraphs);
+
+ }
+
+
+ @Test
public void testIndexWithCollectionBuilder () throws IOException {
ki = new KrillIndex();
ki.addDoc(createDoc1());
@@ -57,7 +81,7 @@
kcn.fromBuilder(cb.term("author", "Michael"));
assertEquals(0, kcn.docCount());
- kcn.fromBuilder(cb.term("nothing", "nothing"));
+ kcn.fromBuilder(cb.term("nothing", "nothing"));
assertEquals(0, kcn.docCount());
kcn.fromBuilder(cb.term("textClass", "reisen"));
@@ -433,7 +457,8 @@
assertEquals("Paragraphs", 130, kc.numberOf("paragraphs"));
};
- @Test
+
+ @Test
public void filterExampleWithNullresult () throws Exception {
// Construct index
@@ -441,7 +466,7 @@
// Indexing test files
for (String i : new String[] { "00001", "00002" }) {
ki.addDoc(getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
- true);
+ true);
};
ki.commit();
@@ -456,7 +481,8 @@
assertEquals("Tokens", 0, kc.numberOf("tokens"));
assertEquals("Sentences", 0, kc.numberOf("sentences"));
assertEquals("Paragraphs", 0, kc.numberOf("paragraphs"));
- };
+ };
+
@Test
public void filterExampleAtomicLegacy () throws Exception {