@Test public void readsContentOfEntityStreamAsByteArray() throws Exception { byte[] result = byteEntityProvider.readFrom(byte[].class, null, null, MediaType.WILDCARD_TYPE, new MultivaluedMapImpl(), new ByteArrayInputStream(testContent)); assertArrayEquals(testContent, result); }
@Override public byte[] readFrom(Class<byte[]> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { int length = getContentLength(httpHeaders); ByteArrayOutputStream out = length > 0 ? new NoSyncByteArrayOutputStream(length) : new NoSyncByteArrayOutputStream(); ByteStreams.copy(entityStream, out); return out.toByteArray(); }
ByteEntityProvider implements EntityProvider<byte[]> { @Override public byte[] readFrom(Class<byte[]> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { int length = getContentLength(httpHeaders); ByteArrayOutputStream out = length > 0 ? new NoSyncByteArrayOutputStream(length) : new NoSyncByteArrayOutputStream(); ByteStreams.copy(entityStream, out); return out.toByteArray(); } }
ByteEntityProvider implements EntityProvider<byte[]> { @Override public byte[] readFrom(Class<byte[]> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { int length = getContentLength(httpHeaders); ByteArrayOutputStream out = length > 0 ? new NoSyncByteArrayOutputStream(length) : new NoSyncByteArrayOutputStream(); ByteStreams.copy(entityStream, out); return out.toByteArray(); }  }
ByteEntityProvider implements EntityProvider<byte[]> { @Override public byte[] readFrom(Class<byte[]> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { int length = getContentLength(httpHeaders); ByteArrayOutputStream out = length > 0 ? new NoSyncByteArrayOutputStream(length) : new NoSyncByteArrayOutputStream(); ByteStreams.copy(entityStream, out); return out.toByteArray(); }  @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); }
ByteEntityProvider implements EntityProvider<byte[]> { @Override public byte[] readFrom(Class<byte[]> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { int length = getContentLength(httpHeaders); ByteArrayOutputStream out = length > 0 ? new NoSyncByteArrayOutputStream(length) : new NoSyncByteArrayOutputStream(); ByteStreams.copy(entityStream, out); return out.toByteArray(); }  @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);  }