Test KeywordAnalyzer

Change-Id: Iacf651723a46e78a8a7ab8eb0a781d611a9f81c3
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestKeywordAnalyzer.java b/src/test/java/de/ids_mannheim/korap/index/TestKeywordAnalyzer.java
new file mode 100644
index 0000000..c575450
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/index/TestKeywordAnalyzer.java
@@ -0,0 +1,46 @@
+package de.ids_mannheim.korap.index;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.StringReader;
+import java.io.IOException;
+
+import de.ids_mannheim.korap.index.KeywordAnalyzer;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+
+@RunWith(JUnit4.class)
+public class TestKeywordAnalyzer {
+
+	@Test
+	public void keywordAnalyzer () throws IOException {
+
+		StringReader reader = new StringReader("alpha beta gamma");
+		
+		KeywordAnalyzer kwa = new KeywordAnalyzer();
+		TokenStream ts = kwa.tokenStream("keys", reader);
+		ts.reset();
+
+		assertTrue(ts.incrementToken());
+		CharTermAttribute term = ts.getAttribute(CharTermAttribute.class);
+
+		assertEquals(term.toString(), "alpha");
+		assertTrue(ts.incrementToken());
+		term = ts.getAttribute(CharTermAttribute.class);
+		assertEquals(term.toString(), "beta");
+
+		assertTrue(ts.incrementToken());
+		term = ts.getAttribute(CharTermAttribute.class);
+		assertEquals(term.toString(), "gamma");
+
+		assertTrue(!ts.incrementToken());
+	};
+};