Catch null reference in case no vc cache is defined

Change-Id: I6dda338e03e46030f2b6d2741cef73d9e1bbf71d
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index 48cf842..7ebb4f7 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -366,7 +366,8 @@
         this.writer().commit();
         commitCounter = 0;
         this.closeReader();
-        KrillCollection.cache.removeAll();
+        if (KrillCollection.cache != null)
+            KrillCollection.cache.removeAll();
     };
 
 
diff --git a/src/test/resources/ehcache.xml b/src/main/resources/ehcache.xml
similarity index 100%
rename from src/test/resources/ehcache.xml
rename to src/main/resources/ehcache.xml
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestCollectionCache.java b/src/test/java/de/ids_mannheim/korap/collection/TestCollectionCache.java
new file mode 100644
index 0000000..5591494
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestCollectionCache.java
@@ -0,0 +1,24 @@
+package de.ids_mannheim.korap.collection;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.KrillIndex;
+import de.ids_mannheim.korap.index.FieldDocument;
+
+public class TestCollectionCache {
+
+    @Test
+    public void testNullCache() throws IOException{
+        assertTrue(KrillCollection.cache != null);
+        
+        KrillCollection.cache = null;
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(new FieldDocument());
+        ki.commit();
+    }
+}
diff --git a/src/test/resources/krill.properties b/src/test/resources/krill.properties
index a6302b6..ea60670 100644
--- a/src/test/resources/krill.properties
+++ b/src/test/resources/krill.properties
@@ -1,4 +1,5 @@
 krill.version = ${project.version}
 krill.name = ${project.name}
 krill.indexDir = test-output
-krill.namedVC = vc
\ No newline at end of file
+krill.namedVC = vc
+krill.index.commit.count = 15
\ No newline at end of file