ByteEntityProvider implements EntityProvider<byte[]> { @Override public void writeTo(byte[] bytes, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { entityStream.write(bytes); }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override byte[] readFrom(Class<byte[]> type,
                           Type genericType,
                           Annotation[] annotations,
                           MediaType mediaType,
                           MultivaluedMap<String, String> httpHeaders,
                           InputStream entityStream); @Override long getSize(byte[] bytes, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(byte[] bytes,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream);  }
@Test public void writesByteArrayToOutputStream() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); byteEntityProvider.writeTo(testContent, byte[].class, null, null, MediaType.WILDCARD_TYPE, new MultivaluedHashMap<>(), out); assertArrayEquals(testContent, out.toByteArray()); }