Update OutputStreamToByteArrayUnitTest.java
This commit is contained in:
parent
6e7e41cea4
commit
99e54378c3
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue