Added search timeout in meta query.
Change-Id: I7811d4ebc9b1f61f55a13e1b8a44e49b7fb0ea00
diff --git a/full/Changes b/full/Changes
index d2d6755..c9be960 100644
--- a/full/Changes
+++ b/full/Changes
@@ -1,3 +1,7 @@
+# version 0.61.5
+17/11/2018
+ - Added a search timeout test (margaretha)
+
# version 0.61.4
14/11/2018
- Integrated lite and full services and controllers in core (margaretha)
diff --git a/full/pom.xml b/full/pom.xml
index 71252ac..9d0a1d9 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.ids_mannheim.korap</groupId>
<artifactId>Kustvakt-full</artifactId>
- <version>0.61.4</version>
+ <version>0.61.5</version>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/SearchKrillTest.java b/full/src/test/java/de/ids_mannheim/korap/web/SearchKrillTest.java
index 34dd3be..ec5561b 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/SearchKrillTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/SearchKrillTest.java
@@ -4,74 +4,64 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import javax.annotation.PostConstruct;
+
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
import com.fasterxml.jackson.databind.JsonNode;
import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.config.BeanConfigTest;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
-import de.ids_mannheim.korap.config.FullConfiguration;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.query.serialize.MetaQueryBuilder;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.SearchKrill;
/**
* Created by hanl on 02.06.16.
+ *
+ * Updated by margaretha
*/
-public class SearchKrillTest extends BeanConfigTest {
+public class SearchKrillTest extends SpringJerseyTest {
- @Override
- public void initMethod () throws KustvaktException {
-
- }
-
-
- @Test
- public void testInit () {
- KustvaktConfiguration config = helper().getContext().getConfiguration();
- SearchKrill krill = new SearchKrill(config.getIndexDir());
+ @Autowired
+ KustvaktConfiguration config;
+
+ SearchKrill krill = null;
+
+ @PostConstruct
+ private void createKrill () {
+ krill = new SearchKrill(config.getIndexDir());
assertNotNull(krill);
}
-
@Test
- public void testIndex () {
- KustvaktConfiguration config = helper().getContext().getConfiguration();
- SearchKrill krill = new SearchKrill(config.getIndexDir());
- assertNotNull(krill);
-
+ public void testIndex () throws KustvaktException {
KrillIndex index = krill.getIndex();
assertNotNull(index);
}
-
@Test
public void testDocSize () {
- KustvaktConfiguration config = helper().getContext().getConfiguration();
- SearchKrill krill = new SearchKrill(config.getIndexDir());
- assertNotNull(krill);
assertNotEquals(0, krill.getIndex().numberOf("documents"));
}
- @Test
+ @Test
public void testMatchInfo () throws KustvaktException {
- FullConfiguration config = helper().getContext().getConfiguration();
- SearchKrill krill = new SearchKrill(config.getIndexDir());
- assertNotNull(krill);
- String matchinfo = krill.getMatch("WPD/AAA.00002/p169-197", config.getFreeLicensePattern());
- JsonNode node = JsonUtils.readTree(matchinfo);
- assertEquals("Invalid match identifier", node.at("/errors/0/1").asText());
- }
+ String matchinfo = krill.getMatch("WPD/AAA.00002/p169-197",
+ config.getFreeLicensePattern());
+ JsonNode node = JsonUtils.readTree(matchinfo);
+ assertEquals("Invalid match identifier",
+ node.at("/errors/0/1").asText());
+ }
@Test
public void testSearch () throws KustvaktException {
QuerySerializer s = new QuerySerializer();
s.setQuery("[orth=der]", "poliqarp");
- KustvaktConfiguration config = helper().getContext().getConfiguration();
- SearchKrill krill = new SearchKrill(config.getIndexDir());
String result = krill.search(s.toJSON());
JsonNode node = JsonUtils.readTree(result);
@@ -79,4 +69,22 @@
assertNotEquals(0, node.at("/matches").size());
}
+ @Test
+ public void testTimeOut () throws KustvaktException {
+ QuerySerializer s = new QuerySerializer();
+ s.setQuery("[orth=der]", "poliqarp");
+// s.setQuery("node ->malt/d[func=/.*/] node", "annis");
+
+ MetaQueryBuilder meta = new MetaQueryBuilder();
+ meta.addEntry("timeout", 1);
+ s.setMeta(meta);
+
+ String query = s.toJSON();
+ JsonNode node = JsonUtils.readTree(query);
+ assertEquals(1, node.at("/meta/timeout").asInt());
+
+ String result = krill.search(query);
+ node = JsonUtils.readTree(result);
+ assertEquals(true,node.at("/meta/timeExceeded").asBoolean());
+ }
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/AnnotationControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/AnnotationControllerTest.java
index f976e32..33f34f0 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/AnnotationControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/AnnotationControllerTest.java
@@ -1,7 +1,6 @@
package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Iterator;