merge conflict resolution
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java b/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
index ff3679d..0deb98b 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
@@ -8,8 +8,12 @@
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.web.SearchKrill;
+
+import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
@@ -18,13 +22,11 @@
*/
public class SearchKrillTest extends BeanConfigTest {
-
@Override
public void initMethod () throws KustvaktException {
}
-
@Test
public void testInit () {
KustvaktConfiguration config = helper().getContext().getConfiguration();
@@ -57,8 +59,7 @@
@Test
public void testSearch () {
QuerySerializer s = new QuerySerializer();
- s.setQuery("[orth=das]", "poliqarp");
-
+ s.setQuery("[orth=der]", "poliqarp");
KustvaktConfiguration config = helper().getContext().getConfiguration();
SearchKrill krill = new SearchKrill(config.getIndexDir());
@@ -67,7 +68,6 @@
JsonNode node = JsonUtils.readTree(result);
assertNotNull(node);
assertNotEquals(0, node.at("/matches").size());
-
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
index b394d68..47771b1 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
@@ -51,6 +51,31 @@
}
+
+ @Test
+ public void testOpenIDLogin () {
+
+ }
+
+
+ @Test
+ public void testOpenIDLogout () {
+
+ }
+
+
+ // -- are these even right? auth - authorization
+ @Test
+ public void testOAuth2Login () {
+
+ }
+
+
+ @Test
+ public void testOAuth2Logout () {
+
+ }
+
//todo: test basicauth via secure connection
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
index 039593e..7712e1b 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.sun.jersey.api.client.ClientResponse;
import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.security.auth.BasicHttpAuth;
import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.utils.JsonUtils;
@@ -11,6 +12,8 @@
import org.junit.Ignore;
import org.junit.Test;
+import java.util.Iterator;
+
import static org.junit.Assert.*;
/**
@@ -28,11 +31,11 @@
@Test
- public void testSearchSimple () {
+ public void testSearchSimpleAuthorized () {
ClientResponse response = resource()
.path(getAPIVersion())
.path("search")
- .queryParam("q", "[orth=das]")
+ .queryParam("q", "[orth=die]")
.queryParam("ql", "poliqarp")
.header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
@@ -42,13 +45,112 @@
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
assertNotNull(node);
- System.out.println("NODE " + node);
assertNotEquals(0, node.path("matches").size());
}
@Test
- public void testCollectionGet () {
+ public void testSearchSimpleWithCQAuthorized () {
+ ClientResponse response = resource()
+ .path(getAPIVersion())
+ .path("search")
+ .queryParam("q", "[orth=das]")
+ .queryParam("ql", "poliqarp")
+ .queryParam("cq", "textClass=politik && corpusSigle=WPD")
+ .header(Attributes.AUTHORIZATION,
+ BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
+ .get(ClientResponse.class);
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
+
+ JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
+ assertNotNull(node);
+
+ }
+
+
+ @Test
+ public void testSearchSimpleDemo () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("search").queryParam("q", "[orth=der]")
+ .queryParam("ql", "poliqarp").get(ClientResponse.class);
+ assertEquals(response.getStatus(),
+ ClientResponse.Status.OK.getStatusCode());
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertNotEquals(0, node.path("matches").size());
+ }
+
+
+ @Test
+ public void testSearchSentenceMeta () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("search").queryParam("q", "[orth=der]")
+ .queryParam("ql", "poliqarp").queryParam("context", "sentence")
+ .get(ClientResponse.class);
+ assertEquals(response.getStatus(),
+ ClientResponse.Status.OK.getStatusCode());
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertNotEquals(0, node.path("matches").size());
+ assertEquals("base/s:s", node.at("/meta/context").asText());
+ assertNotEquals("${project.version}", "/meta/version");
+ }
+
+
+ @Test
+ public void testSearchSimpleCQL () {
+ QuerySerializer s = new QuerySerializer();
+ s.setQuery("(der) or (das)", "CQL");
+
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("search").post(ClientResponse.class, s.toJSON());
+ assertEquals(response.getStatus(),
+ ClientResponse.Status.OK.getStatusCode());
+ String ent = response.getEntity(String.class);
+
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertNotEquals(0, node.path("matches").size());
+ }
+
+
+ @Test
+ public void testSearchRawQuery () {
+ QuerySerializer s = new QuerySerializer();
+ s.setQuery("[orth=der]", "poliqarp");
+ // s.setCollection("corpusSigle=WPD");
+
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("search").post(ClientResponse.class, s.toJSON());
+ assertEquals(response.getStatus(),
+ ClientResponse.Status.OK.getStatusCode());
+ String ent = response.getEntity(String.class);
+
+
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertNotEquals(0, node.path("matches").size());
+ }
+
+
+ @Test
+ public void testCollectionsGetPublic () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("collection").get(ClientResponse.class);
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
+
+ JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
+ assertNotNull(node);
+ assertNotEquals(0, node.size());
+ }
+
+
+ @Test
+ public void testCollectionsGet () {
ClientResponse response = resource()
.path(getAPIVersion())
.path("collection")
@@ -59,11 +161,40 @@
response.getStatus());
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
+ assertNotNull(node);
assertNotEquals(0, node.size());
}
@Test
+ public void testCorporaGet () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("corpus").get(ClientResponse.class);
+ assertEquals(response.getStatus(),
+ ClientResponse.Status.OK.getStatusCode());
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertNotEquals(0, node.size());
+ }
+
+
+ @Test
+ public void testFoundriesGet () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("foundry").get(ClientResponse.class);
+ assertEquals(response.getStatus(),
+ ClientResponse.Status.OK.getStatusCode());
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertNotEquals(0, node.size());
+ }
+
+
+ // create a simple test collection for user kustvakt, otherwise test fails
+ @Test
+ @Ignore
public void testStats () {
ClientResponse response = resource()
.path(getAPIVersion())
@@ -77,8 +208,7 @@
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
assertNotNull(node);
assertNotEquals(0, node.size());
-
- String id = node.path(0).path("id").asText();
+ String id = node.path(1).path("id").asText();
response = resource()
.path(getAPIVersion())
@@ -93,6 +223,7 @@
response.getStatus());
node = JsonUtils.readTree(response.getEntity(String.class));
assertNotNull(node);
+ assertNotNull(node);
int docs = node.path("documents").asInt();
assertNotEquals(0, docs);
assertTrue(docs < 15);
@@ -100,6 +231,46 @@
@Test
+ public void testCollecionGet () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("collection").path("id").get(ClientResponse.class);
+ assertEquals(response.getStatus(),
+ ClientResponse.Status.OK.getStatusCode());
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertNotEquals(0, node.size());
+
+ }
+
+
+ @Test
+ public void testCorpusGet () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("corpus").path("id").get(ClientResponse.class);
+ assertEquals(response.getStatus(),
+ ClientResponse.Status.OK.getStatusCode());
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertNotEquals(0, node.size());
+ }
+
+
+ @Test
+ public void testFoundryGet () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("foundry").path("id").get(ClientResponse.class);
+ assertEquals(response.getStatus(),
+ ClientResponse.Status.OK.getStatusCode());
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertNotEquals(0, node.size());
+ }
+
+
+ @Test
public void testResourceStore () {
}
@@ -112,26 +283,99 @@
@Test
- @Ignore
- public void testSerializationQueryInCollection () {
+ public void testSerializationQueryWithCorpusUnAuthorized () {
ClientResponse response = resource().path(getAPIVersion())
- .path("corpus/WPD/search").queryParam("q", "[base=Haus]")
+ .path("corpus/WPD/search").queryParam("q", "[orth=der]")
.queryParam("ql", "poliqarp").queryParam("context", "base/s:s")
.method("TRACE", ClientResponse.class);
- assertEquals(response.getStatus(),
- ClientResponse.Status.OK.getStatusCode());
- System.out.println("RESPONSE 1 " + response);
+ assertEquals(ClientResponse.Status.BAD_REQUEST.getStatusCode(),
+ response.getStatus());
String ent = response.getEntity(String.class);
- System.out.println("Entity 1 " + ent);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertEquals(401, node.at("/errors/0/0").asInt());
}
@Test
- public void testSerializationQueryPublic () {
- ClientResponse response = resource().path(getAPIVersion())
- .path("search").queryParam("q", "[base=Haus]")
- .queryParam("ql", "poliqarp").queryParam("context", "sentence")
+ public void testSerializationQueryWithCorpus () {
+ ClientResponse response = resource()
+ .path(getAPIVersion())
+ .path("corpus/WPD/search")
+ .queryParam("q", "[orth=der]")
+ .queryParam("ql", "poliqarp")
+ .header(Attributes.AUTHORIZATION,
+ BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
.method("TRACE", ClientResponse.class);
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+ assertEquals("koral:doc", node.at("/collection/@type").asText());
+ assertEquals("corpusSigle", node.at("/collection/key").asText());
+ }
+
+
+ @Test
+ public void testSerializationQueryWithCollection () {
+ ClientResponse response = resource()
+ .path(getAPIVersion())
+ .path("collection")
+ .header(Attributes.AUTHORIZATION,
+ BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
+ .get(ClientResponse.class);
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+
+ Iterator it = node.elements();
+ String id = null;
+ while (it.hasNext()) {
+ JsonNode next = (JsonNode) it.next();
+ if ("Weimarer Werke".equals(next.path("name").asText()))
+ id = next.path("id").asText();
+ }
+ assertNotNull(id);
+ assertFalse(id.isEmpty());
+
+ response = resource()
+ .path(getAPIVersion())
+ .path("collection")
+ .path(id)
+ .path("search")
+ .queryParam("q", "[orth=der]")
+ .queryParam("ql", "poliqarp")
+ .queryParam("context", "base/s:s")
+ .header(Attributes.AUTHORIZATION,
+ BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
+ .method("TRACE", ClientResponse.class);
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
+ ent = response.getEntity(String.class);
+ node = JsonUtils.readTree(ent);
+ assertNotNull(node);
+
+ assertEquals("koral:docGroup", node.at("/collection/@type").asText());
+ assertEquals("koral:doc", node.at("/collection/operands/0/@type")
+ .asText());
+ assertEquals("koral:doc", node.at("/collection/operands/1/@type")
+ .asText());
+ assertEquals("creationDate", node.at("/collection/operands/0/key")
+ .asText());
+ assertEquals("corpusSigle", node.at("/collection/operands/1/key")
+ .asText());
+
+ }
+
+
+ @Test
+ public void testSearchQueryPublicCorpora () {
+ ClientResponse response = resource().path(getAPIVersion())
+ .path("search").queryParam("q", "[orth=der]")
+ .queryParam("ql", "poliqarp").get(ClientResponse.class);
assertEquals(response.getStatus(),
ClientResponse.Status.OK.getStatusCode());
String ent = response.getEntity(String.class);
@@ -143,60 +387,41 @@
}
- @Test
- public void testQuery () {
- ClientResponse response = resource().path(getAPIVersion())
- .path("search").queryParam("q", "[base=Haus]")
- .queryParam("ql", "poliqarp").queryParam("context", "sentence")
- .get(ClientResponse.class);
- assertEquals(response.getStatus(),
- ClientResponse.Status.OK.getStatusCode());
- String ent = response.getEntity(String.class);
- JsonNode node = JsonUtils.readTree(ent);
- assertNotNull(node);
- assertEquals("base/s:s", node.at("/meta/context").asText());
- assertNotEquals("${project.version}", "/meta/version");
- }
-
-
+ // use trace for this
@Test
@Ignore
public void testSerializationMeta () {
ClientResponse response = resource().path(getAPIVersion())
.path("search").queryParam("context", "sentence")
.queryParam("q", "[pos=ADJA]").queryParam("ql", "poliqarp")
- .get(ClientResponse.class);
+
+ .method("TRACE", ClientResponse.class);
assertEquals(response.getStatus(),
ClientResponse.Status.OK.getStatusCode());
}
@Test
- @Ignore
- public void testSerializationCollection () {
- ClientResponse response = resource().path(getAPIVersion()).path("")
- .get(ClientResponse.class);
- assertEquals(response.getStatus(),
- ClientResponse.Status.OK.getStatusCode());
- }
-
-
- @Test
- public void testMatchInfo () {
+ public void testMatchInfoGet () {
}
@Test
- public void testGetResources () {
- ClientResponse response = resource().path(getAPIVersion())
- .path("collection").get(ClientResponse.class);
- assertEquals(response.getStatus(),
- ClientResponse.Status.OK.getStatusCode());
- String ent = response.getEntity(String.class);
- JsonNode node = JsonUtils.readTree(ent);
- assertNotNull(node);
- assertNotEquals(0, node.size());
+ public void testMatchInfoSave () {
+
+ }
+
+
+ @Test
+ public void testMatchInfoDelete () {
+
+ }
+
+
+ @Test
+ public void testGetMatches () {
+
}