Skip to content

Commit

Permalink
Fixed supported versions in the configs & changed delimiter to comma.
Browse files Browse the repository at this point in the history
Change-Id: I91f001dcee42ff8b86520a6dfecaa17a2d1cb6e1
  • Loading branch information
margaretha committed Jul 12, 2024
1 parent 37ac316 commit cdd26e6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -161,7 +162,8 @@ protected void load (Properties properties) throws Exception {
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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/kustvakt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ ldap.config = src/main/resources/embedded-ldap-example.conf
# 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand All @@ -36,4 +42,13 @@ public void testSearchWrongVersion () throws KustvaktException {
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());
}
}
4 changes: 2 additions & 2 deletions src/test/resources/kustvakt-dnb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ ldap.config = src/test/resources/test-ldap.conf

# 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
#
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/kustvakt-icc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ krill.test = true
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
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/kustvakt-test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ ldap.config = src/test/resources/test-ldap.conf

# 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
#
Expand Down

0 comments on commit cdd26e6

Please sign in to comment.