Resolved #42 - Added close index controller.
Change-Id: I0df990b1bf2f7d7f92ac4f0e90aced584aad265e
diff --git a/full/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java b/full/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
index 0b46164..8590db1 100644
--- a/full/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
+++ b/full/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
@@ -87,6 +87,10 @@
public FullConfiguration (Properties properties) throws Exception {
super(properties);
}
+
+ public FullConfiguration () {
+ super();
+ }
@Override
public void load (Properties properties) throws Exception {
diff --git a/full/src/main/java/de/ids_mannheim/korap/server/KustvaktServer.java b/full/src/main/java/de/ids_mannheim/korap/server/KustvaktServer.java
index 9b2f8ee..b3a3a6e 100644
--- a/full/src/main/java/de/ids_mannheim/korap/server/KustvaktServer.java
+++ b/full/src/main/java/de/ids_mannheim/korap/server/KustvaktServer.java
@@ -33,7 +33,8 @@
properties.load(in);
in.close();
- config = new FullConfiguration(properties);
+ config = new FullConfiguration();
+ config.loadBasicProperties(properties);
if (kargs == null)
System.exit(0);
diff --git a/full/src/main/resources/kustvakt.conf b/full/src/main/resources/kustvakt.conf
index 2a5a045..7c8ec4c 100644
--- a/full/src/main/resources/kustvakt.conf
+++ b/full/src/main/resources/kustvakt.conf
@@ -94,7 +94,6 @@
security.validation.stringLength = 150
security.validation.emailLength = 50
security.sharedSecret=this-is-shared-secret-code-for-JWT-Signing.It-must-contains-minimum-256-bits
-security.adminToken=adminToken
## applicable: rewrite, foundry, filter, deny
security.rewrite.strategies=filter, foundry, rewrite
\ No newline at end of file
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