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/31 15:47:08 UTC
[GitHub] [beam] lukecwik commented on a change in pull request #11263:
[BEAM-9325] Override proper write method in UnownedOutputStream
lukecwik 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_r401020590
##########
File path: sdks/java/core/src/test/java/org/apache/beam/sdk/util/UnownedOutputStreamTest.java
##########
@@ -53,4 +56,22 @@ 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);
+
+ byte[] data0 = "Hello World!".getBytes(StandardCharsets.UTF_8);
+ byte[] data1 = "Welcome!".getBytes(StandardCharsets.UTF_8);
+
+ expected.write(data0, 0, data0.length);
+ osActual.write(data0, 0, data0.length);
+
+ expected.write(data1, 0, data1.length);
+ osActual.write(data1, 0, data1.length);
+
+ assertArrayEquals(expected.toByteArray(), actual.toByteArray());
Review comment:
This won't actually test that the singular version of the method was called since if FilteredOutputStream wrote one byte at a time you would still get the expected result. You'll need to use a mock and validate that #write(byte[], int, int) was called the correct number of times.
----------------------------------------------------------------
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