Serializer { public final byte[] serialize() { outputStream = new ByteArrayOutputStream(); serializeBytes(); return getAlreadySerialized(); } Serializer(); final byte[] serialize(); ByteArrayOutputStream getOutputStream();  }
@Test public void testSerialize() { byte[] result = serializer.serialize(); assertArrayEquals(result, new byte[] { 0, 1, 2, 3 }); }