Implemented predefined VC caching and added VC reference tests.
Change-Id: I84ad56b375f8b076ad92e493775993fc0580249f
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java
index 7fb5d4c..a5ba179 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java
@@ -8,7 +8,6 @@
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response.Status;
-import org.apache.commons.codec.binary.Base64;
import org.apache.http.entity.ContentType;
import org.apache.oltu.oauth2.common.error.OAuthError;
import org.apache.oltu.oauth2.common.message.types.GrantType;
@@ -187,6 +186,7 @@
tokenForm.add("client_id", "fCBbQkAyYzI4NzUxMg");
tokenForm.add("client_secret", "secret");
tokenForm.add("code", code);
+ System.out.println(code);
response = requestToken(tokenForm);
String entity = response.getEntity(String.class);
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java
new file mode 100644
index 0000000..ae3d38e
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java
@@ -0,0 +1,75 @@
+package de.ids_mannheim.korap.web.controller;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.ClientResponse;
+
+import de.ids_mannheim.korap.config.SpringJerseyTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.utils.JsonUtils;
+
+public class VCReferenceTest extends SpringJerseyTest {
+
+ @Test
+ public void testVCRef () throws KustvaktException {
+ testSearchWithoutVCRefOr();
+ testSearchWithoutVCRefAnd();
+ // auto caching
+ testSearchWithVCRefEqual();
+ testSearchWithVCRefNotEqual();
+ // retrieve from cache
+ testSearchWithVCRefEqual();
+ testSearchWithVCRefNotEqual();
+ }
+
+ private void testSearchWithoutVCRefOr () throws KustvaktException {
+ ClientResponse response = resource().path("search")
+ .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
+ .queryParam("cq",
+ "textSigle=\"GOE/AGF/00000\" | textSigle=\"GOE/AGA/01784\"")
+ .get(ClientResponse.class);
+
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertTrue(node.at("/matches").size() > 0);
+ }
+
+ private void testSearchWithoutVCRefAnd () throws KustvaktException {
+ ClientResponse response = resource().path("search")
+ .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
+ .queryParam("cq",
+ "textSigle!=\"GOE/AGI/04846\" & textSigle!=\"GOE/AGA/01784\"")
+ .get(ClientResponse.class);
+
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertTrue(node.at("/matches").size() > 0);
+ }
+
+ public void testSearchWithVCRefEqual () throws KustvaktException {
+ ClientResponse response = resource().path("search")
+ .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
+ .queryParam("cq", "referTo named-vc1")
+ .get(ClientResponse.class);
+
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertTrue(node.at("/matches").size() > 0);
+
+ }
+
+ public void testSearchWithVCRefNotEqual () throws KustvaktException {
+ ClientResponse response = resource().path("search")
+ .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
+ .queryParam("cq", "referTo named-vc2")
+ .get(ClientResponse.class);
+
+ String ent = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(ent);
+ assertTrue(node.at("/matches").size() > 0);
+ }
+
+}
diff --git a/full/src/test/resources/kustvakt-test.conf b/full/src/test/resources/kustvakt-test.conf
index 694abce..8690e4f 100644
--- a/full/src/test/resources/kustvakt-test.conf
+++ b/full/src/test/resources/kustvakt-test.conf
@@ -5,6 +5,8 @@
krill.index.commit.log = log/krill.commit.log
krill.index.commit.auto = 500
krill.index.relations.max = 100
+## Directory path of virtual corpora to cache
+krill.namedVC = vc
#LDAP
ldap.config = file-path-to-ldap-config
diff --git a/full/src/test/resources/test-config.xml b/full/src/test/resources/test-config.xml
index ad3d702..f438fd2 100644
--- a/full/src/test/resources/test-config.xml
+++ b/full/src/test/resources/test-config.xml
@@ -167,8 +167,7 @@
</bean>
<bean id="initializator" class="de.ids_mannheim.korap.config.Initializator"
- init-method="init">
- <constructor-arg name="accessScopeDao" ref="accessScopeDao" />
+ init-method="initTest">
</bean>