BAEL-1609 Added test for CountingOutputStream

This commit is contained in:
iaforek 2018-03-13 19:01:29 +00:00
parent 3c4b0fb20f
commit 928755d17e
1 changed files with 25 additions and 0 deletions

View File

@ -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());
}
}