From 928755d17e2d2566fd62744e1b70801999f98763 Mon Sep 17 00:00:00 2001 From: iaforek Date: Tue, 13 Mar 2018 19:01:29 +0000 Subject: [PATCH] BAEL-1609 Added test for CountingOutputStream --- .../guava/GuavaCountingOutputStreamTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 guava/src/test/java/org/baeldung/guava/GuavaCountingOutputStreamTest.java diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCountingOutputStreamTest.java b/guava/src/test/java/org/baeldung/guava/GuavaCountingOutputStreamTest.java new file mode 100644 index 0000000000..fb8ed7b7f4 --- /dev/null +++ b/guava/src/test/java/org/baeldung/guava/GuavaCountingOutputStreamTest.java @@ -0,0 +1,25 @@ +package org.baeldung.guava; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayOutputStream; + +import org.junit.Test; + +import com.google.common.io.CountingOutputStream; + +public class GuavaCountingOutputStreamTest { + + @Test + public void givenData_whenWrittenToStream_thenGetCorrectCount() throws Exception { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + CountingOutputStream cos = new CountingOutputStream(out); + + byte[] data = new byte[10]; + + cos.write(data); + + assertEquals(10, cos.getCount()); + + } +}