1 package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
3 import org.apache.commons.io.IOUtils;
5 import java.io.IOException;
6 import java.io.InputStream;
9 * Provides util methods for Validation Test classes.
14 private ValidatorUtil() {
19 * Reads a file and coverts it to a byte array.
21 * @param filePath The file path
25 * When the file was not found or the input stream could not be opened
27 public static byte[] getFileResource(final String filePath) throws IOException {
28 try(final InputStream inputStream = ClassLoader.class.getResourceAsStream(filePath)) {
29 if (inputStream == null) {
30 throw new IOException(String.format("Could not find the resource on path \"%s\"", filePath));
32 return IOUtils.toByteArray(inputStream);
33 } catch (final IOException ex) {
34 throw new IOException(String.format("Could not open the input stream for resource on path \"%s\"", filePath), ex);