diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 5f8adadb8..cb0e73175 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -7,6 +7,13 @@ on:
jobs:
build-java:
runs-on: ubuntu-latest
+ env:
+ BABELFY_API_KEY: ${{ secrets.BABELFY_API_KEY }}
+ CHATGPT_API_KEY: ${{ secrets.CHATGPT_API_KEY }}
+ DANDELION_API_KEY: ${{ secrets.DANDELION_API_KEY }}
+ MEANINGCLOUD_API_KEY: ${{ secrets.MEANINGCLOUD_API_KEY }}
+ TAGME_API_KEY: ${{ secrets.TAGME_API_KEY }}
+ TEXTRAZOR_API_KEY: ${{ secrets.TEXTRAZOR_API_KEY }}
steps:
- name: Configure java
uses: actions/setup-java@v3
diff --git a/.gitignore b/.gitignore
index 66dc633e0..ed57ff84a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -148,5 +148,5 @@ dmypy.json
.factorypath
-# LOCAL PROPERTIES
+# LOCAL APPLEICATION PROPERTIES
application-local.properties
\ No newline at end of file
diff --git a/qanary-component-ASR-Kaldi/pom.xml b/qanary-component-ASR-Kaldi/pom.xml
index f1a327fe2..4bb15d225 100644
--- a/qanary-component-ASR-Kaldi/pom.xml
+++ b/qanary-component-ASR-Kaldi/pom.xml
@@ -5,11 +5,12 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-ASR-Kaldi
- 3.1.5
+ 3.1.6
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -100,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-CLS-CLSNLIOD/pom.xml b/qanary-component-CLS-CLSNLIOD/pom.xml
index 1a85935db..1cdd79656 100644
--- a/qanary-component-CLS-CLSNLIOD/pom.xml
+++ b/qanary-component-CLS-CLSNLIOD/pom.xml
@@ -5,12 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-CLS-CLSNLIOD
- 4.1.5
+ 4.1.6
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -101,10 +102,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-LD-Shuyo/pom.xml b/qanary-component-LD-Shuyo/pom.xml
index b9400c504..b3e644670 100644
--- a/qanary-component-LD-Shuyo/pom.xml
+++ b/qanary-component-LD-Shuyo/pom.xml
@@ -114,10 +114,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NED-AGDISTIS/pom.xml b/qanary-component-NED-AGDISTIS/pom.xml
index 59a994a7d..f5bffbb80 100644
--- a/qanary-component-NED-AGDISTIS/pom.xml
+++ b/qanary-component-NED-AGDISTIS/pom.xml
@@ -4,7 +4,7 @@
4.0.0
qanary-component-NED-AGDISTIS
eu.wdaqua.qanary.component
- 4.3.1
+ 4.4.0
org.springframework.boot
@@ -14,7 +14,8 @@
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
qanary-component-ned-agdistis
1.4.13
@@ -24,7 +25,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.springframework.boot
@@ -72,7 +80,6 @@
json-path-assert
test
-
com.google.code.gson
gson
diff --git a/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisCacheTests.java b/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisCacheTests.java
deleted file mode 100644
index 13503a7c0..000000000
--- a/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisCacheTests.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package eu.wdaqua.qanary.component.agdistis.ned;
-
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-class AgdistisCacheTests {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
- private static final Logger LOGGER = LoggerFactory.getLogger(AgdistisCacheTests.class);
-
- private final int testPort;
- private final RestTemplateWithCaching myRestTemplate;
- private final CacheOfRestTemplateResponse myCacheOfResponse;
-
- AgdistisCacheTests(
- @Value(value = "${local.server.port}") int testPort, //
- @Autowired RestTemplateWithCaching myRestTemplate, //
- @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
- ) {
- this.testPort = testPort;
- this.myRestTemplate = myRestTemplate;
- this.myCacheOfResponse = myCacheOfResponse;
- }
-
- @BeforeEach
- public void init() {
- assert this.myRestTemplate != null : "restTemplate cannot be null";
- }
-
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(myRestTemplate);
- assertNotNull(myCacheOfResponse);
-
- URI testServiceURL0 = new URI("http://localhost:" + testPort + "/");
- URI testServiceURL1 = new URI("http://localhost:" + testPort + "/component-description");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 5); // wait until it is too late for caching
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.NOT_CACHED); // cache miss: different URI
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * @param uri
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(URI uri, Cache cacheStatus) throws URISyntaxException {
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = myRestTemplate.getForEntity(uri, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- LOGGER.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-}
diff --git a/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisTestConfiguration.java b/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisTestConfiguration.java
index 89e910866..cbe6b3e60 100644
--- a/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisTestConfiguration.java
+++ b/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisTestConfiguration.java
@@ -15,7 +15,7 @@ public class AgdistisTestConfiguration {
System.setProperty("question2", "What is the capital of Germany?");
System.setProperty("question3", "What is the real name of Batman?");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + AgdistisCacheTests.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/CacheTests.java b/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/CacheTests.java
new file mode 100644
index 000000000..f1f38b09b
--- /dev/null
+++ b/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.agdistis.ned;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-NED-Ambiverse/pom.xml b/qanary-component-NED-Ambiverse/pom.xml
index ed8fd6734..e69f628f4 100644
--- a/qanary-component-NED-Ambiverse/pom.xml
+++ b/qanary-component-NED-Ambiverse/pom.xml
@@ -5,11 +5,12 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NED-Ambiverse
- 3.1.4
+ 3.1.5
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -99,10 +100,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NED-Babelfy/pom.xml b/qanary-component-NED-Babelfy/pom.xml
index dd8ec8588..191b2731a 100644
--- a/qanary-component-NED-Babelfy/pom.xml
+++ b/qanary-component-NED-Babelfy/pom.xml
@@ -10,10 +10,12 @@
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
qanary-component-ned-babelfy
1.4.13
@@ -23,7 +25,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.springframework.boot
@@ -82,7 +91,6 @@
-
com.google.code.gson
gson
@@ -104,10 +112,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/BabelfyCacheTests.java b/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/BabelfyCacheTests.java
deleted file mode 100644
index 584d5657c..000000000
--- a/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/BabelfyCacheTests.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package eu.wdaqua.qanary.component.babelfy.ned;
-
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-class BabelfyCacheTests {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
- private static final Logger LOGGER = LoggerFactory.getLogger(BabelfyCacheTests.class);
-
- private final int testPort;
- private final RestTemplateWithCaching myRestTemplate;
- private final CacheOfRestTemplateResponse myCacheOfResponse;
-
- BabelfyCacheTests(
- @Value(value = "${local.server.port}") int testPort, //
- @Autowired RestTemplateWithCaching myRestTemplate, //
- @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
- ) {
- this.testPort = testPort;
- this.myRestTemplate = myRestTemplate;
- this.myCacheOfResponse = myCacheOfResponse;
- }
-
- @BeforeEach
- public void init() {
- assert this.myRestTemplate != null : "restTemplate cannot be null";
- }
-
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(myRestTemplate);
- assertNotNull(myCacheOfResponse);
-
- URI testServiceURL0 = new URI("http://localhost:" + testPort + "/");
- URI testServiceURL1 = new URI("http://localhost:" + testPort + "/component-description");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 5); // wait until it is too late for caching
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.NOT_CACHED); // cache miss: different URI
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * @param uri
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(URI uri, Cache cacheStatus) throws URISyntaxException {
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = myRestTemplate.getForEntity(uri, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- LOGGER.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-}
diff --git a/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/BabelfyTestConfiguration.java b/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/BabelfyTestConfiguration.java
index 435266e67..cbe2cd228 100644
--- a/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/BabelfyTestConfiguration.java
+++ b/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/BabelfyTestConfiguration.java
@@ -15,7 +15,7 @@ public class BabelfyTestConfiguration {
System.setProperty("question2", "What is the capital of Germany?");
System.setProperty("question3", "What is the real name of Batman?");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + BabelfyCacheTests.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/CacheTests.java b/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/CacheTests.java
new file mode 100644
index 000000000..30b225185
--- /dev/null
+++ b/qanary-component-NED-Babelfy/src/test/java/eu/wdaqua/qanary/component/babelfy/ned/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.babelfy.ned;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-NED-DBpediaSpotlight/pom.xml b/qanary-component-NED-DBpediaSpotlight/pom.xml
index 914f51d6e..ef111424f 100644
--- a/qanary-component-NED-DBpediaSpotlight/pom.xml
+++ b/qanary-component-NED-DBpediaSpotlight/pom.xml
@@ -5,14 +5,17 @@
eu.wdaqua.qanary.component
qanary-component-NED-DBpediaSpotlight
3.4.0
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.1,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
2.7.9
qanary
qanary-component-ned-dbpediaspotlight
@@ -21,10 +24,17 @@
- eu.wdaqua.qanary
- qa.component
- ${qanary.version}
-
+ eu.wdaqua.qanary
+ qa.component
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
+
org.springframework.boot
spring-boot-starter-web
@@ -61,11 +71,6 @@
junit-jupiter-engine
test
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
junit
junit
@@ -115,10 +120,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/CacheTests.java b/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/CacheTests.java
new file mode 100644
index 000000000..a6b4c6f68
--- /dev/null
+++ b/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.dbpediaspotlight.ned;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/DBpediaSpotlightServiceFetcherTest.java b/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/DBpediaSpotlightServiceFetcherTest.java
index 042224acd..d7e38bbe0 100644
--- a/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/DBpediaSpotlightServiceFetcherTest.java
+++ b/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/DBpediaSpotlightServiceFetcherTest.java
@@ -1,17 +1,16 @@
package eu.wdaqua.qanary.component.dbpediaspotlight.ned;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import eu.wdaqua.qanary.commons.QanaryExceptionNoOrMultipleQuestions;
+import eu.wdaqua.qanary.commons.QanaryQuestion;
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import eu.wdaqua.qanary.component.dbpediaspotlight.ned.exceptions.DBpediaSpotlightJsonParsingNotPossible;
+import eu.wdaqua.qanary.exceptions.SparqlQueryFailed;
+import net.minidev.json.JSONObject;
+import net.minidev.json.parser.JSONParser;
+import net.minidev.json.parser.ParseException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -22,35 +21,22 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-
-import eu.wdaqua.qanary.commons.QanaryExceptionNoOrMultipleQuestions;
-import eu.wdaqua.qanary.commons.QanaryQuestion;
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import eu.wdaqua.qanary.component.dbpediaspotlight.ned.exceptions.DBpediaSpotlightJsonParsingNotPossible;
-import eu.wdaqua.qanary.exceptions.SparqlQueryFailed;
-import net.minidev.json.JSONObject;
-import net.minidev.json.parser.JSONParser;
-import net.minidev.json.parser.ParseException;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
import static eu.wdaqua.qanary.commons.config.QanaryConfiguration.endpointKey;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Application.class)
@WebAppConfiguration
class DBpediaSpotlightServiceFetcherTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
private static final Logger logger = LoggerFactory.getLogger(DBpediaSpotlightServiceFetcherTest.class);
String knownValidResponseBody = "{\"types\":\"\",\"confidence\":\"0.1\",\"text\":\"test question Berlin London Tokio\",\"Resources\":{\"Resource\":[{\"URI\":\"http:\\/\\/dbpedia.org\\/resource\\/Test_cricket\",\"support\":\"24138\",\"types\":\"\",\"surfaceForm\":\"test\",\"offset\":\"0\",\"similarityScore\":\"0.809517253401639\",\"percentageOfSecondRank\":\"0.0744734775216245\"},{\"URI\":\"http:\\/\\/dbpedia.org\\/resource\\/Berlin\",\"support\":\"87107\",\"types\":\"Wikidata:Q515,Wikidata:Q486972,Schema:Place,Schema:City,DBpedia:Settlement,DBpedia:PopulatedPlace,DBpedia:Place,DBpedia:Location,DBpedia:City\",\"surfaceForm\":\"Berlin\",\"offset\":\"14\",\"similarityScore\":\"0.9993887385897859\",\"percentageOfSecondRank\":\"3.3106570817681E-4\"},{\"URI\":\"http:\\/\\/dbpedia.org\\/resource\\/London\",\"support\":\"236613\",\"types\":\"Wikidata:Q515,Wikidata:Q486972,Schema:Place,Schema:City,DBpedia:Settlement,DBpedia:PopulatedPlace,DBpedia:Place,DBpedia:Location,DBpedia:City\",\"surfaceForm\":\"London\",\"offset\":\"21\",\"similarityScore\":\"0.9997648904521458\",\"percentageOfSecondRank\":\"7.949092738689299E-5\"},{\"URI\":\"http:\\/\\/dbpedia.org\\/resource\\/Tokyo\",\"support\":\"47818\",\"types\":\"Wikidata:Q515,Wikidata:Q486972,Schema:Place,Schema:City,DBpedia:Settlement,DBpedia:PopulatedPlace,DBpedia:Place,DBpedia:Location,DBpedia:City\",\"surfaceForm\":\"Tokio\",\"offset\":\"28\",\"similarityScore\":\"0.9983547399586975\",\"percentageOfSecondRank\":\"0.0015053572463341422\"}]},\"sparql\":\"\",\"support\":\"0\",\"policy\":\"whitelist\"}";
@Autowired
@@ -74,7 +60,7 @@ class DBpediaSpotlightServiceFetcherTest {
@BeforeEach
public void init() throws URISyntaxException, QanaryExceptionNoOrMultipleQuestions, SparqlQueryFailed, DBpediaSpotlightJsonParsingNotPossible, IOException {
assert this.restTemplate != null : "restTemplate cannot be null";
-
+
this.mockedQanaryQuestion = Mockito.mock(QanaryQuestion.class);
Mockito.when(this.mockedQanaryQuestion.getOutGraph()).thenReturn(new URI(endpointKey));
Mockito.when(this.mockedQanaryQuestion.getUri()).thenReturn(new URI("targetquestion"));
@@ -84,102 +70,6 @@ public void init() throws URISyntaxException, QanaryExceptionNoOrMultipleQuestio
this.mockedDBpediaSpotlightNED = Mockito.mock(DBpediaSpotlightNED.class);
Mockito.when(this.mockedDBpediaSpotlightNED.getSparqlInsertQuery(any(FoundDBpediaResource.class), any(QanaryQuestion.class))).thenCallRealMethod();
}
-
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(restTemplate);
- assertNotNull(myCacheOfResponse);
-
- LoginForm loginForm0 = new LoginForm("userName", "password");
- LoginForm loginForm1 = new LoginForm("userName2", "password2");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 1); // wait until it is too late for caching
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.NOT_CACHED); // cache miss: different body
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
- }
-
- /**
- * @param loginForm
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(LoginForm loginForm, Cache cacheStatus) throws URISyntaxException {
- URI TESTSERVICEURL = new URI("http://httpbin.org/post");
-
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- HttpEntity requestEntity = new HttpEntity(loginForm, headers);
-
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- logger.debug("execute POST request on {}", TESTSERVICEURL);
- ResponseEntity responseEntity = restTemplate.postForEntity(TESTSERVICEURL, requestEntity, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- logger.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-
- public class LoginForm {
- private String username;
- private String password;
-
- public LoginForm() {
- }
-
- public LoginForm(String username, String password) {
- super();
- this.username = username;
- this.password = password;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
- }
@Test
void testParsingOfJsonResponseOffline() throws ParseException, DBpediaSpotlightJsonParsingNotPossible {
@@ -220,7 +110,7 @@ void testFoundResources() throws ParseException, DBpediaSpotlightJsonParsingNotP
assertNotEquals(null, foundDBpediaResource.getResource());
}
}
-
+
@Test
void testGetSparqlInsertQuery() throws ParseException, DBpediaSpotlightJsonParsingNotPossible, URISyntaxException, QanaryExceptionNoOrMultipleQuestions, SparqlQueryFailed, IOException {
JSONParser parser = new JSONParser();
diff --git a/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/DBpediaSpotlightTestConfiguration.java b/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/DBpediaSpotlightTestConfiguration.java
index 12478f8b7..723b1b042 100644
--- a/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/DBpediaSpotlightTestConfiguration.java
+++ b/qanary-component-NED-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ned/DBpediaSpotlightTestConfiguration.java
@@ -9,7 +9,7 @@
public class DBpediaSpotlightTestConfiguration {
// define here the current CaffeineCacheManager configuration
static {
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + DBpediaSpotlightServiceFetcherTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
// deactivate the live test of the real-world webservice
System.setProperty("dbpediaspotlight.perform-live-check-on-component-start", "false");
}
diff --git a/qanary-component-NED-Dandelion/pom.xml b/qanary-component-NED-Dandelion/pom.xml
index c5bcbd4b3..e9b537859 100644
--- a/qanary-component-NED-Dandelion/pom.xml
+++ b/qanary-component-NED-Dandelion/pom.xml
@@ -4,16 +4,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NED-Dandelion
- 3.3.1
+ 3.4.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
qanary-component-ned-dandelion
1.4.13
@@ -23,7 +25,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.springframework.boot
@@ -88,7 +97,6 @@
-
com.google.code.gson
gson
@@ -110,10 +118,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/CacheTests.java b/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/CacheTests.java
new file mode 100644
index 000000000..3c0ee2c92
--- /dev/null
+++ b/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.dandelion.ned;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/DandelionCacheTest.java b/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/DandelionCacheTest.java
deleted file mode 100644
index 802ec7b9d..000000000
--- a/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/DandelionCacheTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package eu.wdaqua.qanary.component.dandelion.ned;
-
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-class DandelionCacheTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
- private static final Logger LOGGER = LoggerFactory.getLogger(DandelionCacheTest.class);
-
- private final int testPort;
- private final RestTemplateWithCaching myRestTemplate;
- private final CacheOfRestTemplateResponse myCacheOfResponse;
-
- DandelionCacheTest(
- @Value(value = "${local.server.port}") int testPort, //
- @Autowired RestTemplateWithCaching myRestTemplate, //
- @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
- ) {
- this.testPort = testPort;
- this.myRestTemplate = myRestTemplate;
- this.myCacheOfResponse = myCacheOfResponse;
- }
-
- @BeforeEach
- public void init() {
- assert this.myRestTemplate != null : "restTemplate cannot be null";
- }
-
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(myRestTemplate);
- assertNotNull(myCacheOfResponse);
-
- URI testServiceURL0 = new URI("http://localhost:" + testPort + "/");
- URI testServiceURL1 = new URI("http://localhost:" + testPort + "/component-description");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 5); // wait until it is too late for caching
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.NOT_CACHED); // cache miss: different URI
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * @param uri
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(URI uri, Cache cacheStatus) throws URISyntaxException {
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = myRestTemplate.getForEntity(uri, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- LOGGER.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-}
diff --git a/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/DandelionTestConfiguration.java b/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/DandelionTestConfiguration.java
index 49c86243d..6094cfb96 100644
--- a/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/DandelionTestConfiguration.java
+++ b/qanary-component-NED-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ned/DandelionTestConfiguration.java
@@ -14,7 +14,7 @@ public class DandelionTestConfiguration {
System.setProperty("question2", "What is the capital of Germany?");
System.setProperty("question3", "What is the real name of Batman?");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + DandelionCacheTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-NED-DiambiguationClass-OKBQA/pom.xml b/qanary-component-NED-DiambiguationClass-OKBQA/pom.xml
index 287856454..2b3c9b235 100644
--- a/qanary-component-NED-DiambiguationClass-OKBQA/pom.xml
+++ b/qanary-component-NED-DiambiguationClass-OKBQA/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NED-DiambiguationClass-OKBQA
- 3.1.3
+ 3.1.4
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -100,10 +102,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NED-MeaningCloud/pom.xml b/qanary-component-NED-MeaningCloud/pom.xml
index 49de84c2d..4310f59e9 100644
--- a/qanary-component-NED-MeaningCloud/pom.xml
+++ b/qanary-component-NED-MeaningCloud/pom.xml
@@ -5,10 +5,12 @@
eu.wdaqua.qanary.component
qanary-component-NED-MeaningCloud
3.1.0
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -103,10 +105,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NED-Ontotext/pom.xml b/qanary-component-NED-Ontotext/pom.xml
index a81f920d0..d1c7603ec 100644
--- a/qanary-component-NED-Ontotext/pom.xml
+++ b/qanary-component-NED-Ontotext/pom.xml
@@ -6,16 +6,18 @@
eu.wdaqua.qanary.component
qanary-component-NED-Ontotext
3.1.0
+
org.springframework.boot
spring-boot-starter-parent
- 2.5.5
+ 2.6.7
+
17
[3.7.0,4.0.0)
qanary
- ned-ontotext
+ qanary-component-ned-ontotext
1.4.13
@@ -89,7 +91,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqua.qanary.component.ontotext.ner.Application
+ eu.wdaqua.qanary.component.ontotext.ned.Application
@@ -99,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
@@ -117,9 +115,19 @@
push
+
+ default-2
+
+ tag
+ push
+
+
+ latest
+
+
- ${docker.image.name}
+ ${docker.image.prefix}/${docker.image.name}
${project.version}
${project.build.finalName}.jar
diff --git a/qanary-component-NED-Opentapioca/pom.xml b/qanary-component-NED-Opentapioca/pom.xml
index fc0a37bda..9649f4519 100644
--- a/qanary-component-NED-Opentapioca/pom.xml
+++ b/qanary-component-NED-Opentapioca/pom.xml
@@ -11,6 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -100,7 +101,6 @@
com.hazelcast
hazelcast-spring
-
com.google.code.gson
gson
diff --git a/qanary-component-NED-Tagme/pom.xml b/qanary-component-NED-Tagme/pom.xml
index 7e5fe837f..e463fc63b 100644
--- a/qanary-component-NED-Tagme/pom.xml
+++ b/qanary-component-NED-Tagme/pom.xml
@@ -10,6 +10,7 @@
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -103,10 +104,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NED-Watson/pom.xml b/qanary-component-NED-Watson/pom.xml
index 936c60f45..f11a6e0a3 100644
--- a/qanary-component-NED-Watson/pom.xml
+++ b/qanary-component-NED-Watson/pom.xml
@@ -11,6 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -73,7 +74,6 @@
json-path-assert
test
-
com.google.code.gson
gson
@@ -85,7 +85,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqa.qanary.component.watson.ned.Application
+ eu.wdaqua.qanary.component.watson.ned.Application
@@ -95,10 +95,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NED-Watson/src/main/java/eu/wdaqa/qanary/component/watson/ned/Application.java b/qanary-component-NED-Watson/src/main/java/eu/wdaqua/qanary/component/watson/ned/Application.java
similarity index 96%
rename from qanary-component-NED-Watson/src/main/java/eu/wdaqa/qanary/component/watson/ned/Application.java
rename to qanary-component-NED-Watson/src/main/java/eu/wdaqua/qanary/component/watson/ned/Application.java
index 07a372d83..6e2efa605 100644
--- a/qanary-component-NED-Watson/src/main/java/eu/wdaqa/qanary/component/watson/ned/Application.java
+++ b/qanary-component-NED-Watson/src/main/java/eu/wdaqua/qanary/component/watson/ned/Application.java
@@ -1,4 +1,4 @@
-package eu.wdaqa.qanary.component.watson.ned;
+package eu.wdaqua.qanary.component.watson.ned;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
diff --git a/qanary-component-NED-Watson/src/main/java/eu/wdaqa/qanary/component/watson/ned/NamedEntity.java b/qanary-component-NED-Watson/src/main/java/eu/wdaqua/qanary/component/watson/ned/NamedEntity.java
similarity index 96%
rename from qanary-component-NED-Watson/src/main/java/eu/wdaqa/qanary/component/watson/ned/NamedEntity.java
rename to qanary-component-NED-Watson/src/main/java/eu/wdaqua/qanary/component/watson/ned/NamedEntity.java
index fbebb3d07..35fdafdc1 100644
--- a/qanary-component-NED-Watson/src/main/java/eu/wdaqa/qanary/component/watson/ned/NamedEntity.java
+++ b/qanary-component-NED-Watson/src/main/java/eu/wdaqua/qanary/component/watson/ned/NamedEntity.java
@@ -1,4 +1,4 @@
-package eu.wdaqa.qanary.component.watson.ned;
+package eu.wdaqua.qanary.component.watson.ned;
public class NamedEntity {
private String uri;
diff --git a/qanary-component-NED-Watson/src/main/java/eu/wdaqa/qanary/component/watson/ned/WatsonNED.java b/qanary-component-NED-Watson/src/main/java/eu/wdaqua/qanary/component/watson/ned/WatsonNED.java
similarity index 99%
rename from qanary-component-NED-Watson/src/main/java/eu/wdaqa/qanary/component/watson/ned/WatsonNED.java
rename to qanary-component-NED-Watson/src/main/java/eu/wdaqua/qanary/component/watson/ned/WatsonNED.java
index 854e532d4..afc217f1b 100644
--- a/qanary-component-NED-Watson/src/main/java/eu/wdaqa/qanary/component/watson/ned/WatsonNED.java
+++ b/qanary-component-NED-Watson/src/main/java/eu/wdaqua/qanary/component/watson/ned/WatsonNED.java
@@ -1,4 +1,4 @@
-package eu.wdaqa.qanary.component.watson.ned;
+package eu.wdaqua.qanary.component.watson.ned;
import com.google.gson.Gson;
import eu.wdaqua.qanary.commons.QanaryMessage;
diff --git a/qanary-component-NED-Watson/src/test/java/eu/wdaqa/qanary/component/watson/ned/LiveConnectionToWatsonTest.java b/qanary-component-NED-Watson/src/test/java/eu/wdaqua/qanary/component/watson/ned/LiveConnectionToWatsonTest.java
similarity index 96%
rename from qanary-component-NED-Watson/src/test/java/eu/wdaqa/qanary/component/watson/ned/LiveConnectionToWatsonTest.java
rename to qanary-component-NED-Watson/src/test/java/eu/wdaqua/qanary/component/watson/ned/LiveConnectionToWatsonTest.java
index deff411f6..97159d15a 100644
--- a/qanary-component-NED-Watson/src/test/java/eu/wdaqa/qanary/component/watson/ned/LiveConnectionToWatsonTest.java
+++ b/qanary-component-NED-Watson/src/test/java/eu/wdaqua/qanary/component/watson/ned/LiveConnectionToWatsonTest.java
@@ -1,10 +1,11 @@
-package eu.wdaqa.qanary.component.watson.ned;
+package eu.wdaqua.qanary.component.watson.ned;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -21,6 +22,7 @@
class LiveConnectionToWatsonTest {
private static final Logger logger = LoggerFactory.getLogger(LiveConnectionToWatsonTest.class);
private final float minThreshold = 0.4f;
+ @Qualifier("watsonNED")
@Autowired
private WatsonNED myWatsonNED;
diff --git a/qanary-component-NED-Watson/src/test/java/eu/wdaqa/qanary/component/watson/ned/QanaryServiceControllerTest.java b/qanary-component-NED-Watson/src/test/java/eu/wdaqua/qanary/component/watson/ned/QanaryServiceControllerTest.java
similarity index 98%
rename from qanary-component-NED-Watson/src/test/java/eu/wdaqa/qanary/component/watson/ned/QanaryServiceControllerTest.java
rename to qanary-component-NED-Watson/src/test/java/eu/wdaqua/qanary/component/watson/ned/QanaryServiceControllerTest.java
index 565644b5b..e379e4c85 100644
--- a/qanary-component-NED-Watson/src/test/java/eu/wdaqa/qanary/component/watson/ned/QanaryServiceControllerTest.java
+++ b/qanary-component-NED-Watson/src/test/java/eu/wdaqua/qanary/component/watson/ned/QanaryServiceControllerTest.java
@@ -1,4 +1,4 @@
-package eu.wdaqa.qanary.component.watson.ned;
+package eu.wdaqua.qanary.component.watson.ned;
import eu.wdaqua.qanary.commons.QanaryMessage;
import eu.wdaqua.qanary.commons.config.QanaryConfiguration;
diff --git a/qanary-component-NER-Ambiverse/pom.xml b/qanary-component-NER-Ambiverse/pom.xml
index b967a5763..9d59f14ee 100644
--- a/qanary-component-NER-Ambiverse/pom.xml
+++ b/qanary-component-NER-Ambiverse/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-Ambiverse
- 3.1.4
+ 3.1.6
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -89,7 +91,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqua.qanary.component.ambiverse.ned.Application
+ eu.wdaqua.qanary.component.ambiverse.ner.Application
@@ -99,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-Aylien/pom.xml b/qanary-component-NER-Aylien/pom.xml
index aa1daf17f..21dc513f3 100644
--- a/qanary-component-NER-Aylien/pom.xml
+++ b/qanary-component-NER-Aylien/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-Aylien
- 3.1.2
+ 3.1.3
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -95,7 +97,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqua.qanary.component.aylien.ned.Application
+ eu.wdaqua.qanary.component.aylien.ner.Application
@@ -105,10 +107,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-Babelfy/pom.xml b/qanary-component-NER-Babelfy/pom.xml
index 640053b47..04d4d0a68 100644
--- a/qanary-component-NER-Babelfy/pom.xml
+++ b/qanary-component-NER-Babelfy/pom.xml
@@ -4,12 +4,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-Babelfy
- 3.1.2
+ 3.1.3
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -99,10 +100,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-ComicCharacterNameSimpleNamedEntityRecognizer/pom.xml b/qanary-component-NER-ComicCharacterNameSimpleNamedEntityRecognizer/pom.xml
index 97810d6d3..4bf08655f 100644
--- a/qanary-component-NER-ComicCharacterNameSimpleNamedEntityRecognizer/pom.xml
+++ b/qanary-component-NER-ComicCharacterNameSimpleNamedEntityRecognizer/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-ComicCharacterNameSimpleNamedEntityRecognizer
- 3.2.0
+ 3.2.1
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -99,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-DBpediaSpotlight/pom.xml b/qanary-component-NER-DBpediaSpotlight/pom.xml
index be430eef1..1b4ded31e 100644
--- a/qanary-component-NER-DBpediaSpotlight/pom.xml
+++ b/qanary-component-NER-DBpediaSpotlight/pom.xml
@@ -4,16 +4,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-DBpediaSpotlight
- 3.3.1
+ 3.4.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
qanary-component-ner-dbpediaspotlight
1.4.13
@@ -23,7 +25,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.springframework.boot
@@ -94,7 +103,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqua.qanary.component.ner.exceptions.dbpediaspotlight.Application
+ eu.wdaqua.qanary.component.dbpediaspotlight.ner.Application
@@ -104,10 +113,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/CacheTests.java b/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/CacheTests.java
new file mode 100644
index 000000000..68e8b6fd2
--- /dev/null
+++ b/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.dbpediaspotlight.ner;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/DBpediaSpotlightServiceFetcherTest.java b/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/DBpediaSpotlightServiceFetcherTest.java
index a535e570d..595a9c794 100644
--- a/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/DBpediaSpotlightServiceFetcherTest.java
+++ b/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/DBpediaSpotlightServiceFetcherTest.java
@@ -4,11 +4,8 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
import eu.wdaqua.qanary.component.dbpediaspotlight.ner.exceptions.DBpediaSpotlightJsonParsingNotPossible;
-import jakarta.json.Json;
-import net.minidev.json.JSONObject;
import net.minidev.json.parser.JSONParser;
import net.minidev.json.parser.ParseException;
import org.junit.jupiter.api.BeforeEach;
@@ -18,14 +15,11 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.*;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
-import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
-import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.*;
@@ -33,14 +27,10 @@
@SpringBootTest(classes = Application.class)
@WebAppConfiguration
class DBpediaSpotlightServiceFetcherTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 30;
private static final Logger logger = LoggerFactory.getLogger(DBpediaSpotlightServiceFetcherTest.class);
String knownValidResponseBody = "{\"types\":\"\",\"confidence\":\"0.1\",\"text\":\"test question Berlin London Tokio\",\"Resources\":{\"Resource\":[{\"URI\":\"http:\\/\\/dbpedia.org\\/resource\\/Test_cricket\",\"support\":\"24138\",\"types\":\"\",\"surfaceForm\":\"test\",\"offset\":\"0\",\"similarityScore\":\"0.809517253401639\",\"percentageOfSecondRank\":\"0.0744734775216245\"},{\"URI\":\"http:\\/\\/dbpedia.org\\/resource\\/Berlin\",\"support\":\"87107\",\"types\":\"Wikidata:Q515,Wikidata:Q486972,Schema:Place,Schema:City,DBpedia:Settlement,DBpedia:PopulatedPlace,DBpedia:Place,DBpedia:Location,DBpedia:City\",\"surfaceForm\":\"Berlin\",\"offset\":\"14\",\"similarityScore\":\"0.9993887385897859\",\"percentageOfSecondRank\":\"3.3106570817681E-4\"},{\"URI\":\"http:\\/\\/dbpedia.org\\/resource\\/London\",\"support\":\"236613\",\"types\":\"Wikidata:Q515,Wikidata:Q486972,Schema:Place,Schema:City,DBpedia:Settlement,DBpedia:PopulatedPlace,DBpedia:Place,DBpedia:Location,DBpedia:City\",\"surfaceForm\":\"London\",\"offset\":\"21\",\"similarityScore\":\"0.9997648904521458\",\"percentageOfSecondRank\":\"7.949092738689299E-5\"},{\"URI\":\"http:\\/\\/dbpedia.org\\/resource\\/Tokyo\",\"support\":\"47818\",\"types\":\"Wikidata:Q515,Wikidata:Q486972,Schema:Place,Schema:City,DBpedia:Settlement,DBpedia:PopulatedPlace,DBpedia:Place,DBpedia:Location,DBpedia:City\",\"surfaceForm\":\"Tokio\",\"offset\":\"28\",\"similarityScore\":\"0.9983547399586975\",\"percentageOfSecondRank\":\"0.0015053572463341422\"}]},\"sparql\":\"\",\"support\":\"0\",\"policy\":\"whitelist\"}";
@Autowired
private RestTemplateWithCaching restTemplate;
- @Autowired
- private CacheOfRestTemplateResponse myCacheOfResponse;
static {
// deactivate the live test of the real-world webservice
@@ -49,107 +39,10 @@ class DBpediaSpotlightServiceFetcherTest {
}
@BeforeEach
- public void init() throws URISyntaxException {
+ public void init() {
assert this.restTemplate != null : "restTemplate cannot be null";
}
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(restTemplate);
- assertNotNull(myCacheOfResponse);
-
- LoginForm loginForm0 = new LoginForm("userName", "password");
- LoginForm loginForm1 = new LoginForm("userName2", "password2");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 10); // wait until it is too late for caching
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.NOT_CACHED); // cache miss: different body
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * @param loginForm
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(LoginForm loginForm, Cache cacheStatus) throws URISyntaxException {
- URI TESTSERVICEURL = new URI("http://httpbin.org/post");
-
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- HttpEntity requestEntity = new HttpEntity(loginForm, headers);
-
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- logger.debug("execute POST request on {}", TESTSERVICEURL);
- ResponseEntity responseEntity = restTemplate.postForEntity(TESTSERVICEURL, requestEntity, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- logger.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-
- public class LoginForm {
- private String username;
- private String password;
-
- public LoginForm() {
- }
-
- public LoginForm(String username, String password) {
- super();
- this.username = username;
- this.password = password;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
- }
-
@Test
void testParsingOfJsonResponseOffline() throws ParseException, DBpediaSpotlightJsonParsingNotPossible {
DBpediaSpotlightServiceFetcher myFetcher = new DBpediaSpotlightServiceFetcher();
diff --git a/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/DBpediaSpotlightTestConfiguration.java b/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/DBpediaSpotlightTestConfiguration.java
index d2fbd1acb..7cb363d4b 100644
--- a/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/DBpediaSpotlightTestConfiguration.java
+++ b/qanary-component-NER-DBpediaSpotlight/src/test/java/eu/wdaqua/qanary/component/dbpediaspotlight/ner/DBpediaSpotlightTestConfiguration.java
@@ -9,7 +9,7 @@
public class DBpediaSpotlightTestConfiguration {
// define here the current CaffeineCacheManager configuration
static {
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + DBpediaSpotlightServiceFetcherTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
// deactivate the live test of the real-world webservice
System.setProperty("dbpediaspotlight.perform-live-check-on-component-start", "false");
}
diff --git a/qanary-component-NER-Dandelion/pom.xml b/qanary-component-NER-Dandelion/pom.xml
index 4a400e4cc..766fc8ce8 100644
--- a/qanary-component-NER-Dandelion/pom.xml
+++ b/qanary-component-NER-Dandelion/pom.xml
@@ -4,16 +4,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-Dandelion
- 3.3.1
+ 3.4.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
qanary-component-ner-dandelion
1.4.13
@@ -23,7 +25,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.springframework.boot
diff --git a/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/CacheTests.java b/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/CacheTests.java
new file mode 100644
index 000000000..d23a788cc
--- /dev/null
+++ b/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.dandelion.ner;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/DandelionCacheTest.java b/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/DandelionCacheTest.java
deleted file mode 100644
index edf435670..000000000
--- a/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/DandelionCacheTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package eu.wdaqua.qanary.component.dandelion.ner;
-
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-class DandelionCacheTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
- private static final Logger LOGGER = LoggerFactory.getLogger(DandelionCacheTest.class);
-
- private final int testPort;
- private final RestTemplateWithCaching myRestTemplate;
- private final CacheOfRestTemplateResponse myCacheOfResponse;
-
- DandelionCacheTest(
- @Value(value = "${local.server.port}") int testPort, //
- @Autowired RestTemplateWithCaching myRestTemplate, //
- @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
- ) {
- this.testPort = testPort;
- this.myRestTemplate = myRestTemplate;
- this.myCacheOfResponse = myCacheOfResponse;
- }
-
- @BeforeEach
- public void init() {
- assert this.myRestTemplate != null : "restTemplate cannot be null";
- }
-
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(myRestTemplate);
- assertNotNull(myCacheOfResponse);
-
- URI testServiceURL0 = new URI("http://localhost:" + testPort + "/");
- URI testServiceURL1 = new URI("http://localhost:" + testPort + "/component-description");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 5); // wait until it is too late for caching
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.NOT_CACHED); // cache miss: different URI
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * @param uri
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(URI uri, Cache cacheStatus) throws URISyntaxException {
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = myRestTemplate.getForEntity(uri, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- LOGGER.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-}
diff --git a/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/DandelionTestConfiguration.java b/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/DandelionTestConfiguration.java
index d08b2a390..f48f4d9f1 100644
--- a/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/DandelionTestConfiguration.java
+++ b/qanary-component-NER-Dandelion/src/test/java/eu/wdaqua/qanary/component/dandelion/ner/DandelionTestConfiguration.java
@@ -15,7 +15,7 @@ public class DandelionTestConfiguration {
System.setProperty("question2", "What is the capital of Germany?");
System.setProperty("question3", "What is the real name of Batman?");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + DandelionCacheTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-NER-EntityClassifier/pom.xml b/qanary-component-NER-EntityClassifier/pom.xml
index 8b3aa7848..79f0ec3fb 100644
--- a/qanary-component-NER-EntityClassifier/pom.xml
+++ b/qanary-component-NER-EntityClassifier/pom.xml
@@ -4,12 +4,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-EntityClassifier
- 3.1.2
+ 3.1.3
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -99,10 +100,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-EntityClassifier2/pom.xml b/qanary-component-NER-EntityClassifier2/pom.xml
index 7364157d2..5be2cdcb8 100644
--- a/qanary-component-NER-EntityClassifier2/pom.xml
+++ b/qanary-component-NER-EntityClassifier2/pom.xml
@@ -4,12 +4,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-EntityClassifier2
- 3.1.2
+ 3.1.3
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -99,10 +100,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-FOX/pom.xml b/qanary-component-NER-FOX/pom.xml
index 5d16e0f6e..bb22aa50d 100644
--- a/qanary-component-NER-FOX/pom.xml
+++ b/qanary-component-NER-FOX/pom.xml
@@ -3,12 +3,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-Fox
- 3.1.2
+ 3.1.3
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -98,10 +99,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-MeaningCloud/pom.xml b/qanary-component-NER-MeaningCloud/pom.xml
index 41fdc763b..d4cd03976 100644
--- a/qanary-component-NER-MeaningCloud/pom.xml
+++ b/qanary-component-NER-MeaningCloud/pom.xml
@@ -4,16 +4,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-MeaningCloud
- 3.3.1
+ 3.4.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
qanary-component-ner-meaning-cloud
1.4.13
@@ -23,7 +25,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.springframework.boot
@@ -82,7 +91,6 @@
-
com.google.code.gson
gson
@@ -104,10 +112,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/CacheTests.java b/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/CacheTests.java
new file mode 100644
index 000000000..18ae005eb
--- /dev/null
+++ b/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.meaningcloud.ner;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/MeaningCloudCacheTest.java b/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/MeaningCloudCacheTest.java
deleted file mode 100644
index 8e9ea4daa..000000000
--- a/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/MeaningCloudCacheTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package eu.wdaqua.qanary.component.meaningcloud.ner;
-
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-class MeaningCloudCacheTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
- private static final Logger LOGGER = LoggerFactory.getLogger(MeaningCloudCacheTest.class);
-
- private final int testPort;
- private final RestTemplateWithCaching myRestTemplate;
- private final CacheOfRestTemplateResponse myCacheOfResponse;
-
- MeaningCloudCacheTest(
- @Value(value = "${local.server.port}") int testPort, //
- @Autowired RestTemplateWithCaching myRestTemplate, //
- @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
- ) {
- this.testPort = testPort;
- this.myRestTemplate = myRestTemplate;
- this.myCacheOfResponse = myCacheOfResponse;
- }
-
- @BeforeEach
- public void init() {
- assert this.myRestTemplate != null : "restTemplate cannot be null";
- }
-
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(myRestTemplate);
- assertNotNull(myCacheOfResponse);
-
- URI testServiceURL0 = new URI("http://localhost:" + testPort + "/");
- URI testServiceURL1 = new URI("http://localhost:" + testPort + "/component-description");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 5); // wait until it is too late for caching
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.NOT_CACHED); // cache miss: different URI
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * @param uri
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(URI uri, Cache cacheStatus) throws URISyntaxException {
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = myRestTemplate.getForEntity(uri, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- LOGGER.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-}
diff --git a/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/MeaningCloudTestConfiguration.java b/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/MeaningCloudTestConfiguration.java
index 65cd442f3..d19db5ee0 100644
--- a/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/MeaningCloudTestConfiguration.java
+++ b/qanary-component-NER-MeaningCloud/src/test/java/eu/wdaqua/qanary/component/meaningcloud/ner/MeaningCloudTestConfiguration.java
@@ -14,7 +14,7 @@ public class MeaningCloudTestConfiguration {
System.setProperty("question2", "What is the capital of Germany?");
System.setProperty("question3", "What is the real name of Batman?");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + MeaningCloudCacheTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-NER-Ontotext/pom.xml b/qanary-component-NER-Ontotext/pom.xml
index 06b039972..86957df6a 100644
--- a/qanary-component-NER-Ontotext/pom.xml
+++ b/qanary-component-NER-Ontotext/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-Ontotext
- 3.1.2
+ 3.1.3
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -99,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-Stanford/pom.xml b/qanary-component-NER-Stanford/pom.xml
index 3a7bff93c..c0805ff3a 100644
--- a/qanary-component-NER-Stanford/pom.xml
+++ b/qanary-component-NER-Stanford/pom.xml
@@ -5,10 +5,12 @@
eu.wdaqua.qanary.component
qanary-component-NER-Stanford
3.1.7
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
[3.7.1,4.0.0)
@@ -100,7 +102,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqua.qanary.StanfordNER.Application
+ eu.wdaqua.qanary.component.stanford.ner.Application
@@ -110,10 +112,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-Tagme/pom.xml b/qanary-component-NER-Tagme/pom.xml
index 773efe445..ad21e0437 100644
--- a/qanary-component-NER-Tagme/pom.xml
+++ b/qanary-component-NER-Tagme/pom.xml
@@ -4,16 +4,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-Tagme
- 3.3.1
+ 3.4.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
qanary-component-ner-tagme
1.4.13
@@ -23,7 +25,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.springframework.boot
@@ -82,7 +91,6 @@
-
com.google.code.gson
gson
@@ -94,7 +102,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqua.qanary.component.tagme.ned.Application
+ eu.wdaqua.qanary.component.tagme.ner.Application
@@ -104,10 +112,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/CacheTests.java b/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/CacheTests.java
new file mode 100644
index 000000000..38f5daa3f
--- /dev/null
+++ b/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.tagme.ner;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/TagmeCacheTest.java b/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/TagmeCacheTest.java
deleted file mode 100644
index b613f840c..000000000
--- a/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/TagmeCacheTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package eu.wdaqua.qanary.component.tagme.ner;
-
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-class TagmeCacheTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
- private static final Logger LOGGER = LoggerFactory.getLogger(TagmeCacheTest.class);
-
- private final int testPort;
- private final RestTemplateWithCaching myRestTemplate;
- private final CacheOfRestTemplateResponse myCacheOfResponse;
-
- TagmeCacheTest(
- @Value(value = "${local.server.port}") int testPort, //
- @Autowired RestTemplateWithCaching myRestTemplate, //
- @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
- ) {
- this.testPort = testPort;
- this.myRestTemplate = myRestTemplate;
- this.myCacheOfResponse = myCacheOfResponse;
- }
-
- @BeforeEach
- public void init() {
- assert this.myRestTemplate != null : "restTemplate cannot be null";
- }
-
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(myRestTemplate);
- assertNotNull(myCacheOfResponse);
-
- URI testServiceURL0 = new URI("http://localhost:" + testPort + "/");
- URI testServiceURL1 = new URI("http://localhost:" + testPort + "/component-description");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 5); // wait until it is too late for caching
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.NOT_CACHED); // cache miss: different URI
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * @param uri
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(URI uri, Cache cacheStatus) throws URISyntaxException {
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = myRestTemplate.getForEntity(uri, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- LOGGER.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-}
diff --git a/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/TagmeTestConfiguration.java b/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/TagmeTestConfiguration.java
index 6c27b9b00..b21348d6e 100644
--- a/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/TagmeTestConfiguration.java
+++ b/qanary-component-NER-Tagme/src/test/java/eu/wdaqua/qanary/component/tagme/ner/TagmeTestConfiguration.java
@@ -14,7 +14,7 @@ public class TagmeTestConfiguration {
System.setProperty("question2", "What is the capital of Germany?");
System.setProperty("question3", "What is the real name of Batman?");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + TagmeCacheTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
System.setProperty("tagme.api.threshold", "0.0");
}
diff --git a/qanary-component-NER-TextRazor/pom.xml b/qanary-component-NER-TextRazor/pom.xml
index d79875bd6..a931d9d80 100644
--- a/qanary-component-NER-TextRazor/pom.xml
+++ b/qanary-component-NER-TextRazor/pom.xml
@@ -4,16 +4,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NER-TextRazor
- 3.3.1
+ 3.4.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.1,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
qanary-component-ner-textrazor
1.4.13
@@ -23,7 +25,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.springframework.boot
@@ -82,7 +91,6 @@
-
com.google.code.gson
gson
@@ -104,10 +112,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/CacheTests.java b/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/CacheTests.java
new file mode 100644
index 000000000..0b09baa80
--- /dev/null
+++ b/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.textrazor.ner;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/TextRazorCacheTest.java b/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/TextRazorCacheTest.java
deleted file mode 100644
index 9778dde14..000000000
--- a/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/TextRazorCacheTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package eu.wdaqua.qanary.component.textrazor.ner;
-
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-class TextRazorCacheTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
- private static final Logger LOGGER = LoggerFactory.getLogger(TextRazorCacheTest.class);
-
- private final int testPort;
- private final RestTemplateWithCaching myRestTemplate;
- private final CacheOfRestTemplateResponse myCacheOfResponse;
-
- TextRazorCacheTest(
- @Value(value = "${local.server.port}") int testPort, //
- @Autowired RestTemplateWithCaching myRestTemplate, //
- @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
- ) {
- this.testPort = testPort;
- this.myRestTemplate = myRestTemplate;
- this.myCacheOfResponse = myCacheOfResponse;
- }
-
- @BeforeEach
- public void init() {
- assert this.myRestTemplate != null : "restTemplate cannot be null";
- }
-
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(myRestTemplate);
- assertNotNull(myCacheOfResponse);
-
- URI testServiceURL0 = new URI("http://localhost:" + testPort + "/");
- URI testServiceURL1 = new URI("http://localhost:" + testPort + "/component-description");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 5); // wait until it is too late for caching
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.NOT_CACHED); // cache miss: different URI
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * @param uri
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(URI uri, Cache cacheStatus) throws URISyntaxException {
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = myRestTemplate.getForEntity(uri, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- LOGGER.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-}
diff --git a/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/TextRazorTestConfiguration.java b/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/TextRazorTestConfiguration.java
index 929ab7703..0e73ee1e5 100644
--- a/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/TextRazorTestConfiguration.java
+++ b/qanary-component-NER-TextRazor/src/test/java/eu/wdaqua/qanary/component/textrazor/ner/TextRazorTestConfiguration.java
@@ -14,7 +14,7 @@ public class TextRazorTestConfiguration {
System.setProperty("question2", "What is the capital of Germany?");
System.setProperty("question3", "What is the real name of Batman?");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + TextRazorCacheTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-NERD-Alchemy/pom.xml b/qanary-component-NERD-Alchemy/pom.xml
index d6acf249f..7efe0d884 100644
--- a/qanary-component-NERD-Alchemy/pom.xml
+++ b/qanary-component-NERD-Alchemy/pom.xml
@@ -4,12 +4,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NERD-Alchemy
- 3.1.2
+ 3.1.3
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -104,10 +105,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NERD-LuceneLinker/pom.xml b/qanary-component-NERD-LuceneLinker/pom.xml
index 24758e1c2..4e0974a70 100644
--- a/qanary-component-NERD-LuceneLinker/pom.xml
+++ b/qanary-component-NERD-LuceneLinker/pom.xml
@@ -3,12 +3,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NERD-LuceneLinker
- 3.1.5
+ 3.1.6
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -118,10 +119,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-NERD-SMAPH/pom.xml b/qanary-component-NERD-SMAPH/pom.xml
index c3ba2e76e..cf07aba9a 100644
--- a/qanary-component-NERD-SMAPH/pom.xml
+++ b/qanary-component-NERD-SMAPH/pom.xml
@@ -10,6 +10,7 @@
org.springframework.boot
spring-boot-starter-parent
2.7.0
+
17
@@ -100,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
com.spotify
dockerfile-maven-plugin
diff --git a/qanary-component-QB-AnnotationOfSpotClass-OKBQA/pom.xml b/qanary-component-QB-AnnotationOfSpotClass-OKBQA/pom.xml
index 06575d4ac..57ff0b10f 100644
--- a/qanary-component-QB-AnnotationOfSpotClass-OKBQA/pom.xml
+++ b/qanary-component-QB-AnnotationOfSpotClass-OKBQA/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-AnnotationOfSpotClass-OKBQA
- 3.1.2
+ 3.1.3
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -99,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QB-BirthDataWikidata/pom.xml b/qanary-component-QB-BirthDataWikidata/pom.xml
index 9b4eaeada..63da4e5d5 100644
--- a/qanary-component-QB-BirthDataWikidata/pom.xml
+++ b/qanary-component-QB-BirthDataWikidata/pom.xml
@@ -11,6 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -120,10 +121,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/pom.xml b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/pom.xml
index 2d5cb06a1..3633d4b82 100644
--- a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/pom.xml
+++ b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia
- 3.2.0
+ 3.2.2
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -99,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/resources/queries/insert_one_annotation_test.rq b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/resources/queries/insert_one_annotation_test.rq
index 907cc407b..fdd31edc5 100644
--- a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/resources/queries/insert_one_annotation_test.rq
+++ b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/resources/queries/insert_one_annotation_test.rq
@@ -17,6 +17,6 @@ INSERT {
}
}
WHERE
- { BIND(iri(str(rand())) AS ?newAnnotation)
+ { BIND(IRI(str(rand())) AS ?newAnnotation)
BIND(now() AS ?time)
}
diff --git a/qanary-component-QB-GAnswerWrapper/pom.xml b/qanary-component-QB-GAnswerWrapper/pom.xml
index 536727aac..c72562f87 100644
--- a/qanary-component-QB-GAnswerWrapper/pom.xml
+++ b/qanary-component-QB-GAnswerWrapper/pom.xml
@@ -5,16 +5,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-GAnswerWrapper
- 3.1.5
+ 3.2.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
2.7.10
qanary
@@ -28,13 +30,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
-
-
- org.apache.logging.log4j
- log4j-to-slf4j
-
-
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.apache.logging.log4j
@@ -116,7 +119,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqua.qanary.g_answer_wrapper.Application
+ eu.wdaqua.qanary.component.ganswerwrapper.qb.Application
@@ -126,10 +129,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/CacheTests.java b/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/CacheTests.java
new file mode 100644
index 000000000..4d882d5a7
--- /dev/null
+++ b/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.ganswerwrapper.qb;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/GAnswerQueryBuilderTest.java b/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/GAnswerQueryBuilderTest.java
index 2aef51d92..c6585a353 100644
--- a/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/GAnswerQueryBuilderTest.java
+++ b/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/GAnswerQueryBuilderTest.java
@@ -12,7 +12,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
-import org.springframework.http.*;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
@@ -20,7 +19,6 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.*;
@@ -71,35 +69,6 @@ void testIsLangSuppoerted() throws Exception {
assertFalse(gAnswerQueryBuilder.isLangSuppoerted("se"));
}
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(restTemplate);
- assertNotNull(myCacheOfResponse);
-
- LoginForm loginForm0 = new LoginForm("userName", "password");
- LoginForm loginForm1 = new LoginForm("userName2", "password2");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 1); // wait until it is too late for caching
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.NOT_CACHED); // cache miss: different body
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
/**
* @throws URISyntaxException
*/
@@ -123,39 +92,6 @@ void liveTest() throws URISyntaxException {
assertEquals(result0.getSparql(), expectedSparql);
}
- /**
- * @param loginForm
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(LoginForm loginForm, Cache cacheStatus) throws URISyntaxException {
- URI TESTSERVICEURL = new URI("http://httpbin.org/post");
-
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- HttpEntity requestEntity = new HttpEntity(loginForm, headers);
-
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = restTemplate.postForEntity(TESTSERVICEURL, requestEntity, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- logger.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
/**
* @param myApp
* @param question
@@ -169,38 +105,4 @@ private GAnswerResult testWebService(GAnswerQueryBuilder myApp, String question,
return result;
}
- private enum Cache {
- CACHED, NOT_CACHED
- }
-
- public class LoginForm {
- private String username;
- private String password;
-
- public LoginForm() {
- }
-
- public LoginForm(String username, String password) {
- super();
- this.username = username;
- this.password = password;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
- }
-
}
diff --git a/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/GAnswerTestConfiguration.java b/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/GAnswerTestConfiguration.java
index d510b36b7..7d1cd29d8 100644
--- a/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/GAnswerTestConfiguration.java
+++ b/qanary-component-QB-GAnswerWrapper/src/test/java/eu/wdaqua/qanary/component/ganswerwrapper/qb/GAnswerTestConfiguration.java
@@ -11,7 +11,7 @@ public class GAnswerTestConfiguration {
static {
System.setProperty("g_answer.endpoint.url", "http://some-ganswer-endpoint-url.com/endpoint");
System.setProperty("g_answer.mock.endpoint.url", "http://some-ganswer-endpoint-url.com/endpoint");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + GAnswerQueryBuilderTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-QB-MonoliticWrapper/pom.xml b/qanary-component-QB-MonoliticWrapper/pom.xml
index f156820a2..a57c05b14 100644
--- a/qanary-component-QB-MonoliticWrapper/pom.xml
+++ b/qanary-component-QB-MonoliticWrapper/pom.xml
@@ -4,12 +4,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-MonoliticWrapper
- 3.1.1
+ 3.1.2
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
11
@@ -105,10 +106,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QB-PlatypusWrapper/pom.xml b/qanary-component-QB-PlatypusWrapper/pom.xml
index de4c9a689..6c1c2f900 100644
--- a/qanary-component-QB-PlatypusWrapper/pom.xml
+++ b/qanary-component-QB-PlatypusWrapper/pom.xml
@@ -5,16 +5,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-PlatypusWrapper
- 3.2.0
+ 3.3.1
org.springframework.boot
spring-boot-starter-parent
2.7.9
+
17
- [3.7.1,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
diff --git a/qanary-component-QB-PlatypusWrapper/src/main/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusQueryBuilderController.java b/qanary-component-QB-PlatypusWrapper/src/main/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusQueryBuilderController.java
index 5dff5680a..2eb836af7 100644
--- a/qanary-component-QB-PlatypusWrapper/src/main/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusQueryBuilderController.java
+++ b/qanary-component-QB-PlatypusWrapper/src/main/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusQueryBuilderController.java
@@ -1,8 +1,8 @@
package eu.wdaqua.qanary.component.platypuswrapper.qb;
-import java.net.URI;
-import java.net.URISyntaxException;
-
+import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.DataNotProcessableException;
+import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.PlatypusRequest;
+import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.PlatypusResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -12,9 +12,8 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
-import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.DataNotProcessableException;
-import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.PlatypusRequest;
-import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.PlatypusResult;
+import java.net.URI;
+import java.net.URISyntaxException;
@Controller
public class PlatypusQueryBuilderController {
diff --git a/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/CacheTests.java b/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/CacheTests.java
new file mode 100644
index 000000000..8d2e9575c
--- /dev/null
+++ b/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.platypuswrapper.qb;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/MockPlatypusQueryBuilderTest.java b/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/MockPlatypusQueryBuilderTest.java
index 5eb4f18c8..3622e4e8e 100644
--- a/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/MockPlatypusQueryBuilderTest.java
+++ b/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/MockPlatypusQueryBuilderTest.java
@@ -1,15 +1,9 @@
package eu.wdaqua.qanary.component.platypuswrapper.qb;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.DataNotProcessableException;
+import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.PlatypusResult;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
@@ -22,10 +16,15 @@
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.client.MockRestServiceServer;
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.DataNotProcessableException;
-import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.PlatypusResult;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Application.class)
@@ -36,6 +35,7 @@ class MockPlatypusQueryBuilderTest {
private final String testQueryFilename = "/queries/test_query_of_platypus_api.rq";
MockRestServiceServer mockServer;
private URI endpoint;
+ private final String applicationName = "PlatypusQueryBuilder";
@Autowired
private Environment env;
private CacheOfRestTemplateResponse myCacheOfResponse = new CacheOfRestTemplateResponse();
diff --git a/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusQueryBuilderTest.java b/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusQueryBuilderTest.java
index f4dcba9bd..45ffbc161 100644
--- a/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusQueryBuilderTest.java
+++ b/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusQueryBuilderTest.java
@@ -1,20 +1,10 @@
package eu.wdaqua.qanary.component.platypuswrapper.qb;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.DataNotProcessableException;
+import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.PlatypusResult;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
@@ -24,18 +14,16 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit.jupiter.EnabledIf;
import org.springframework.test.context.junit.jupiter.SpringExtension;
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.DataNotProcessableException;
-import eu.wdaqua.qanary.component.platypuswrapper.qb.messages.PlatypusResult;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Application.class)
@@ -43,8 +31,6 @@
@ComponentScan("eu.wdaqua.qanary")
@AutoConfigureWebClient
class PlatypusQueryBuilderTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
private static final Logger logger = LoggerFactory.getLogger(PlatypusQueryBuilderTest.class);
private final String applicationName = "PlatypusQueryBuilder";
private URI endpoint;
@@ -101,37 +87,7 @@ void testIsLangSuppoerted() throws Exception {
}
/**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- @EnabledIf(expression = "#{environment['platypus.api.live.test.active'] == 'true'}", loadContext = true)
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(restTemplate);
- assertNotNull(myCacheOfResponse);
-
- LoginForm loginForm0 = new LoginForm("userName", "password");
- LoginForm loginForm1 = new LoginForm("userName2", "password2");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 1); // wait until it is too late for caching
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.NOT_CACHED); // cache miss: different body
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * Test answer with date literal
+ * Test answer with date literal
* @throws URISyntaxException
* @throws DataNotProcessableException
*/
@@ -157,8 +113,8 @@ void testWebServiceWhenWasAngelaMerkelBornResultOneDate() throws URISyntaxExcept
assertEquals(expectedType, result0.getDatatype());
}
-
- // TODO: test answer with boolean
+
+ // TODO: test answer with boolean
// TODO: test answer with string literal
// TODO: test answer with float literal
// TODO: test answer with integer literal
@@ -166,7 +122,7 @@ void testWebServiceWhenWasAngelaMerkelBornResultOneDate() throws URISyntaxExcept
/**
* Test answer with resource
*
- * capital of Germany usually returns two resources (Berlin and Bonn),
+ * capital of Germany usually returns two resources (Berlin and Bonn),
* consider a different question
*
* @throws URISyntaxException
@@ -194,39 +150,6 @@ void testWebServiceWhatIsTheCapitalOfGermanyResultAtLeastOneResource() throws UR
assertEquals(expectedType, result0.getDatatype());
}
- /**
- * @param loginForm
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(LoginForm loginForm, Cache cacheStatus) throws URISyntaxException {
- URI TESTSERVICEURL = new URI("http://httpbin.org/post");
-
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- HttpEntity requestEntity = new HttpEntity(loginForm, headers);
-
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = restTemplate.postForEntity(TESTSERVICEURL, requestEntity, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- logger.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
/**
* @param myApp
* @param question
@@ -241,38 +164,4 @@ private PlatypusResult testWebService(PlatypusQueryBuilder myApp, String questio
return result;
}
- private enum Cache {
- CACHED, NOT_CACHED
- }
-
- public class LoginForm {
- private String username;
- private String password;
-
- public LoginForm() {
- }
-
- public LoginForm(String username, String password) {
- super();
- this.username = username;
- this.password = password;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
- }
-
}
diff --git a/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusTestConfiguration.java b/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusTestConfiguration.java
index eaac76766..f9577aade 100644
--- a/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusTestConfiguration.java
+++ b/qanary-component-QB-PlatypusWrapper/src/test/java/eu/wdaqua/qanary/component/platypuswrapper/qb/PlatypusTestConfiguration.java
@@ -11,7 +11,7 @@ public class PlatypusTestConfiguration {
static {
System.setProperty("platypus.endpoint.url", "https://qa.askplatyp.us/v0/ask");
System.setProperty("platypus.mock.endpoint.url", "http://some-platypus-endpoint-url.com/endpoint");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + PlatypusQueryBuilderTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-QB-QAnswer/pom.xml b/qanary-component-QB-QAnswer/pom.xml
index 0a1c55b02..bd3dde1b9 100644
--- a/qanary-component-QB-QAnswer/pom.xml
+++ b/qanary-component-QB-QAnswer/pom.xml
@@ -10,6 +10,7 @@
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
11
@@ -100,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QB-RuBQWrapper/pom.xml b/qanary-component-QB-RuBQWrapper/pom.xml
index de2f1755e..b6e42c7f6 100644
--- a/qanary-component-QB-RuBQWrapper/pom.xml
+++ b/qanary-component-QB-RuBQWrapper/pom.xml
@@ -5,16 +5,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-RuBQWrapper
- 3.1.6
+ 3.2.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
2.6.7
qanary
@@ -29,13 +31,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
-
-
- org.apache.logging.log4j
- log4j-to-slf4j
-
-
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.apache.logging.log4j
@@ -117,7 +120,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqua.qanary.rubq_wrapper.Application
+ eu.wdaqua.qanary.component.rubqwrapper.qb.Application
@@ -127,10 +130,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/CacheTests.java b/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/CacheTests.java
new file mode 100644
index 000000000..5c55d2309
--- /dev/null
+++ b/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.rubqwrapper.qb;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/RuBQQueryBuilderTest.java b/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/RuBQQueryBuilderTest.java
index 0621246e9..8e2cbfcf6 100644
--- a/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/RuBQQueryBuilderTest.java
+++ b/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/RuBQQueryBuilderTest.java
@@ -12,7 +12,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
-import org.springframework.http.*;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
@@ -20,7 +19,6 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.*;
@@ -71,35 +69,6 @@ void testIsLangSuppoerted() throws Exception {
assertFalse(ruBQQueryBuilder.isLangSuppoerted("se"));
}
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(restTemplate);
- assertNotNull(myCacheOfResponse);
-
- LoginForm loginForm0 = new LoginForm("userName", "password");
- LoginForm loginForm1 = new LoginForm("userName2", "password2");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 1); // wait until it is too late for caching
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.NOT_CACHED); // cache miss: different body
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
/**
* @throws URISyntaxException
*/
@@ -123,39 +92,6 @@ void liveTest() throws URISyntaxException {
assertEquals(result0.getSparql(), expectedSparql);
}
- /**
- * @param loginForm
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(LoginForm loginForm, Cache cacheStatus) throws URISyntaxException {
- URI TESTSERVICEURL = new URI("http://httpbin.org/post");
-
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- HttpEntity requestEntity = new HttpEntity(loginForm, headers);
-
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = restTemplate.postForEntity(TESTSERVICEURL, requestEntity, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- logger.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
/**
* @param myApp
* @param question
@@ -169,38 +105,4 @@ private RuBQResult testWebService(RuBQQueryBuilder myApp, String question, Strin
return result;
}
- private enum Cache {
- CACHED, NOT_CACHED
- }
-
- public class LoginForm {
- private String username;
- private String password;
-
- public LoginForm() {
- }
-
- public LoginForm(String username, String password) {
- super();
- this.username = username;
- this.password = password;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
- }
-
}
diff --git a/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/RuBQTestConfiguration.java b/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/RuBQTestConfiguration.java
index a8fa4238c..7ae0c8180 100644
--- a/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/RuBQTestConfiguration.java
+++ b/qanary-component-QB-RuBQWrapper/src/test/java/eu/wdaqua/qanary/component/rubqwrapper/qb/RuBQTestConfiguration.java
@@ -11,7 +11,7 @@ public class RuBQTestConfiguration {
static {
System.setProperty("rubq.endpoint.url", "http://some-rubq-endpoint-url.com/endpoint");
System.setProperty("rubq.mock.endpoint.url", "http://some-rubq-endpoint-url.com/endpoint");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + RuBQQueryBuilderTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-QB-SimpleRealNameOfSuperHero/pom.xml b/qanary-component-QB-SimpleRealNameOfSuperHero/pom.xml
index 4efeb920c..289e6b5ad 100644
--- a/qanary-component-QB-SimpleRealNameOfSuperHero/pom.xml
+++ b/qanary-component-QB-SimpleRealNameOfSuperHero/pom.xml
@@ -6,10 +6,12 @@
eu.wdaqua.qanary.component
qanary-component-QB-SimpleRealNameOfSuperHero
3.1.6
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -127,10 +129,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QB-Sina/pom.xml b/qanary-component-QB-Sina/pom.xml
index 95333fca3..af61a4798 100644
--- a/qanary-component-QB-Sina/pom.xml
+++ b/qanary-component-QB-Sina/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-Sina
- 3.2.3
+ 3.2.4
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -106,12 +108,6 @@
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
diff --git a/qanary-component-QB-TeBaQaWrapper/pom.xml b/qanary-component-QB-TeBaQaWrapper/pom.xml
index 5ff5ada9d..caa914c9d 100644
--- a/qanary-component-QB-TeBaQaWrapper/pom.xml
+++ b/qanary-component-QB-TeBaQaWrapper/pom.xml
@@ -5,16 +5,18 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-TeBaQAWrapper
- 3.1.6
+ 3.2.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
2.6.7
qanary
@@ -26,17 +28,18 @@
-
- eu.wdaqua.qanary
- qa.component
- ${qanary.version}
-
-
- org.apache.logging.log4j
- log4j-to-slf4j
-
-
-
+
+ eu.wdaqua.qanary
+ qa.component
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
+
org.apache.logging.log4j
log4j-to-slf4j
@@ -117,7 +120,7 @@
org.springframework.boot
spring-boot-maven-plugin
- eu.wdaqua.qanary.tebaqa_wrapper.Application
+ eu.wdaqua.qanary.component.tebaqawrapper.qb.Application
@@ -127,10 +130,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/CacheTests.java b/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/CacheTests.java
new file mode 100644
index 000000000..a69613f9d
--- /dev/null
+++ b/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.tebaqawrapper.qb;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/TeBaQAQueryBuilderTest.java b/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/TeBaQAQueryBuilderTest.java
index 490ba2f06..346e767d5 100644
--- a/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/TeBaQAQueryBuilderTest.java
+++ b/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/TeBaQAQueryBuilderTest.java
@@ -12,7 +12,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
-import org.springframework.http.*;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
@@ -20,7 +19,6 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.*;
@@ -28,8 +26,6 @@
@SpringBootTest(classes = Application.class)
@WebAppConfiguration
class TeBaQAQueryBuilderTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
private static final Logger logger = LoggerFactory.getLogger(TeBaQAQueryBuilderTest.class);
private final String applicationName = "TeBaQAQueryBuilderTest";
private URI endpoint;
@@ -71,35 +67,6 @@ void testIsLangSuppoerted() throws Exception {
assertFalse(teBaQAQueryBuilder.isLangSupported("se"));
}
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(restTemplate);
- assertNotNull(myCacheOfResponse);
-
- LoginForm loginForm0 = new LoginForm("userName", "password");
- LoginForm loginForm1 = new LoginForm("userName2", "password2");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 1); // wait until it is too late for caching
- callRestTemplateWithCaching(loginForm0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.NOT_CACHED); // cache miss: different body
- callRestTemplateWithCaching(loginForm0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(loginForm1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
/**
* @throws URISyntaxException
*/
@@ -120,39 +87,6 @@ void liveTest() throws URISyntaxException {
assertEquals(result0.getSparql(), expectedSparql);
}
- /**
- * @param loginForm
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(LoginForm loginForm, Cache cacheStatus) throws URISyntaxException {
- URI TESTSERVICEURL = new URI("http://httpbin.org/post");
-
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- HttpEntity requestEntity = new HttpEntity(loginForm, headers);
-
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = restTemplate.postForEntity(TESTSERVICEURL, requestEntity, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- logger.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
/**
* @param myApp
* @param question
@@ -166,38 +100,4 @@ private TeBaQAResult testWebService(TeBaQAQueryBuilder myApp, String question, S
return result;
}
- private enum Cache {
- CACHED, NOT_CACHED
- }
-
- public class LoginForm {
- private String username;
- private String password;
-
- public LoginForm() {
- }
-
- public LoginForm(String username, String password) {
- super();
- this.username = username;
- this.password = password;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
- }
-
}
diff --git a/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/TeBeQaTestConfiguration.java b/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/TeBeQaTestConfiguration.java
index e8563144e..c76ad3881 100644
--- a/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/TeBeQaTestConfiguration.java
+++ b/qanary-component-QB-TeBaQaWrapper/src/test/java/eu/wdaqua/qanary/component/tebaqawrapper/qb/TeBeQaTestConfiguration.java
@@ -11,7 +11,7 @@ public class TeBeQaTestConfiguration {
static {
System.setProperty("tebaqa.endpoint.url", "https://tebaqa.demos.dice-research.org/qa-simple");
System.setProperty("tebaqa.mock.endpoint.url", "http://some-tebaqa/endpoint");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + TeBaQAQueryBuilderTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/qanary-component-QBE-QAnswer/pom.xml b/qanary-component-QBE-QAnswer/pom.xml
index b994b8f74..f721af93c 100644
--- a/qanary-component-QBE-QAnswer/pom.xml
+++ b/qanary-component-QBE-QAnswer/pom.xml
@@ -5,12 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QBE-QAnswer
- 3.2.2
+ 3.2.3
org.springframework.boot
spring-boot-starter-parent
2.7.0
+
11
diff --git a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/pom.xml b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/pom.xml
index e26200400..c76e5e6d2 100644
--- a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/pom.xml
+++ b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QBE-SimpleQueryBuilderAndExecutor
- 3.2.0
+ 3.2.2
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -99,10 +101,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/test/resources/queries/insert_json_test.rq b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/test/resources/queries/insert_json_test.rq
index 270b36ce8..354e5c2c9 100644
--- a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/test/resources/queries/insert_json_test.rq
+++ b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/test/resources/queries/insert_json_test.rq
@@ -13,6 +13,6 @@ INSERT {
}
}
WHERE
- { BIND(iri(str(rand())) AS ?b)
+ { BIND(IRI(str(rand())) AS ?b)
BIND(now() AS ?time)
}
diff --git a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/test/resources/queries/insert_sparql_test.rq b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/test/resources/queries/insert_sparql_test.rq
index ed0dc166c..767f2e812 100644
--- a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/test/resources/queries/insert_sparql_test.rq
+++ b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/test/resources/queries/insert_sparql_test.rq
@@ -13,6 +13,6 @@ INSERT {
}
}
WHERE
- { BIND(iri(str(rand())) AS ?a)
+ { BIND(IRI(str(rand())) AS ?a)
BIND(now() AS ?time)
}
diff --git a/qanary-component-QC-AnswerTypeClassifier/pom.xml b/qanary-component-QC-AnswerTypeClassifier/pom.xml
index 1be3538fd..34357fef7 100644
--- a/qanary-component-QC-AnswerTypeClassifier/pom.xml
+++ b/qanary-component-QC-AnswerTypeClassifier/pom.xml
@@ -5,12 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QC-AnswerTypeClassifier
- 3.1.1
+ 3.1.2
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
11
@@ -108,10 +109,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QE-SparqlExecuter/pom.xml b/qanary-component-QE-SparqlExecuter/pom.xml
index ec8c30693..04032601d 100644
--- a/qanary-component-QE-SparqlExecuter/pom.xml
+++ b/qanary-component-QE-SparqlExecuter/pom.xml
@@ -6,10 +6,12 @@
eu.wdaqua.qanary.component
qanary-component-QE-SparqlExecuter
3.2.0
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -104,10 +106,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-QE-Wikidata/pom.xml b/qanary-component-QE-Wikidata/pom.xml
index 0109fdc90..d3e9d9a38 100644
--- a/qanary-component-QE-Wikidata/pom.xml
+++ b/qanary-component-QE-Wikidata/pom.xml
@@ -11,6 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -114,10 +115,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-RD-AnnotaitonOfSpotProperty-OKBQA/pom.xml b/qanary-component-RD-AnnotaitonOfSpotProperty-OKBQA/pom.xml
index fdf67c757..2067a4266 100644
--- a/qanary-component-RD-AnnotaitonOfSpotProperty-OKBQA/pom.xml
+++ b/qanary-component-RD-AnnotaitonOfSpotProperty-OKBQA/pom.xml
@@ -5,14 +5,16 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-RD-AnnotaitonOfSpotProperty-OKBQA
- 3.1.1
+ 3.1.2
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
- 11
+ 17
[3.1.2,4.0.0)
qanary
qanary-component-rd-annotaitonofspotproperty-okbqa
@@ -100,10 +102,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-RD-DiambiguationProperty-OKBQA/pom.xml b/qanary-component-RD-DiambiguationProperty-OKBQA/pom.xml
index 40aa9bb3e..241fbc111 100644
--- a/qanary-component-RD-DiambiguationProperty-OKBQA/pom.xml
+++ b/qanary-component-RD-DiambiguationProperty-OKBQA/pom.xml
@@ -5,14 +5,16 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-RD-DiambiguationProperty-OKBQA
- 3.1.1
+ 3.1.2
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
- 11
+ 17
[3.1.2,4.0.0)
qanary
qanary-component-rd-diambiguationproperty-okbqa
@@ -100,10 +102,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-REL-RelNliod/pom.xml b/qanary-component-REL-RelNliod/pom.xml
index 3a5eef36d..eb97e9927 100644
--- a/qanary-component-REL-RelNliod/pom.xml
+++ b/qanary-component-REL-RelNliod/pom.xml
@@ -5,11 +5,13 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-REL-RelNliod
- 3.1.2
+ 3.1.3
+
org.springframework.boot
spring-boot-starter-parent
2.6.7
+
17
@@ -105,10 +107,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
diff --git a/qanary-component-TQA-ChatGPTWrapper/pom.xml b/qanary-component-TQA-ChatGPTWrapper/pom.xml
index e058d60ed..81d9c9da9 100644
--- a/qanary-component-TQA-ChatGPTWrapper/pom.xml
+++ b/qanary-component-TQA-ChatGPTWrapper/pom.xml
@@ -5,7 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-TQA-ChatGPTWrapper
- 0.2.1
+ 0.3.0
org.springframework.boot
@@ -15,7 +15,8 @@
17
- [3.7.0,4.0.0)
+ [3.7.0,4.0.0)
+ [3.8.0,4.0.0)
qanary
qanary-component-tqa-chatgptwrapper
1.4.13
@@ -26,7 +27,14 @@
eu.wdaqua.qanary
qa.component
- ${qanary.version}
+ ${qanary.component.version}
+
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+ test-jar
+ test
org.springframework.boot
diff --git a/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/CacheTests.java b/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/CacheTests.java
new file mode 100644
index 000000000..1d69d3ff1
--- /dev/null
+++ b/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/CacheTests.java
@@ -0,0 +1,64 @@
+package eu.wdaqua.qanary.component.chatgptwrapper.tqa;
+
+import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
+import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import qa.commons.QanaryCacheTest;
+
+import java.net.URISyntaxException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+class CacheTests {
+ // time span for caching, tests wait this time span during the test runs
+ protected final static int MAX_TIME_SPAN_SECONDS = 5;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheTests.class);
+
+ private final int testPort;
+ private final RestTemplateWithCaching myRestTemplate;
+ private final CacheOfRestTemplateResponse myCacheOfResponse;
+
+ CacheTests(
+ @Value(value = "${local.server.port}") int testPort, //
+ @Autowired RestTemplateWithCaching myRestTemplate, //
+ @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
+ ) {
+ this.testPort = testPort;
+ this.myRestTemplate = myRestTemplate;
+ this.myCacheOfResponse = myCacheOfResponse;
+ }
+
+ @BeforeEach
+ public void init() {
+ assert this.myRestTemplate != null : "restTemplate cannot be null";
+ }
+
+ /**
+ * @throws InterruptedException
+ * @throws URISyntaxException
+ */
+ @Test
+ void givenRestTemplate_whenRequested_thenLogAndModifyResponse() {
+ QanaryCacheTest qanaryCacheTest = new QanaryCacheTest(
+ testPort,
+ MAX_TIME_SPAN_SECONDS,
+ myRestTemplate,
+ myCacheOfResponse
+ );
+
+ assertDoesNotThrow(
+ qanaryCacheTest::givenRestTemplate_whenRequested_thenLogAndModifyResponse
+ );
+ }
+
+}
diff --git a/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/ChatGPTCacheTest.java b/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/ChatGPTCacheTest.java
deleted file mode 100644
index d9a9c1fdc..000000000
--- a/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/ChatGPTCacheTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package eu.wdaqua.qanary.component.chatgptwrapper.tqa;
-
-import eu.wdaqua.qanary.communications.CacheOfRestTemplateResponse;
-import eu.wdaqua.qanary.communications.RestTemplateWithCaching;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SpringExtension.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@TestPropertySource(properties = { //
- "CHATGPT.API.KEY=DUMMY-KEY-TO-ALLOW-COMPONENT-TO-START-AND-MOCK-TEST-TO-BE-EXECUTED", //
- "CHATGPT.API.LIVE.TEST.ACTIVE=false" //
-})
-class ChatGPTCacheTest {
- // time span for caching, tests wait this time span during the test runs
- protected final static int MAX_TIME_SPAN_SECONDS = 5;
- private static final Logger LOGGER = LoggerFactory.getLogger(ChatGPTCacheTest.class);
-
- private final int testPort;
- private final RestTemplateWithCaching myRestTemplate;
- private final CacheOfRestTemplateResponse myCacheOfResponse;
-
- ChatGPTCacheTest(
- @Value(value = "${local.server.port}") int testPort, //
- @Autowired RestTemplateWithCaching myRestTemplate, //
- @Autowired CacheOfRestTemplateResponse myCacheOfResponse //
- ) {
- this.testPort = testPort;
- this.myRestTemplate = myRestTemplate;
- this.myCacheOfResponse = myCacheOfResponse;
- }
-
- @BeforeEach
- public void init() {
- assert this.myRestTemplate != null : "restTemplate cannot be null";
- }
-
- /**
- * @throws InterruptedException
- * @throws URISyntaxException
- */
- @Test
- void givenRestTemplate_whenRequested_thenLogAndModifyResponse() throws InterruptedException, URISyntaxException {
-
- assertNotNull(myRestTemplate);
- assertNotNull(myCacheOfResponse);
-
- URI testServiceURL0 = new URI("http://localhost:" + testPort + "/");
- URI testServiceURL1 = new URI("http://localhost:" + testPort + "/component-description");
-
- long initialNumberOfRequests = myCacheOfResponse.getNumberOfExecutedRequests();
-
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- TimeUnit.SECONDS.sleep(MAX_TIME_SPAN_SECONDS + 5); // wait until it is too late for caching
- callRestTemplateWithCaching(testServiceURL0, Cache.NOT_CACHED); // cache miss: too long ago
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.NOT_CACHED); // cache miss: different URI
- callRestTemplateWithCaching(testServiceURL0, Cache.CACHED); // cache hit
- callRestTemplateWithCaching(testServiceURL1, Cache.CACHED); // cache hit
-
- assertEquals(initialNumberOfRequests + 3, myCacheOfResponse.getNumberOfExecutedRequests());
-
- }
-
- /**
- * @param uri
- * @param cacheStatus
- * @throws URISyntaxException
- */
- private void callRestTemplateWithCaching(URI uri, Cache cacheStatus) throws URISyntaxException {
- long numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests();
- ResponseEntity responseEntity = myRestTemplate.getForEntity(uri, String.class);
- numberOfNewlyExecutedRequests = myCacheOfResponse.getNumberOfExecutedRequests() - numberOfNewlyExecutedRequests;
- LOGGER.info("numberOfExecutedRequest since last request: new={}, count={}, teststatus={}", //
- numberOfNewlyExecutedRequests, myCacheOfResponse.getNumberOfExecutedRequests(), cacheStatus);
-
- assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
-
- switch (cacheStatus) {
- case NOT_CACHED:
- assertEquals(1, numberOfNewlyExecutedRequests);
- break;
- case CACHED:
- assertEquals(0, numberOfNewlyExecutedRequests);
- break;
- default:
- fail("Test case misconfigured");
- break;
- }
- }
-
- private enum Cache {
- CACHED, NOT_CACHED
- }
-}
diff --git a/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/ChatGPTTestConfiguration.java b/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/ChatGPTTestConfiguration.java
index ee9749d15..8a063b772 100644
--- a/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/ChatGPTTestConfiguration.java
+++ b/qanary-component-TQA-ChatGPTWrapper/src/test/java/eu/wdaqua/qanary/component/chatgptwrapper/tqa/ChatGPTTestConfiguration.java
@@ -16,7 +16,7 @@ public class ChatGPTTestConfiguration {
System.setProperty("chatGPT.getModelById.url", "/v1/models/");
System.setProperty("chatGPT.createCompletions.url", "/v1/completions");
- System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + ChatGPTCacheTest.MAX_TIME_SPAN_SECONDS + "s");
+ System.setProperty("qanary.webservicecalls.cache.specs", "maximumSize=1000,expireAfterAccess=" + CacheTests.MAX_TIME_SPAN_SECONDS + "s");
}
/**
diff --git a/service_config/build_images.sh b/service_config/build_images.sh
index 9b4635153..4ba44a76e 100755
--- a/service_config/build_images.sh
+++ b/service_config/build_images.sh
@@ -11,6 +11,60 @@ mvn clean install -Ddockerfile.skip=true -DskipTests
# delete Qanary pipeline repository
rm -rf Qanary/
+# replace secrets
+if [ -z "$BABELFY_API_KEY" ]
+then
+ echo "BABELFY_API_KEY is not set. Check your secrets."
+ exit
+else
+ sed -i "s/API_KEY/$BABELFY_API_KEY/g" ./service_config/files/ned-babelfy
+ sed -i "s/API_KEY/$BABELFY_API_KEY/g" ./service_config/files/ner-babelfy
+fi
+
+if [ -z "$CHATGPT_API_KEY" ]
+then
+ echo "CHATGPT_API_KEY is not set. Check your secrets."
+ exit
+else
+ sed -i "s/API_KEY/$CHATGPT_API_KEY/g" ./service_config/files/tqa-chatgptwrapper
+fi
+
+if [ -z "$DANDELION_API_KEY" ]
+then
+ echo "$DANDELION_API_KEY is not set. Check your secrets."
+ exit
+else
+ sed -i "s/API_KEY/$DANDELION_API_KEY/g" ./service_config/files/ned-dandelion
+ sed -i "s/API_KEY/$DANDELION_API_KEY/g" ./service_config/files/ner-dandelion
+fi
+
+if [ -z "$MEANINGCLOUD_API_KEY" ]
+then
+ echo "$MEANINGCLOUD_API_KEY is not set. Check your secrets."
+ exit
+else
+ sed -i "s/API_KEY/$MEANINGCLOUD_API_KEY/g" ./service_config/files/ned-meaningcloud
+ sed -i "s/API_KEY/$MEANINGCLOUD_API_KEY/g" ./service_config/files/ner-meaning-cloud
+fi
+
+if [ -z "$TAGME_API_KEY" ]
+then
+ echo "$TAGME_API_KEY is not set. Check your secrets."
+ exit
+else
+ sed -i "s/API_KEY/$TAGME_API_KEY/g" ./service_config/files/ned-tagme
+ sed -i "s/API_KEY/$TAGME_API_KEY/g" ./service_config/files/ner-tagme
+fi
+
+if [ -z "$TEXTRAZOR_API_KEY" ]
+then
+ echo "$TEXTRAZOR_API_KEY is not set. Check your secrets."
+ exit
+else
+ sed -i "s/API_KEY/$TEXTRAZOR_API_KEY/g" ./service_config/files/ner-text-razor
+fi
+
+
# build Docker Images and store name and tag
if ! mvn clean package -DskipTests;
then
diff --git a/service_config/files/ned-babelfy b/service_config/files/ned-babelfy
index d9dcf4360..71934a9bc 100644
--- a/service_config/files/ned-babelfy
+++ b/service_config/files/ned-babelfy
@@ -1,4 +1,5 @@
SERVER_HOST=http://demos.swe.htwk-leipzig.de
SERVER_PORT=40126
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
-SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40126
\ No newline at end of file
+SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40126
+BABELFY_API_KEY=API_KEY
\ No newline at end of file
diff --git a/service_config/files/ned-dandelion b/service_config/files/ned-dandelion
index a123118e5..fedd95b18 100644
--- a/service_config/files/ned-dandelion
+++ b/service_config/files/ned-dandelion
@@ -1,4 +1,5 @@
SERVER_HOST=http://demos.swe.htwk-leipzig.de
SERVER_PORT=40128
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
-SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40128
\ No newline at end of file
+SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40128
+DANDELION_API_KEY=API_KEY
diff --git a/service_config/files/ned-meaningcloud b/service_config/files/ned-meaningcloud
index 600a3e2fb..12acbbecd 100644
--- a/service_config/files/ned-meaningcloud
+++ b/service_config/files/ned-meaningcloud
@@ -1,4 +1,5 @@
SERVER_HOST=http://demos.swe.htwk-leipzig.de
SERVER_PORT=40130
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
-SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40130
\ No newline at end of file
+SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40130
+MEANINGCLOUD_API_KEY=API_KEY
diff --git a/service_config/files/ned-tagme b/service_config/files/ned-tagme
index 5256e6d74..4080c8de5 100644
--- a/service_config/files/ned-tagme
+++ b/service_config/files/ned-tagme
@@ -1,4 +1,5 @@
SERVER_HOST=http://demos.swe.htwk-leipzig.de
SERVER_PORT=40132
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
-SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40132
\ No newline at end of file
+SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40132
+TAGME_API_KEY=API_KEY
diff --git a/service_config/files/ner-babelfy b/service_config/files/ner-babelfy
index c9d32deda..7291978c9 100644
--- a/service_config/files/ner-babelfy
+++ b/service_config/files/ner-babelfy
@@ -1,4 +1,5 @@
SERVER_HOST=http://demos.swe.htwk-leipzig.de
SERVER_PORT=40136
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
-SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40136
\ No newline at end of file
+SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40136
+BABELFY_API_KEY=API_KEY
\ No newline at end of file
diff --git a/service_config/files/ner-dandelion b/service_config/files/ner-dandelion
index 5e0fc6592..a164d86eb 100644
--- a/service_config/files/ner-dandelion
+++ b/service_config/files/ner-dandelion
@@ -1,4 +1,5 @@
SERVER_HOST=http://demos.swe.htwk-leipzig.de
SERVER_PORT=40139
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
-SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40139
\ No newline at end of file
+SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40139
+DANDELION_API_KEY=API_KEY
diff --git a/service_config/files/ner-meaning-cloud b/service_config/files/ner-meaning-cloud
index e5a4944e9..6719ca91b 100644
--- a/service_config/files/ner-meaning-cloud
+++ b/service_config/files/ner-meaning-cloud
@@ -1,4 +1,5 @@
SERVER_HOST=http://demos.swe.htwk-leipzig.de
SERVER_PORT=40143
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
-SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40143
\ No newline at end of file
+SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40143
+MEANINGCLOUD_API_KEY=API_KEY
diff --git a/service_config/files/ner-tagme b/service_config/files/ner-tagme
index f4d10d647..85afbafe9 100644
--- a/service_config/files/ner-tagme
+++ b/service_config/files/ner-tagme
@@ -1,4 +1,5 @@
SERVER_HOST=http://demos.swe.htwk-leipzig.de
SERVER_PORT=40146
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
-SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40146
\ No newline at end of file
+SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40146
+TAGME_API_KEY=API_KEY
diff --git a/service_config/files/ner-text-razor b/service_config/files/ner-text-razor
index 2445568e1..7e1e706e1 100644
--- a/service_config/files/ner-text-razor
+++ b/service_config/files/ner-text-razor
@@ -1,4 +1,5 @@
SERVER_HOST=http://demos.swe.htwk-leipzig.de
SERVER_PORT=40147
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
-SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40147
\ No newline at end of file
+SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40147
+TEXTRAZOR_API_KEY=API_KEY
diff --git a/service_config/files/tqa-chatgptwrapper b/service_config/files/tqa-chatgptwrapper
index 5c23539ca..a890cd2f1 100644
--- a/service_config/files/tqa-chatgptwrapper
+++ b/service_config/files/tqa-chatgptwrapper
@@ -3,3 +3,4 @@ SERVER_PORT=40164
SPRING_BOOT_ADMIN_URL=http://demos.swe.htwk-leipzig.de:40111/
SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://demos.swe.htwk-leipzig.de:40164
QANARY_WEBSERVICECALLS_CACHE_SPECS=maximumSize=100000,expireAfterAccess=2419200s
+CHATGPT_API_KEY=API_KEY