You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/03/30 22:55:28 UTC

[GitHub] [beam] lukemin89 commented on a change in pull request #11263: [BEAM-9325] Override proper write method in UnownedOutputStream

lukemin89 commented on a change in pull request #11263: [BEAM-9325] Override proper write method in UnownedOutputStream
URL: https://github.com/apache/beam/pull/11263#discussion_r400543326
 
 

 ##########
 File path: sdks/java/core/src/test/java/org/apache/beam/sdk/util/UnownedOutputStreamTest.java
 ##########
 @@ -53,4 +57,21 @@ public void testClosingThrows() throws Exception {
     expectedException.expectMessage("Caller does not own the underlying");
     os.close();
   }
+
+  @Test
+  public void testWrite() throws IOException {
+    ByteArrayOutputStream expected = new ByteArrayOutputStream();
+    ByteArrayOutputStream actual = new ByteArrayOutputStream();
+    UnownedOutputStream osActual = new UnownedOutputStream(actual);
+
+    writeToBoth(expected, osActual, "Hello World!".getBytes(StandardCharsets.UTF_8));
+    writeToBoth(expected, osActual, "Welcome!".getBytes(StandardCharsets.UTF_8));
+
+    assertArrayEquals(expected.toByteArray(), actual.toByteArray());
+  }
+
+  private static void writeToBoth(OutputStream a, OutputStream b, byte[] data) throws IOException {
+    a.write(data);
+    b.write(data);
 
 Review comment:
   inlined with full signature!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services