aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Dudycz <jakub.dudycz@nokia.com>2018-03-13 12:06:08 +0100
committerPatrick Brady <pb071s@att.com>2018-03-13 19:37:34 +0000
commitbe0f949a316b66dbfc213769d4c7073ea21a7b54 (patch)
tree77685db2989e5e6fc0e3d82430e883a1c91b0ef4
parentbc73640c5d910e376fd06d0a3fcbf18d8f92fd90 (diff)
StreamHelper unit tests
Improved code coverage Change-Id: Ie0dcf723e73890aa24b761fb3b46e2739d239040 Issue-ID: APPC-724 Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
-rw-r--r--appc-common/src/test/java/org/onap/appc/util/StreamHelperTest.java (renamed from appc-common/src/test/java/org/onap/appc/util/TestStreamHelper.java)16
1 files changed, 11 insertions, 5 deletions
diff --git a/appc-common/src/test/java/org/onap/appc/util/TestStreamHelper.java b/appc-common/src/test/java/org/onap/appc/util/StreamHelperTest.java
index 70ac8a087..42c4bf58b 100644
--- a/appc-common/src/test/java/org/onap/appc/util/TestStreamHelper.java
+++ b/appc-common/src/test/java/org/onap/appc/util/StreamHelperTest.java
@@ -31,7 +31,7 @@ import java.io.ByteArrayInputStream;
import org.junit.Test;
import org.onap.appc.util.StreamHelper;
-public class TestStreamHelper {
+public class StreamHelperTest {
private static final String text = "Filler text (also placeholder text or dummy text) is text that shares "
+ "some characteristics of a real written text, but is random or otherwise generated. It may be used "
@@ -66,16 +66,22 @@ public class TestStreamHelper {
+ "$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijk\n";
@Test
- public void testStreamHelperNullStream() {
+ public void should_return_empty_string_when_given_null_input_stream() {
assertNotNull(StreamHelper.getStringFromInputStream(null));
assertEquals("", StreamHelper.getStringFromInputStream(null));
}
@Test
- public void testStreamHelperByteArrayStream() {
- ByteArrayInputStream in = new ByteArrayInputStream(text.getBytes());
+ public void should_return_empty_string_when_given_empty_byte_array() {
+ ByteArrayInputStream emptyInputStream = new ByteArrayInputStream(new byte[0]);
- assertEquals(text, StreamHelper.getStringFromInputStream(in));
+ assertEquals("", StreamHelper.getStringFromInputStream(emptyInputStream));
}
+ @Test
+ public void should_return_string_when_given_byte_array() {
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(text.getBytes());
+
+ assertEquals(text, StreamHelper.getStringFromInputStream(inputStream));
+ }
}