Serializer { protected final void appendBytes(byte[] bytes) { try { outputStream.write(bytes); } catch (IOException ex) { LOGGER.warn("Encountered exception while writing to ByteArrayOutputStream."); LOGGER.debug(ex); } } Serializer(); final byte[] serialize(); ByteArrayOutputStream getOutputStream();  }
@Test public void testAppendBytes() { serializer.appendBytes(new byte[] { 0, 1, 2, 3, 4, 5, 6 }); byte[] result = serializer.getAlreadySerialized(); assertArrayEquals(result, new byte[] { 0, 1, 2, 3, 4, 5, 6, }); }