Update OutputStreamToByteArrayUnitTest.java

This commit is contained in:
DiegoMarti2 2023-12-14 00:34:19 +02:00 committed by GitHub
parent 6e7e41cea4
commit 99e54378c3
1 changed files with 3 additions and 6 deletions

View File

@ -29,12 +29,10 @@ public class OutputStreamToByteArrayUnitTest {
@Test
public void givenByteArrayOutputStream_whenUsingDrainableOutputStream_thenReturnByteArray() throws IOException {
String data = "Welcome to Baeldung!";
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
DrainableOutputStream drainableOutputStream = new DrainableOutputStream(byteArrayOutputStream);
public void givenSystemOut_whenUsingDrainableOutputStream_thenReturnByteArray() throws IOException {
String data = "Welcome to Baeldung!\n";
DrainableOutputStream drainableOutputStream = new DrainableOutputStream(System.out);
try (drainableOutputStream) {
drainableOutputStream.write(data.getBytes(StandardCharsets.UTF_8));
}
@ -43,7 +41,6 @@ public class OutputStreamToByteArrayUnitTest {
assertEquals(data, new String(writtenData, StandardCharsets.UTF_8));
}
public class DrainableOutputStream extends FilterOutputStream {
private final ByteArrayOutputStream buffer;