summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorMichal Banka <michal.banka@nokia.com>2020-09-14 23:04:37 +0200
committerMichal Banka <michal.banka@nokia.com>2020-09-15 11:26:56 +0200
commit80a8297a4b84eb33a0f77e9a56283e3c8fb5f929 (patch)
treefc41e3f0c6d95500feab2c764a5bd91dc9d28918 /src/test/java
parent9872f0081fa4aec5e41b89fc9a5fe3d4cd19d5c9 (diff)
Fix bug throwing exception when first event is collected
- Problem: When running app from jar (e.g. in docker env) ClassLoader badly interprete classpath as root of app jar, while resources are located in jar under BOOT-INF/classes/ in Spring Boot apps. - Solution: Moved file from resources to etc directory so ClassLoader isn't needed. Filepath of api_version_description.json which previously was badly resolved now is configured in collector.properties. Change-Id: I690394cc59e16c95f5902045efc3fdaf13bf9112 Signed-off-by: Michal Banka <michal.banka@nokia.com> Issue-ID: DCAEGEN2-2426
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/dcae/common/JsonDataLoader.java10
-rw-r--r--src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java4
2 files changed, 7 insertions, 7 deletions
diff --git a/src/test/java/org/onap/dcae/common/JsonDataLoader.java b/src/test/java/org/onap/dcae/common/JsonDataLoader.java
index 2ea59aa0..8c2fdd6d 100644
--- a/src/test/java/org/onap/dcae/common/JsonDataLoader.java
+++ b/src/test/java/org/onap/dcae/common/JsonDataLoader.java
@@ -20,7 +20,9 @@
package org.onap.dcae.common;
import java.io.IOException;
+import java.net.URL;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
/**
@@ -35,15 +37,15 @@ public final class JsonDataLoader {
}
/**
- * This method is validating given event using schema adn throws exception if event is not valid
+ * This method is validating given event using schema and throws exception when event is invalid
*
* @param path to file that will be loaded
* @return contend of the file located under path, given in parameters, as string
* @throws IOException when file under given path was not found
*/
public static String loadContent(String path) throws IOException {
- return new String(
- Files.readAllBytes(Paths.get(JsonDataLoader.class.getResource(path).getPath()))
- );
+ URL resource = JsonDataLoader.class.getResource(path);
+ Path resourcePath = Paths.get(resource.getPath());
+ return new String(Files.readAllBytes(resourcePath));
}
}
diff --git a/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java b/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
index 0a03c1a4..ce7e09d3 100644
--- a/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
+++ b/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
@@ -315,9 +315,7 @@ public class VesRestControllerTest {
private void configureHeadersForEventListener() {
when(headerUtils.getRestApiIdentify(anyString())).thenReturn("eventListener");
- when(headerUtils.getApiVerFilePath(anyString())).thenReturn(
- this.getClass().getResource("/api_version_config.json").getPath()
- );
+ when(applicationSettings.getApiVersionDescriptionFilepath()).thenReturn("etc/api_version_description.json");
}
private void verifyThatTransformedEventWasSend(DMaaPEventPublisher eventPublisher, String eventBeforeTransformation) {