Updated URLs in readme and added a request test with FCSQL.
Change-Id: If294ee17d1e75b09ddc32309a4f62e170fda6bc3
diff --git a/src/main/java/de/mannheim/ids/korap/sru/Annotation.java b/src/main/java/de/ids_mannheim/korap/sru/Annotation.java
similarity index 95%
rename from src/main/java/de/mannheim/ids/korap/sru/Annotation.java
rename to src/main/java/de/ids_mannheim/korap/sru/Annotation.java
index 7580ef6..7d714e5 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/Annotation.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/Annotation.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
/**
*
diff --git a/src/main/java/de/mannheim/ids/korap/sru/AnnotationHandler.java b/src/main/java/de/ids_mannheim/korap/sru/AnnotationHandler.java
similarity index 99%
rename from src/main/java/de/mannheim/ids/korap/sru/AnnotationHandler.java
rename to src/main/java/de/ids_mannheim/korap/sru/AnnotationHandler.java
index 3d23eb0..71196d1 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/AnnotationHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/AnnotationHandler.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/de/mannheim/ids/korap/sru/AnnotationLayer.java b/src/main/java/de/ids_mannheim/korap/sru/AnnotationLayer.java
similarity index 97%
rename from src/main/java/de/mannheim/ids/korap/sru/AnnotationLayer.java
rename to src/main/java/de/ids_mannheim/korap/sru/AnnotationLayer.java
index 10cdf53..aedd0f9 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/AnnotationLayer.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/AnnotationLayer.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import java.net.URI;
import java.util.HashMap;
diff --git a/src/main/java/de/mannheim/ids/korap/sru/FCSConstants.java b/src/main/java/de/ids_mannheim/korap/sru/FCSConstants.java
similarity index 96%
rename from src/main/java/de/mannheim/ids/korap/sru/FCSConstants.java
rename to src/main/java/de/ids_mannheim/korap/sru/FCSConstants.java
index d532e3f..5ba1cb0 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/FCSConstants.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/FCSConstants.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
public class FCSConstants {
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapClient.java b/src/main/java/de/ids_mannheim/korap/sru/KorapClient.java
similarity index 98%
rename from src/main/java/de/mannheim/ids/korap/sru/KorapClient.java
rename to src/main/java/de/ids_mannheim/korap/sru/KorapClient.java
index 359c7d7..5bb1776 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapClient.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/KorapClient.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
@@ -8,7 +8,6 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
@@ -38,9 +37,6 @@
public class KorapClient {
private String serviceUri;
- private static final String CONFIGURATION_FILE = "kustvakt.conf";
- private static final String SERVICE_URI_PROPERTY =
- "korapsru.client.service.uri";
private static final String DEFAULT_CONTEXT_TYPE = "sentence";
private static final String DEFAULT_FOUNDRY = "*";
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapEndpointDescription.java b/src/main/java/de/ids_mannheim/korap/sru/KorapEndpointDescription.java
similarity index 99%
rename from src/main/java/de/mannheim/ids/korap/sru/KorapEndpointDescription.java
rename to src/main/java/de/ids_mannheim/korap/sru/KorapEndpointDescription.java
index ee6a04a..1631075 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapEndpointDescription.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/KorapEndpointDescription.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import java.io.IOException;
import java.io.InputStream;
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapJsonQuery.java b/src/main/java/de/ids_mannheim/korap/sru/KorapJsonQuery.java
similarity index 98%
rename from src/main/java/de/mannheim/ids/korap/sru/KorapJsonQuery.java
rename to src/main/java/de/ids_mannheim/korap/sru/KorapJsonQuery.java
index 0483a12..6e87b7e 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapJsonQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/KorapJsonQuery.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
public class KorapJsonQuery {
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapMatch.java b/src/main/java/de/ids_mannheim/korap/sru/KorapMatch.java
similarity index 98%
rename from src/main/java/de/mannheim/ids/korap/sru/KorapMatch.java
rename to src/main/java/de/ids_mannheim/korap/sru/KorapMatch.java
index fd0c1c1..7b3253a 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapMatch.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/KorapMatch.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapMatchHandler.java b/src/main/java/de/ids_mannheim/korap/sru/KorapMatchHandler.java
similarity index 97%
rename from src/main/java/de/mannheim/ids/korap/sru/KorapMatchHandler.java
rename to src/main/java/de/ids_mannheim/korap/sru/KorapMatchHandler.java
index 39df47d..6773c13 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapMatchHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/KorapMatchHandler.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapMeta.java b/src/main/java/de/ids_mannheim/korap/sru/KorapMeta.java
similarity index 90%
rename from src/main/java/de/mannheim/ids/korap/sru/KorapMeta.java
rename to src/main/java/de/ids_mannheim/korap/sru/KorapMeta.java
index 2c29d99..f762c07 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapMeta.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/KorapMeta.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapResult.java b/src/main/java/de/ids_mannheim/korap/sru/KorapResult.java
similarity index 96%
rename from src/main/java/de/mannheim/ids/korap/sru/KorapResult.java
rename to src/main/java/de/ids_mannheim/korap/sru/KorapResult.java
index 95cf7f6..0991c6e 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapResult.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/KorapResult.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapSRU.java b/src/main/java/de/ids_mannheim/korap/sru/KorapSRU.java
similarity index 99%
rename from src/main/java/de/mannheim/ids/korap/sru/KorapSRU.java
rename to src/main/java/de/ids_mannheim/korap/sru/KorapSRU.java
index 616ddeb..42efb3a 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapSRU.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/KorapSRU.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import java.io.IOException;
import java.util.List;
diff --git a/src/main/java/de/mannheim/ids/korap/sru/KorapSRUSearchResultSet.java b/src/main/java/de/ids_mannheim/korap/sru/KorapSRUSearchResultSet.java
similarity index 99%
rename from src/main/java/de/mannheim/ids/korap/sru/KorapSRUSearchResultSet.java
rename to src/main/java/de/ids_mannheim/korap/sru/KorapSRUSearchResultSet.java
index db78ca2..c76bf6a 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/KorapSRUSearchResultSet.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/KorapSRUSearchResultSet.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
import java.io.ByteArrayInputStream;
import java.io.IOException;
diff --git a/src/main/java/de/mannheim/ids/korap/sru/QueryLanguage.java b/src/main/java/de/ids_mannheim/korap/sru/QueryLanguage.java
similarity index 77%
rename from src/main/java/de/mannheim/ids/korap/sru/QueryLanguage.java
rename to src/main/java/de/ids_mannheim/korap/sru/QueryLanguage.java
index 7bccd81..f987505 100644
--- a/src/main/java/de/mannheim/ids/korap/sru/QueryLanguage.java
+++ b/src/main/java/de/ids_mannheim/korap/sru/QueryLanguage.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.sru;
+package de.ids_mannheim.korap.sru;
public enum QueryLanguage {
CQL, FCSQL;
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index 310893a..a8b155d 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -1,5 +1,5 @@
-#log4j.rootLogger = ERROR, stdout
-log4j.rootLogger = DEBUG, stdout
+log4j.rootLogger = ERROR, stdout
+#log4j.rootLogger = DEBUG, stdout
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
diff --git a/src/test/java/de/ids_mannheim/korap/test/FCSQLRequestTest.java b/src/test/java/de/ids_mannheim/korap/test/FCSQLRequestTest.java
new file mode 100644
index 0000000..4006019
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/test/FCSQLRequestTest.java
@@ -0,0 +1,85 @@
+package de.ids_mannheim.korap.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.http.NameValuePair;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * The tests in this class requires running KustvaktServer and KorAPSRU.
+ * The results are based on the sample corpus from the Goethe corpus.
+ *
+ * Specify the Kustvakt service URI at
+ * /KorapSRU/src/main/webapp/WEB-INF/web.xml
+ *
+ * @author margaretha
+ *
+ */
+public class FCSQLRequestTest {
+
+ private String korapSruUri = "http://localhost:8080/KorapSRU";
+ private static DocumentBuilder documentBuilder;
+
+ @BeforeClass
+ public static void setDocumentBuilder ()
+ throws ParserConfigurationException {
+ DocumentBuilderFactory documentBuilderFactory =
+ DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ }
+
+ @Test
+ public void testFCSQuery () throws URISyntaxException, IOException,
+ SAXException, ParserConfigurationException {
+ List<NameValuePair> params = new ArrayList<NameValuePair>();
+ params.add(new BasicNameValuePair("operation", "startRetrieve"));
+ params.add(new BasicNameValuePair("query", "[tt:lemma=\".*bar\"]"));
+ params.add(new BasicNameValuePair("queryType", "fcs"));
+
+ URIBuilder builder = new URIBuilder(korapSruUri);
+ builder.addParameters(params);
+
+ URI uri = builder.build();
+ assertEquals(
+ "http://localhost:8080/KorapSRU?operation=startRetrieve&query=%5Btt%3Alemma%3D%22.*bar%22%5D&queryType=fcs",
+ uri.toString());
+
+ HttpGet request = new HttpGet(uri);
+ CloseableHttpClient client = HttpClients.createDefault();
+ CloseableHttpResponse response = null;
+ response = client.execute(request);
+
+ assertEquals(200, response.getStatusLine().getStatusCode());
+
+ InputStream is = response.getEntity().getContent();
+ Document document = documentBuilder.parse(is);
+ NodeList nodeList =
+ document.getElementsByTagName("sruResponse:numberOfRecords");
+
+ assertEquals("134", nodeList.item(0).getTextContent());
+ response.close();
+ }
+
+}
diff --git a/src/test/java/de/mannheim/ids/korap/test/KorapClientTest.java b/src/test/java/de/ids_mannheim/korap/test/KorapClientTest.java
similarity index 85%
rename from src/test/java/de/mannheim/ids/korap/test/KorapClientTest.java
rename to src/test/java/de/ids_mannheim/korap/test/KorapClientTest.java
index 93aea30..26e3311 100644
--- a/src/test/java/de/mannheim/ids/korap/test/KorapClientTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/KorapClientTest.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.test;
+package de.ids_mannheim.korap.test;
import static org.junit.Assert.assertEquals;
@@ -11,20 +11,20 @@
import com.fasterxml.jackson.databind.JsonNode;
-import de.mannheim.ids.korap.sru.KorapClient;
-import de.mannheim.ids.korap.sru.KorapMatch;
-import de.mannheim.ids.korap.sru.KorapResult;
-import de.mannheim.ids.korap.sru.QueryLanguage;
+import de.ids_mannheim.korap.sru.KorapClient;
+import de.ids_mannheim.korap.sru.KorapMatch;
+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.
- * Skip the tests if Kustvakt does not have this corpus in the Krill
- * index.
*
* The tests require a running KustvaktServer.
- * Specify the Kustvakt service URI in the configuration file at
- * src/main/resources/kustvakt.conf.
+ * Specify the Kustvakt service URI at
+ * /KorapSRU/src/main/webapp/WEB-INF/web.xml
+ *
+ * and in the initialization of KorapClient in the code below.
*
* @author margaretha
*
@@ -33,6 +33,10 @@
private KorapClient c;
private KorapResult result;
private KorapMatch match;
+
+ public KorapClientTest () {
+ c = new KorapClient("http://localhost:8089/api/", 25, 50);
+ }
@Test
public void testCQLQuery () throws HttpResponseException, IOException {
diff --git a/src/test/java/de/mannheim/ids/korap/test/KorapSRUTest.java b/src/test/java/de/ids_mannheim/korap/test/KorapSRUTest.java
similarity index 96%
rename from src/test/java/de/mannheim/ids/korap/test/KorapSRUTest.java
rename to src/test/java/de/ids_mannheim/korap/test/KorapSRUTest.java
index 459aabb..b5b6c1c 100644
--- a/src/test/java/de/mannheim/ids/korap/test/KorapSRUTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/KorapSRUTest.java
@@ -1,4 +1,4 @@
-package de.mannheim.ids.korap.test;
+package de.ids_mannheim.korap.test;
import static org.junit.Assert.assertEquals;
@@ -25,12 +25,10 @@
/**
* The tests are based on the sample corpus from the Goethe corpus.
- * Skip the tests if Kustvakt does not have this corpus in the Krill
- * index.
*
* The tests require a running KustvaktServer.
- * Specify the Kustvakt service URI in the configuration file at
- * src/main/resources/kustvakt.conf.
+ * Specify the Kustvakt service URI at
+ * /KorapSRU/src/main/webapp/WEB-INF/web.xml
*
* @author margaretha
*
@@ -112,7 +110,7 @@
node = node.getFirstChild();
attr = node.getAttributes().getNamedItem("id").getNodeValue();
- assertEquals("http://clarin.ids-mannheim.de/korapsru/layers/pos2", attr);
+ assertEquals("http://clarin.ids-mannheim.de/korapsru/layers/text", attr);
// assertEquals(50, node.getChildNodes().getLength());
}