### Question:
ContentWriters { public static Single<DataChunk> writeBytes(byte[] bytes, boolean copy) { byte[] data; if (copy) { data = new byte[bytes.length]; System.arraycopy(bytes, 0, data, 0, bytes.length); } else { data = bytes; } return Single.just(DataChunk.create(false, ByteBuffer.wrap(data))); } private  ContentWriters(); static Single<DataChunk> writeBytes(byte[] bytes, boolean copy); static Single<DataChunk> writeCharSequence(CharSequence cs, Charset charset); static Single<DataChunk> writeCharBuffer(CharBuffer buffer, Charset charset); static Single<DataChunk> writeStackTrace(Throwable throwable, Charset charset); @Deprecated(since = "2.0.0") static Function<byte[], Publisher<DataChunk>> byteArrayWriter(boolean copy); @Deprecated(since = "2.0.0") static Function<CharSequence, Publisher<DataChunk>> charSequenceWriter(Charset charset); @Deprecated(since = "2.0.0") static Function<CharBuffer, Publisher<DataChunk>> charBufferWriter(Charset charset); @Deprecated(since = "2.0.0") static Function<ReadableByteChannel, Publisher<DataChunk>> byteChannelWriter(RetrySchema retrySchema); @Deprecated(since = "2.0.0") static Function<ReadableByteChannel, Publisher<DataChunk>> byteChannelWriter();  }### Answer:
@Test public void byteWriter() throws Exception { byte[] bytes = "abc".getBytes(StandardCharsets.ISO_8859_1); Publisher<DataChunk> publisher = ContentWriters.writeBytes(bytes, false); byte[] result = ContentReaders.readBytes(publisher).get(5, TimeUnit.SECONDS); assertThat(bytes, is(result)); }
@Test public void copyByteWriter() throws Exception { byte[] bytes = "abc".getBytes(StandardCharsets.ISO_8859_1); Publisher<DataChunk> publisher = ContentWriters.writeBytes(bytes, true); System.arraycopy("xxx".getBytes(StandardCharsets.ISO_8859_1), 0, bytes, 0, bytes.length); byte[] result = ContentReaders.readBytes(publisher).get(); assertThat("abc".getBytes(StandardCharsets.ISO_8859_1), is(result)); }
@Test public void byteWriterEmpty() throws Exception { byte[] bytes = new byte[0]; Publisher<DataChunk> publisher = ContentWriters.writeBytes(bytes, false); byte[] result = ContentReaders.readBytes(publisher).get(5, TimeUnit.SECONDS); assertThat(result.length, is(0)); }