summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java
index 91e3807a79..fdde36c935 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorUtil.java
@@ -11,12 +11,27 @@ import java.io.InputStream;
class ValidatorUtil {
- private ValidatorUtil(){
+ private ValidatorUtil() {
}
- public static byte[] getFileResource(String filePath) throws IOException{
- InputStream inputStream = ClassLoader.class.getClass().getResourceAsStream(filePath);
- return IOUtils.toByteArray(inputStream);
+ /**
+ * Reads a file and coverts it to a byte array.
+ *
+ * @param filePath The file path
+ * @return
+ * The file byte array
+ * @throws IOException
+ * When the file was not found or the input stream could not be opened
+ */
+ public static byte[] getFileResource(final String filePath) throws IOException {
+ try(final InputStream inputStream = ClassLoader.class.getResourceAsStream(filePath)) {
+ if (inputStream == null) {
+ throw new IOException(String.format("Could not find the resource on path \"%s\"", filePath));
+ }
+ return IOUtils.toByteArray(inputStream);
+ } catch (final IOException ex) {
+ throw new IOException(String.format("Could not open the input stream for resource on path \"%s\"", filePath), ex);
+ }
}
}