}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testReadFrom() throws Exception {
MessageBodyReader p = new BinaryDataProvider();
byte[] bytes = (byte[])p.readFrom(byte[].class, byte[].class, new Annotation[]{},
MediaType.APPLICATION_OCTET_STREAM_TYPE,
new MetadataMap<String, Object>(),
new ByteArrayInputStream("hi".getBytes()));
assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
InputStream is = (InputStream)p.readFrom(InputStream.class, InputStream.class, new Annotation[]{},
MediaType.APPLICATION_OCTET_STREAM_TYPE,
new MetadataMap<String, Object>(),
new ByteArrayInputStream("hi".getBytes()));
bytes = IOUtils.readBytesFromStream(is);
assertTrue(Arrays.equals(new String("hi").getBytes(), bytes));
Reader r = (Reader)p.readFrom(Reader.class, Reader.class, new Annotation[]{},
MediaType.APPLICATION_OCTET_STREAM_TYPE,
new MetadataMap<String, Object>(),
new ByteArrayInputStream("hi".getBytes()));
assertEquals(IOUtils.toString(r), "hi");
}