ByteArrayHttpData implements HttpData { @Override public String toString(Charset charset) { requireNonNull(charset, "charset"); return new String(array, charset); } ByteArrayHttpData(byte[] array); private  ByteArrayHttpData(byte[] array, boolean endOfStream); @Override byte[] array(); @Override int length(); @Override String toString(Charset charset); @Override String toString(); @Override InputStream toInputStream(); @Override boolean isEndOfStream(); @Override ByteArrayHttpData withEndOfStream(boolean endOfStream); @Override boolean isPooled(); @Override ByteBuf byteBuf(ByteBufAccessMode mode); @Override ByteBuf byteBuf(int offset, int length, ByteBufAccessMode mode); @Override void close(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test void testToString() { assertThat(ByteArrayHttpData.EMPTY).hasToString("{0B}"); assertThat(new ByteArrayHttpData(new byte[] { 'f', 'o', 'o' })).hasToString("{3B, text=foo}"); assertThat(new ByteArrayHttpData(new byte[] { 1, 2, 3 })).hasToString("{3B, hex=010203}"); assertThat(ByteArrayHttpData.EMPTY_EOS).hasToString("{0B, EOS}"); assertThat(new ByteArrayHttpData(new byte[] { 'f', 'o', 'o' }) .withEndOfStream()).hasToString("{3B, EOS, text=foo}"); assertThat(new ByteArrayHttpData(new byte[] { 1, 2, 3 }) .withEndOfStream()).hasToString("{3B, EOS, hex=010203}"); assertThat(new ByteArrayHttpData(new byte[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', -1 })).hasToString("{17B, text=0123456789abcdef}"); }