Make API welcome message configurable
This allows flexible, informal messages and, if necessary, terms of
service to be displayed. For RKorAPClient this is nice because the
welcome message will be displayed on connect.
Change-Id: I9d3c6cef7b1f0205a23fe847909bca0de982bc0f
diff --git a/full/src/main/resources/kustvakt.conf b/full/src/main/resources/kustvakt.conf
index 62546c6..a9086ba 100644
--- a/full/src/main/resources/kustvakt.conf
+++ b/full/src/main/resources/kustvakt.conf
@@ -12,6 +12,7 @@
ldap.config = file-path-to-ldap-config
# Kustvakt
+api.welcome.message = Welcome to KorAP API!
current.api.version = v1.0
# multiple versions separated by space
# supported.api.version = v1.0
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 18e2c35..a97ab50 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
@@ -8,6 +8,7 @@
import javax.ws.rs.core.MediaType;
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
import org.junit.Ignore;
import org.junit.Test;
@@ -22,6 +23,7 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.utils.JsonUtils;
+import org.springframework.beans.factory.annotation.Autowired;
/**
* @author hanl, margaretha
@@ -30,6 +32,9 @@
*/
public class SearchControllerTest extends SpringJerseyTest {
+ @Autowired
+ private KustvaktConfiguration config;
+
private JsonNode requestSearchWithFields(String fields) throws KustvaktException{
ClientResponse response = resource().path(API_VERSION).path("search")
.queryParam("q", "[orth=das]").queryParam("ql", "poliqarp")
@@ -50,7 +55,17 @@
s.setQuery("Wasser", "poliqarp");
return s.toJSON();
}
-
+
+ @Test
+ public void testApiWelcomeMessage () {
+ ClientResponse response = resource().path(API_VERSION).path("")
+ .get(ClientResponse.class);
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
+ String message = response.getEntity(String.class);
+ assertEquals(message, config.getApiWelcomeMessage());
+ }
+
@Test
public void testSearchWithField () throws KustvaktException {
JsonNode node = requestSearchWithFields("author");