Resolved #42 - Added close index controller.
Change-Id: I0df990b1bf2f7d7f92ac4f0e90aced584aad265e
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java b/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java
index 60fb14a..b9ed11b 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java
@@ -23,7 +23,7 @@
@ContextConfiguration("classpath:test-config.xml")
public abstract class SpringJerseyTest extends JerseyTest {
- public final static String API_VERSION = "v1.1";
+ public final static String API_VERSION = "v1.0";
@Autowired
protected GenericApplicationContext applicationContext;
@@ -57,9 +57,7 @@
return new WebAppDescriptor.Builder(classPackages)
.servletClass(SpringServlet.class)
.contextListenerClass(StaticContextLoaderListener.class)
- // .contextListenerClass(ContextLoaderListener.class)
- // .contextParam("contextConfigLocation",
- // "classpath:test-config.xml")
+ .contextParam("adminToken", "secret")
.build();
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
index 0a62f9d..7e118d1 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
@@ -6,14 +6,20 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.apache.http.HttpStatus;
import org.junit.Ignore;
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.net.HttpHeaders;
import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
import de.ids_mannheim.korap.authentication.http.HttpAuthorizationHandler;
import de.ids_mannheim.korap.config.Attributes;
@@ -21,14 +27,17 @@
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.utils.JsonUtils;
+import de.ids_mannheim.korap.web.SearchKrill;
/**
* @author hanl, margaretha
- * @lastUpdate 18/02/2019
+ * @lastUpdate 18/03/2019
*
*/
public class SearchControllerTest extends SpringJerseyTest {
+ @Autowired
+ private SearchKrill searchKrill;
private JsonNode requestSearchWithFields(String fields) throws KustvaktException{
ClientResponse response = resource().path(API_VERSION).path("search")
@@ -333,5 +342,21 @@
assertNotEquals(0, node.path("matches").size());
// assertEquals(10993, node.at("/meta/totalResults").asInt());
}
+
+ @Test
+ public void testCloseIndex () throws IOException {
+ searchKrill.getStatistics(null);
+ assertEquals(true, searchKrill.getIndex().isReaderOpen());
+
+ MultivaluedMap<String, String> m = new MultivaluedMapImpl();
+ m.add("token", "secret");
+
+ ClientResponse response = resource().path(API_VERSION).path("index")
+ .path("close").type(MediaType.APPLICATION_FORM_URLENCODED)
+ .post(ClientResponse.class, m);
+
+ assertEquals(HttpStatus.SC_OK, response.getStatus());
+ assertEquals(false, searchKrill.getIndex().isReaderOpen());
+ }
}
diff --git a/full/src/test/resources/kustvakt-test.conf b/full/src/test/resources/kustvakt-test.conf
index a4f8467..066377c 100644
--- a/full/src/test/resources/kustvakt-test.conf
+++ b/full/src/test/resources/kustvakt-test.conf
@@ -13,7 +13,7 @@
# Kustvakt
# multiple versions separated by space
-current.api.version = v1.1
+current.api.version = v1.0
supported.api.version = v0.1 v1.0
## server