Set up the test framework with SpringServlet.
Change-Id: Ie5a4e05e54fdf4c77b52daf9a34808e2bf7f0581
diff --git a/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java b/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
index 74def43..79042d5 100644
--- a/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
+++ b/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
@@ -8,6 +8,7 @@
import org.junit.runners.model.InitializationError;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -31,6 +32,7 @@
public void init () throws Exception {
+// context = new ClassPathXmlApplicationContext("test-default-config.xml");
assertNotNull("Application context must not be null!", this.context);
jlog.debug("running one-time before init for class "
+ this.getClass().getSimpleName() + " ...");
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java b/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
index 87457bd..932ffb1 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
@@ -4,6 +4,7 @@
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.core.DefaultResourceConfig;
import com.sun.jersey.spi.inject.SingletonTypeInjectableProvider;
+import com.sun.jersey.spi.spring.container.servlet.SpringServlet;
import com.sun.jersey.test.framework.AppDescriptor;
import com.sun.jersey.test.framework.LowLevelAppDescriptor;
import com.sun.jersey.test.framework.WebAppDescriptor;
@@ -16,6 +17,7 @@
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.springframework.web.context.ContextLoaderListener;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriBuilder;
@@ -31,7 +33,8 @@
private final static String API_VERSION = "v0.1";
- private static DefaultResourceConfig resourceConfig = new DefaultResourceConfig();
+ private static DefaultResourceConfig resourceConfig =
+ new DefaultResourceConfig();
private static TestContainerFactory testContainerFactory;
@@ -99,7 +102,11 @@
if (classPackages == null)
ad = new LowLevelAppDescriptor.Builder(resourceConfig).build();
else
- ad = new WebAppDescriptor.Builder(classPackages).build();
+ ad = new WebAppDescriptor.Builder(classPackages)
+ .servletClass(SpringServlet.class)
+ .contextListenerClass(ContextLoaderListener.class)
+ .contextParam("contextConfigLocation", "classpath:test-default-config.xml")
+ .build();
TestContainerFactory tcf = testContainerFactory;
if (tcf == null) {
@@ -109,8 +116,8 @@
tcf = new GrizzlyWebTestContainerFactory();
}
- testContainer = tcf.create(UriBuilder.fromUri(containerURI)
- .port(port).build(), ad);
+ testContainer = tcf.create(
+ UriBuilder.fromUri(containerURI).port(port).build(), ad);
client = testContainer.getClient();
if (client == null) {
client = Client.create(ad.getClientConfig());
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java
index 170ab18..73dbc4a 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java
@@ -30,7 +30,7 @@
@Test
public void testGetMatchInfoPublicCorpus () {
- ClientResponse response = resource().path(getAPIVersion())
+ ClientResponse response = resource()
.path("corpus").path("GOE").path("AGA").path("01784")
.path("p36-100").path("matchInfo")
.queryParam("foundry", "*")
@@ -56,7 +56,7 @@
@Test
public void testGetMatchInfoNotAllowed () {
- ClientResponse response = resource().path(getAPIVersion())
+ ClientResponse response = resource()
.path("corpus").path("GOE").path("AGI").path("04846")
.path("p36875-36876").path("matchInfo")
.queryParam("foundry", "*")
@@ -76,7 +76,7 @@
@Test
public void testGetMatchInfoWithAuthentication () {
- ClientResponse response = resource().path(getAPIVersion())
+ ClientResponse response = resource()
.path("corpus").path("GOE").path("AGI").path("04846")
.path("p36875-36876").path("matchInfo")
.queryParam("foundry", "*")
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
index f735063..e33eb9e 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
@@ -1,4 +1,5 @@
package de.ids_mannheim.korap.web.service.full;
+
/**
* @author hanl, margaretha
* @lastUpdate 19/04/2017
@@ -31,7 +32,7 @@
@Override
public void initMethod () throws KustvaktException {
-// helper().runBootInterfaces();
+ // helper().runBootInterfaces();
}
@@ -41,15 +42,14 @@
"de.ids_mannheim.korap.web.filter",
"de.ids_mannheim.korap.web.utils");
}
-
+
+
@Test
public void testQuerySerializationFilteredPublic () {
ClientResponse response = resource()
- .path(getAPIVersion())
- .path("corpus/WPD13/query")
- .queryParam("q", "[orth=der]")
- .queryParam("ql", "poliqarp")
- .queryParam("context", "base/s:s")
+
+ .path("corpus/WPD13/query").queryParam("q", "[orth=der]")
+ .queryParam("ql", "poliqarp").queryParam("context", "base/s:s")
.method("GET", ClientResponse.class);
assertEquals(ClientResponse.Status.OK.getStatusCode(),
response.getStatus());
@@ -59,17 +59,15 @@
assertEquals("corpusSigle", node.at("/collection/key").asText());
assertEquals("WPD13", node.at("/collection/value").asText());
}
-
-
+
+
@Test
public void testQuerySerializationUnexistingResource () {
ClientResponse response = resource()
- .path(getAPIVersion())
- .path("corpus/ZUW19/query")
- .queryParam("q", "[orth=der]")
- .queryParam("ql", "poliqarp")
- .queryParam("context", "base/s:s")
+
+ .path("corpus/ZUW19/query").queryParam("q", "[orth=der]")
+ .queryParam("ql", "poliqarp").queryParam("context", "base/s:s")
.method("GET", ClientResponse.class);
assertEquals(ClientResponse.Status.BAD_REQUEST.getStatusCode(),
response.getStatus());
@@ -79,15 +77,14 @@
assertEquals("[Cannot found public Corpus with ids: [ZUW19]]",
node.at("/errors/0/2").asText());
}
-
+
+
@Test
public void testQuerySerializationWithNonPublicCorpus () {
ClientResponse response = resource()
- .path(getAPIVersion())
- .path("corpus/BRZ10/query")
- .queryParam("q", "[orth=der]")
- .queryParam("ql", "poliqarp")
- .queryParam("context", "base/s:s")
+
+ .path("corpus/BRZ10/query").queryParam("q", "[orth=der]")
+ .queryParam("ql", "poliqarp").queryParam("context", "base/s:s")
.method("GET", ClientResponse.class);
assertEquals(ClientResponse.Status.BAD_REQUEST.getStatusCode(),
response.getStatus());
@@ -98,12 +95,12 @@
node.at("/errors/0/2").asText());
}
+
@Test
public void testQuerySerializationWithAuthentication () {
ClientResponse response = resource()
- .path(getAPIVersion())
- .path("corpus/BRZ10/query")
- .queryParam("q", "[orth=der]")
+
+ .path("corpus/BRZ10/query").queryParam("q", "[orth=der]")
.queryParam("ql", "poliqarp")
.header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
@@ -118,23 +115,24 @@
assertEquals("BRZ10", node.at("/collection/value").asText());
}
+
@Test
public void testQuerySerializationWithNewCollection () {
// Add Virtual Collection
ClientResponse response = resource()
- .path(getAPIVersion())
- .path("virtualcollection")
- .queryParam("filter", "false")
- .queryParam("query", "creationDate since 1775 & corpusSigle=GOE")
+
+ .path("virtualcollection").queryParam("filter", "false")
+ .queryParam("query",
+ "creationDate since 1775 & corpusSigle=GOE")
.queryParam("name", "Weimarer Werke")
.queryParam("description", "Goethe-Werke in Weimar (seit 1775)")
.header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
.post(ClientResponse.class);
-
+
assertEquals(ClientResponse.Status.OK.getStatusCode(),
response.getStatus());
-
+
String ent = response.getEntity(String.class);
JsonNode node = JsonUtils.readTree(ent);
assertNotNull(node);
@@ -143,7 +141,7 @@
// Get virtual collections
response = resource()
- .path(getAPIVersion())
+
.path("collection")
.header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
@@ -166,12 +164,9 @@
// query serialization service
response = resource()
- .path(getAPIVersion())
- .path("collection")
- .path(id)
- .path("query")
- .queryParam("q", "[orth=der]")
- .queryParam("ql", "poliqarp")
+
+ .path("collection").path(id).path("query")
+ .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
.queryParam("context", "base/s:s")
.header(Attributes.AUTHORIZATION,
BasicHttpAuth.encode("kustvakt", "kustvakt2015"))
@@ -181,105 +176,100 @@
ent = response.getEntity(String.class);
node = JsonUtils.readTree(ent);
assertNotNull(node);
- System.out.println("NODE "+ent);
+ System.out.println("NODE " + ent);
assertEquals("koral:docGroup", node.at("/collection/@type").asText());
- assertEquals("koral:doc", node.at("/collection/operands/0/@type")
- .asText());
- assertEquals("creationDate", node.at("/collection/operands/0/key")
- .asText());
- assertEquals("1775", node.at("/collection/operands/0/value")
- .asText());
- assertEquals("type:date", node.at("/collection/operands/0/type")
- .asText());
- assertEquals("match:geq", node.at("/collection/operands/0/match")
- .asText());
-
- assertEquals("koral:doc", node.at("/collection/operands/1/@type")
- .asText());
- assertEquals("corpusSigle", node.at("/collection/operands/1/key")
- .asText());
- assertEquals("GOE", node.at("/collection/operands/1/value")
- .asText());
- assertEquals("match:eq", node.at("/collection/operands/1/match")
- .asText());
+ assertEquals("koral:doc",
+ node.at("/collection/operands/0/@type").asText());
+ assertEquals("creationDate",
+ node.at("/collection/operands/0/key").asText());
+ assertEquals("1775", node.at("/collection/operands/0/value").asText());
+ assertEquals("type:date",
+ node.at("/collection/operands/0/type").asText());
+ assertEquals("match:geq",
+ node.at("/collection/operands/0/match").asText());
+
+ assertEquals("koral:doc",
+ node.at("/collection/operands/1/@type").asText());
+ assertEquals("corpusSigle",
+ node.at("/collection/operands/1/key").asText());
+ assertEquals("GOE", node.at("/collection/operands/1/value").asText());
+ assertEquals("match:eq",
+ node.at("/collection/operands/1/match").asText());
}
-
+
+
@Test
public void testQuerySerializationOfVirtualCollection () {
ClientResponse response = resource()
- .path(getAPIVersion())
- .path("collection/GOE-VC/query")
- .queryParam("q", "[orth=der]")
- .queryParam("ql", "poliqarp")
- .queryParam("context", "base/s:s")
+
+ .path("collection/GOE-VC/query").queryParam("q", "[orth=der]")
+ .queryParam("ql", "poliqarp").queryParam("context", "base/s:s")
.method("GET", 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/operands/0/@type")
- .asText());
- assertEquals("corpusSigle", node.at("/collection/operands/0/key").asText());
+ assertEquals("koral:doc",
+ node.at("/collection/operands/0/@type").asText());
+ assertEquals("corpusSigle",
+ node.at("/collection/operands/0/key").asText());
assertEquals("GOE", node.at("/collection/operands/0/value").asText());
- assertEquals("koral:doc", node.at("/collection/operands/1/@type")
- .asText());
- assertEquals("creationDate", node.at("/collection/operands/1/key").asText());
- assertEquals("1810-01-01", node.at("/collection/operands/1/value").asText());
+ assertEquals("koral:doc",
+ node.at("/collection/operands/1/@type").asText());
+ assertEquals("creationDate",
+ node.at("/collection/operands/1/key").asText());
+ assertEquals("1810-01-01",
+ node.at("/collection/operands/1/value").asText());
}
-
+
+
@Test
public void testMetaQuerySerialization () {
ClientResponse response = resource()
- .path(getAPIVersion())
- .path("query")
- .queryParam("context", "sentence")
- .queryParam("count", "20")
- .queryParam("page", "5")
- .queryParam("cutoff", "true")
- .queryParam("q", "[pos=ADJA]")
+
+ .path("query").queryParam("context", "sentence")
+ .queryParam("count", "20").queryParam("page", "5")
+ .queryParam("cutoff", "true").queryParam("q", "[pos=ADJA]")
.queryParam("ql", "poliqarp")
.method("GET", ClientResponse.class);
assertEquals(response.getStatus(),
ClientResponse.Status.OK.getStatusCode());
-
+
String ent = response.getEntity(String.class);
JsonNode node = JsonUtils.readTree(ent);
-
+
assertEquals("sentence", node.at("/meta/context").asText());
assertEquals(20, node.at("/meta/count").asInt());
- assertEquals(5, node.at("/meta/startPage").asInt());
+ assertEquals(5, node.at("/meta/startPage").asInt());
assertEquals(true, node.at("/meta/cutOff").asBoolean());
-
+
assertEquals("koral:term", node.at("/query/wrap/@type").asText());
assertEquals("pos", node.at("/query/wrap/layer").asText());
assertEquals("match:eq", node.at("/query/wrap/match").asText());
assertEquals("ADJA", node.at("/query/wrap/key").asText());
}
+
@Test
public void testMetaQuerySerializationWithOffset () {
ClientResponse response = resource()
- .path(getAPIVersion())
- .path("query")
- .queryParam("context", "sentence")
- .queryParam("count", "20")
- .queryParam("page", "5")
- .queryParam("offset", "2")
- .queryParam("cutoff", "true")
- .queryParam("q", "[pos=ADJA]")
- .queryParam("ql", "poliqarp")
+
+ .path("query").queryParam("context", "sentence")
+ .queryParam("count", "20").queryParam("page", "5")
+ .queryParam("offset", "2").queryParam("cutoff", "true")
+ .queryParam("q", "[pos=ADJA]").queryParam("ql", "poliqarp")
.method("GET", ClientResponse.class);
assertEquals(response.getStatus(),
ClientResponse.Status.OK.getStatusCode());
-
+
String ent = response.getEntity(String.class);
JsonNode node = JsonUtils.readTree(ent);
-
+
assertEquals("sentence", node.at("/meta/context").asText());
assertEquals(20, node.at("/meta/count").asInt());
- assertEquals(2, node.at("/meta/startIndex").asInt());
+ assertEquals(2, node.at("/meta/startIndex").asInt());
assertEquals(true, node.at("/meta/cutOff").asBoolean());
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
index 1a7afff..909a250 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
@@ -8,6 +8,8 @@
import java.util.Iterator;
import java.util.Set;
+import javax.ws.rs.core.MediaType;
+
import org.eclipse.jetty.http.HttpHeaders;
import org.junit.BeforeClass;
import org.junit.Ignore;
@@ -38,7 +40,7 @@
@Override
public void initMethod () throws KustvaktException {
// helper().runBootInterfaces();
- helper().setupAccount();
+// helper().setupAccount();
}
@@ -52,12 +54,14 @@
@Test
public void testSearchQueryPublicCorpora () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").queryParam("q", "[orth=der]")
- .queryParam("ql", "poliqarp").get(ClientResponse.class);
+ .queryParam("ql", "poliqarp")
+ .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
// assertEquals(ClientResponse.Status.OK.getStatusCode(),
// response.getStatus());
String ent = response.getEntity(String.class);
+ System.out.println(ent);
JsonNode node = JsonUtils.readTree(ent);
assertNotNull(node);
assertEquals("koral:doc", node.at("/collection/@type").asText());
@@ -72,7 +76,7 @@
@Test
public void testSearchQueryWithMeta () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").queryParam("q", "[orth=der]")
.queryParam("ql", "poliqarp").queryParam("cutoff", "true")
.queryParam("count", "5").queryParam("page", "1")
@@ -93,7 +97,7 @@
@Test
public void testSearchQueryFreeExtern () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").queryParam("q", "[orth=die]")
.queryParam("ql", "poliqarp")
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
@@ -115,7 +119,7 @@
@Test
public void testSearchQueryFreeIntern () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").queryParam("q", "[orth=die]")
.queryParam("ql", "poliqarp")
.header(HttpHeaders.X_FORWARDED_FOR, "172.27.0.32")
@@ -138,7 +142,7 @@
@Test
public void testSearchQueryExternAuthorized () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").queryParam("q", "[orth=die]")
.queryParam("ql", "poliqarp")
.header(Attributes.AUTHORIZATION,
@@ -164,7 +168,7 @@
@Test
public void testSearchQueryInternAuthorized () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").queryParam("q", "[orth=die]")
.queryParam("ql", "poliqarp")
.header(Attributes.AUTHORIZATION,
@@ -195,7 +199,7 @@
@Test
@Ignore
public void testSearchQueryWithCollectionQueryAuthorizedWithoutIP () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").queryParam("q", "[orth=das]")
.queryParam("ql", "poliqarp")
.queryParam("cq", "textClass=politik & corpusSigle=BRZ10")
@@ -225,7 +229,7 @@
@Test
@Ignore
public void testSearchQueryAuthorizedWithoutIP () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").queryParam("q", "[orth=die]")
.queryParam("ql", "poliqarp")
.header(Attributes.AUTHORIZATION,
@@ -251,7 +255,7 @@
@Test
@Ignore
public void testSearchForPublicCorpusWithStringId () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("corpus").path("GOE").path("search")
.queryParam("q", "blau").queryParam("ql", "poliqarp")
.get(ClientResponse.class);
@@ -277,7 +281,7 @@
@Test
@Ignore
public void testSearchForVirtualCollectionWithStringId () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("collection").path("GOE-VC").path("search")
.queryParam("q", "blau").queryParam("ql", "poliqarp")
.get(ClientResponse.class);
@@ -315,7 +319,7 @@
}
}
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("corpus").path(id).path("search").queryParam("q", "blau")
.queryParam("ql", "poliqarp").get(ClientResponse.class);
@@ -342,7 +346,7 @@
@Test
@Ignore
public void testSearchForCorpusWithStringIdUnauthorized () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("corpus").path("WPD15").path("search")
.queryParam("q", "blau").queryParam("ql", "poliqarp")
.get(ClientResponse.class);
@@ -359,7 +363,7 @@
@Test
@Ignore
public void testSearchForSpecificCorpus () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("corpus").path("GOE").path("search")
.queryParam("q", "[orth=das]").queryParam("ql", "poliqarp")
.header(Attributes.AUTHORIZATION,
@@ -401,7 +405,7 @@
// System.out.println("Corpus "+id);
}
}
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("corpus").path(id).path("search")
.queryParam("q", "[orth=das]").queryParam("ql", "poliqarp")
.header(Attributes.AUTHORIZATION,
@@ -427,7 +431,7 @@
@Test
public void testSearchSentenceMeta () {
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").queryParam("q", "[orth=der]")
.queryParam("ql", "poliqarp").queryParam("context", "sentence")
.get(ClientResponse.class);
@@ -446,7 +450,7 @@
QuerySerializer s = new QuerySerializer();
s.setQuery("(der) or (das)", "CQL");
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").post(ClientResponse.class, s.toJSON());
assertEquals(ClientResponse.Status.OK.getStatusCode(),
response.getStatus());
@@ -465,7 +469,7 @@
s.setQuery("[orth=der]", "poliqarp");
s.setCollection("corpusSigle=GOE");
- ClientResponse response = resource().path("kustvakt")
+ ClientResponse response = resource()
.path("search").post(ClientResponse.class, s.toJSON());
assertEquals(ClientResponse.Status.OK.getStatusCode(),
response.getStatus());
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java
index 5dc44c2..d2b1386 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java
@@ -162,7 +162,7 @@
private ClientResponse builtSimpleClientResponse (String collectionQuery) {
- return resource().path(getAPIVersion()).path("search")
+ return resource().path("search")
.queryParam("q", "[orth=das]").queryParam("ql", "poliqarp")
.queryParam("cq", collectionQuery).get(ClientResponse.class);
}
@@ -170,7 +170,7 @@
private ClientResponse builtClientResponseWithIP (String collectionQuery,
String ip) {
- return resource().path(getAPIVersion()).path("search")
+ return resource().path("search")
.queryParam("q", "[orth=das]").queryParam("ql", "poliqarp")
.queryParam("cq", collectionQuery)
.header(Attributes.AUTHORIZATION,
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
index 3252ed8..335f564 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
@@ -40,7 +40,7 @@
public void testGetStatisticsNoResource ()
throws JsonProcessingException, IOException {
String collectionQuery = "corpusSigle=WPD15";
- ClientResponse response = resource().path(getAPIVersion())
+ ClientResponse response = resource()
.path("statistics")
.queryParam("collectionQuery", collectionQuery)
.get(ClientResponse.class);
@@ -58,7 +58,7 @@
public void testGetStatisticsWithCollectionQuery1 ()
throws JsonProcessingException, IOException {
String collectionQuery = "corpusSigle=GOE";
- ClientResponse response = resource().path(getAPIVersion())
+ ClientResponse response = resource()
.path("statistics")
.queryParam("collectionQuery", collectionQuery)
.get(ClientResponse.class);
@@ -75,7 +75,7 @@
@Test
public void testGetStatisticsWithCollectionQuery2 ()
throws JsonProcessingException, IOException {
- ClientResponse response = resource().path(getAPIVersion())
+ ClientResponse response = resource()
.path("statistics")
.queryParam("collectionQuery", "creationDate since 1810")
.get(ClientResponse.class);
@@ -93,7 +93,7 @@
@Test
public void testGetStatisticsWithWrongCollectionQuery ()
throws JsonProcessingException, IOException {
- ClientResponse response = resource().path(getAPIVersion())
+ ClientResponse response = resource()
.path("statistics")
.queryParam("collectionQuery", "creationDate geq 1810")
.get(ClientResponse.class);
@@ -113,7 +113,7 @@
@Test
public void testGetStatisticsWithWrongCollectionQuery2 ()
throws JsonProcessingException, IOException {
- ClientResponse response = resource().path(getAPIVersion())
+ ClientResponse response = resource()
.path("statistics")
.queryParam("collectionQuery", "creationDate >= 1810")
.get(ClientResponse.class);
diff --git a/src/test/resources/test-default-config.xml b/src/test/resources/test-default-config.xml
index 8c6464d..09d4822 100644
--- a/src/test/resources/test-default-config.xml
+++ b/src/test/resources/test-default-config.xml
@@ -34,9 +34,11 @@
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<array>
- <value>classpath:jdbc.properties</value>
+ <value>classpath:test-jdbc.properties</value>
<value>classpath:hibernate.properties</value>
<!-- <value>file:./jdbc.properties</value> -->
+ <value>file:./kustvakt.conf</value>
+ <value>classpath:kustvakt.conf</value>
</array>
</property>
</bean>
@@ -55,17 +57,29 @@
<!--class="org.apache.commons.dbcp2.BasicDataSource" -->
<!-- org.springframework.jdbc.datasource.SingleConnectionDataSource -->
- <!-- org.springframework.jdbc.datasource.DriverManagerDataSource -->
- <bean id="dataSource"
+ <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
+ lazy-init="true">
+ <property name="driverClassName" value="${jdbc.driverClassName}" />
+ <property name="url" value="${jdbc.url}" />
+ <property name="username" value="${jdbc.username}" />
+ <property name="password" value="${jdbc.password}" />
+ <!-- relevant for single connection datasource and sqlite -->
+ <!-- <property name="suppressClose"> <value>true</value> </property> -->
+ <!--<property name="initialSize" value="2"/> -->
+ <property name="maxTotal" value="4" />
+ <property name="maxIdle" value="2" />
+ <property name="minIdle" value="1" />
+ <property name="maxWaitMillis" value="15000" />
+ <!--<property name="poolPreparedStatements" value="true"/> -->
+ </bean>
+
+ <bean id="sqliteDataSource"
class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
- lazy-init="false">
- <property name="driverClassName" value="org.sqlite.JDBC" />
- <property name="url" value="jdbc:sqlite::memory:" />
- <!--<property name="initialSize" value="1" /> -->
- <!--<property name="maxTotal" value="1" /> -->
- <!--<property name="maxIdle" value="1" /> -->
- <!--<property name="username" value="${jdbc.username}"/> -->
- <!--<property name="password" value="${jdbc.password}"/> -->
+ lazy-init="true">
+ <property name="driverClassName" value="${jdbc.driverClassName}" />
+ <property name="url" value="${jdbc.url}" />
+ <property name="username" value="${jdbc.username}" />
+ <property name="password" value="${jdbc.password}" />
<!-- relevant for single connection datasource and sqlite -->
<property name="suppressClose">
<value>true</value>
@@ -76,9 +90,9 @@
<!-- to configure database for sqlite, mysql, etc. migrations -->
<bean id="flyway" class="org.flywaydb.core.Flyway" init-method="migrate">
- <property name="baselineOnMigrate" value="false" />
+ <property name="baselineOnMigrate" value="true" />
<property name="locations" value="classpath:db.sqlite" />
- <property name="dataSource" ref="dataSource" />
+ <property name="dataSource" ref="sqliteDataSource" />
</bean>
<bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
@@ -126,6 +140,11 @@
<bean id="resourceDao" class="de.ids_mannheim.korap.dao.ResourceDao"/>
<!-- <bean id="annotationDao" class="de.ids_mannheim.korap.dao.AnnotationDao"/> -->
+ <!-- Krill -->
+ <bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
+ <constructor-arg value="${krill.indexDir}"/>
+ </bean>
+
<bean id="kustvakt_auditing" class="de.ids_mannheim.korap.handlers.JDBCAuditing">
<constructor-arg ref="kustvakt_db" />
</bean>
diff --git a/src/test/resources/test-jdbc.properties b/src/test/resources/test-jdbc.properties
new file mode 100644
index 0000000..1865408
--- /dev/null
+++ b/src/test/resources/test-jdbc.properties
@@ -0,0 +1,10 @@
+#-------------------------------------------------------------------------------
+# Sqlite Settings
+
+jdbc.database=sqlite
+jdbc.driverClassName=org.sqlite.JDBC
+jdbc.url=jdbc:sqlite:db.sqlite
+# jdbc.url=jdbc:sqlite:kustvakt_init_test.sqlite
+jdbc.username=pc
+jdbc.password=pc
+jdbc.schemaPath=classpath:db.sqlite