1 package org.openecomp.core.utilities.file;
3 import org.testng.annotations.Test;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.util.function.Function;
9 import static org.testng.Assert.assertTrue;
15 public class FileUtilsTest {
17 private static final String TEST_RESOURCE = FileUtilsTest.class.getPackage().getName()
18 .replace('.', '/') + "/test-resource.txt";
20 private static final Function<InputStream, Integer> TEST_FUNCTION = (s) -> {
24 } catch (IOException e) {
25 throw new RuntimeException(e);
30 public void testReadViaInputStreamWithSlash() throws Exception {
31 assertTrue(FileUtils.readViaInputStream(TEST_RESOURCE, TEST_FUNCTION) > 0);
35 public void testReadViaInputStreamWithoutSlash() throws Exception {
36 assertTrue(FileUtils.readViaInputStream(TEST_RESOURCE, TEST_FUNCTION) > 0);
39 @Test(expectedExceptions = NullPointerException.class)
40 public void testReadViaInputStreamNull() throws Exception {
41 FileUtils.readViaInputStream((String) null, TEST_FUNCTION);
44 @Test(expectedExceptions = IllegalArgumentException.class)
45 public void testReadViaInputStreamNotFound() throws Exception {
46 FileUtils.readViaInputStream("notfound.txt", TEST_FUNCTION);