Fixed supported versions in the configs & changed delimiter to comma.
Change-Id: I91f001dcee42ff8b86520a6dfecaa17a2d1cb6e1
diff --git a/Changes b/Changes
index 4477da6..a127806 100644
--- a/Changes
+++ b/Changes
@@ -1,11 +1,12 @@
# version 0.74-SNAPSHOT
-- Unified ResourceFilters and SearchResourceFilters.
- Remove corpusQuery param in the statistics web-service (close #758).
- Moved NamedVCLoader to the init package.
- Clean up Spring XML configs.
- Fix some logging to write to file instead of stdout.
- Change CC RE from CC-BY.* to CC.* (kupietz)
+- Unified ResourceFilters and SearchResourceFilters.
+- Fixed supported versions in the configs & changed delimiter to comma.
# version 0.73.2
diff --git a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index 9fa7e85..a1ccd11 100644
--- a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -15,6 +15,7 @@
import java.util.Properties;
import java.util.Set;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -161,7 +162,8 @@
this.supportedVersions = new HashSet<>();
if (!supportedVersions.isEmpty()) {
List<String> versionArray = Arrays
- .asList(supportedVersions.split(" "));
+ .stream(supportedVersions.split(",")).map(String::trim)
+ .collect(Collectors.toList());
this.supportedVersions.addAll(versionArray);
}
this.supportedVersions.add(currentVersion);
diff --git a/src/main/resources/kustvakt.conf b/src/main/resources/kustvakt.conf
index a45eb41..e90c513 100644
--- a/src/main/resources/kustvakt.conf
+++ b/src/main/resources/kustvakt.conf
@@ -14,8 +14,8 @@
# Kustvakt
api.welcome.message = Welcome to KorAP API!
current.api.version = v1.0
-# multiple versions separated by space
-# supported.api.version = v1.0
+# multiple versions comma separated
+# supported.api.versions = v1.0
# server
server.port=8089
diff --git a/src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java b/src/test/java/de/ids_mannheim/korap/web/APIVersionTest.java
similarity index 72%
rename from src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java
rename to src/test/java/de/ids_mannheim/korap/web/APIVersionTest.java
index 9e138fa..0c1dce0 100644
--- a/src/test/java/de/ids_mannheim/korap/web/ApiVersionTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/APIVersionTest.java
@@ -3,10 +3,13 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.net.URI;
+import java.util.Set;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import jakarta.ws.rs.core.MediaType;
@@ -15,8 +18,11 @@
/**
* @author margaretha
*/
-public class ApiVersionTest extends SpringJerseyTest {
+public class APIVersionTest extends SpringJerseyTest {
+ @Autowired
+ private KustvaktConfiguration config;
+
@Test
public void testSearchWithoutVersion () throws KustvaktException {
Response response = target().path("api").path("search")
@@ -36,4 +42,13 @@
URI location = response.getLocation();
assertEquals("/api/" + API_VERSION + "/search", location.getPath());
}
+
+ @Test
+ public void testSupportedVersions () {
+ Set<String> versions = config.getSupportedVersions();
+ assertEquals(2, versions.size());
+
+ String version = versions.stream().findFirst().orElse("");
+ assertEquals(4, version.length());
+ }
}
diff --git a/src/test/resources/kustvakt-dnb.conf b/src/test/resources/kustvakt-dnb.conf
index c6dbdf1..54e0edf 100644
--- a/src/test/resources/kustvakt-dnb.conf
+++ b/src/test/resources/kustvakt-dnb.conf
@@ -21,9 +21,9 @@
# Kustvakt versions
#
-# multiple versions separated by space
+# multiple versions comma separated
current.api.version = v1.0
-supported.api.version = v0.1 v1.0
+supported.api.versions = v1.0
# Server
#
diff --git a/src/test/resources/kustvakt-icc.conf b/src/test/resources/kustvakt-icc.conf
index 965eb4c..354022e 100644
--- a/src/test/resources/kustvakt-icc.conf
+++ b/src/test/resources/kustvakt-icc.conf
@@ -13,9 +13,9 @@
ldap.config = src/test/resources/test-ldap.conf
# Kustvakt
-# multiple versions separated by space
+# multiple versions comma separated
current.api.version = v1.0
-supported.api.version = v0.1 v1.0
+supported.api.versions = v1.0
# server
server.port=8089
diff --git a/src/test/resources/kustvakt-test.conf b/src/test/resources/kustvakt-test.conf
index eb94008..f10d3e8 100644
--- a/src/test/resources/kustvakt-test.conf
+++ b/src/test/resources/kustvakt-test.conf
@@ -19,9 +19,9 @@
# Kustvakt versions
#
-# multiple versions separated by space
+# multiple versions comma separated
current.api.version = v1.0
-supported.api.version = v0.1 v1.0
+supported.api.versions = v0.1, v1.0
# Server
#