Updated KorapClientTest.

Change-Id: I400ae1a5c48eaa700a7a76e68107d2d6fff5fd3e
diff --git a/src/test/java/de/ids_mannheim/korap/test/KorapClientTest.java b/src/test/java/de/ids_mannheim/korap/test/KorapClientTest.java
index 341f91d..30b5ec3 100644
--- a/src/test/java/de/ids_mannheim/korap/test/KorapClientTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/KorapClientTest.java
@@ -14,79 +14,99 @@
 import de.ids_mannheim.korap.sru.KorapResult;
 import de.ids_mannheim.korap.sru.QueryLanguage;
 
-
 /**
  * The tests are based on the sample corpus from the Goethe corpus.
  * 
  * @author margaretha
  *
  */
-public class KorapClientTest {
+public class KorapClientTest extends BaseTest {
     private KorapClient c;
     private KorapResult result;
     private KorapMatch match;
-    
+
     public KorapClientTest () {
-        c = new KorapClient("http://localhost:1080/api/v1.0", 25, 50);
+        c = new KorapClient("http://localhost:1080", 25, 50);
     }
 
     @Test
     public void testCQLQuery () throws HttpResponseException, IOException {
-        
-        
-        result = c.query("der", QueryLanguage.CQL, "1.2", 1, 1,
-                null);
+
+        createExpectationForSearch("der", "cql", "1.2", "50",
+                "search-der.jsonld");
+
+        result = c.query("der", QueryLanguage.CQL, "1.2", 51, 1, null);
         assertEquals(1, result.getMatchSize());
         assertEquals(1858, result.getTotalResults());
-    
+
         match = result.getMatch(0);
-        assertEquals("match-GOE/AGA/01784-p18-19",match.getMatchId());
-        
+        assertEquals("match-GOE/AGA/01784-p1856-1857", match.getMatchId());
+
         match.parseMatchId();
         assertEquals("GOE", match.getCorpusId());
         assertEquals("AGA", match.getDocId());
-        assertEquals("p18-19", match.getPositionId());
-        
+        assertEquals("p1856-1857", match.getPositionId());
+
     }
 
     @Test
-    public void testFCS2Query() throws HttpResponseException, IOException {
-    	result = c.query("(\"blaue\"|\"grüne\")", QueryLanguage.FCSQL, "2.0", 1,
-                25, null);
-    	
-    	assertEquals(25, result.getMatchSize());
+    public void testOrQuery () throws HttpResponseException, IOException {
+
+        createExpectationForSearch("(\"blaue\"|\"grüne\")", "fcsql", "2.0", "0",
+                "search-or.jsonld");
+
+        createExpectationForMatchInfo("GOE-AGF-00000-p7744-7745.jsonld",
+                "/corpus/GOE/AGF/00000/p7744-7745/matchInfo");
+
+        result = c.query("(\"blaue\"|\"grüne\")", QueryLanguage.FCSQL, "2.0", 1,
+                1, null);
+
+        assertEquals(1, result.getMatchSize());
         assertEquals(55, result.getTotalResults());
 
         match = result.getMatch(0);
-        assertEquals("match-GOE/AGF/00000-p7744-7745",match.getMatchId());
-        
+        assertEquals("match-GOE/AGF/00000-p7744-7745", match.getMatchId());
+
         match.parseMatchId();
         assertEquals("GOE", match.getCorpusId());
         assertEquals("AGF", match.getDocId());
         assertEquals("p7744-7745", match.getPositionId());
-	}
-    
+    }
+
     @Test
-    public void testRetrieveAnnotations() throws IOException, URISyntaxException {
-    	String annotationSnippet = c.retrieveAnnotations(
-    			"GOE", "AGF", "00000",
-    			"p7667-7668", "*");
-    	
-    	assertEquals(true, annotationSnippet.startsWith("<snippet><span class="
-    			+ "\"context-left\"></span><span class=\"match\"><span title="));
-	}
-    
+    public void testRetrieveAnnotations ()
+            throws IOException, URISyntaxException {
+        createExpectationForMatchInfo("GOE-AGF-00000-p4276-4277.jsonld",
+                "/corpus/GOE/AGF/00000/p4276-4277/matchInfo");
+
+        String annotationSnippet =
+                c.retrieveAnnotations("GOE", "AGF", "00000", "p4276-4277", "*");
+
+        assertEquals(
+                "<snippet><span class=\"context-left\"><span class=\"more\">"
+                        + "</span></span><span class=\"match\"><mark>feineren</mark>"
+                        + "</span><span class=\"context-right\"><span class=\"more\">"
+                        + "</span></span></snippet>",
+                annotationSnippet);
+    }
+
     @Test
-    public void testRetrieveNonexistingAnnotation() throws IOException, URISyntaxException {
-    	String annotationSnippet = c.retrieveAnnotations(
-    			"WPD15", "D18", "06488",
-    			"p588-589", "*");
-    	
-    	assertEquals("<snippet></snippet>", annotationSnippet);
-	}
-    
+    public void testRetrieveNonexistingAnnotation ()
+            throws IOException, URISyntaxException {
+
+        createExpectationForMatchInfo("unknownMatchInfo.jsonld",
+                "/corpus/WPD15/D18/06488/p588-589/matchInfo");
+
+        String annotationSnippet =
+                c.retrieveAnnotations("WPD15", "D18", "06488", "p588-589", "*");
+
+        assertEquals("<snippet></snippet>", annotationSnippet);
+    }
+
     @Test
-    public void testRetrieveResource () throws HttpResponseException, Exception {
+    public void testRetrieveResource ()
+            throws HttpResponseException, Exception {
+        createRetrieveResource();
         KorapResource[] resources = c.retrieveResources();
         assertEquals(3, resources.length);
         assertEquals("WPD17", resources[0].getResourceId());