// Entity Input Stream
ByteArrayInputStream bais = new ByteArrayInputStream(message.getBytes());
// Entity Stream to be read with DataSourceProvider
DataSourceProvider dsp = new DataSourceProvider();
DataSourceProvider.ByteArrayDataSource bads =
new DataSourceProvider.ByteArrayDataSource(bais, "text/plain");
// Check if readable - assert true
assertTrue(dsp.isReadable(DataSource.class, null, null, null));
assertTrue(dsp.isReadable(Object.class, null, null, null));
// Check if readable - assert false
assertFalse(dsp.isReadable(DataSourceProvider.ByteArrayDataSource.class, null, null, null));
assertFalse(" Reading to String.class is not supported", dsp.isReadable(String.class,
null,
null,
null));
DataSource ds = null;
try {
// Read Entity
ds =
dsp
.readFrom(null, null, null, MediaType.WILDCARD_TYPE, null, bads
.getInputStream());
} catch (IOException e) {
assertFalse(" Failed to read Entity", true);
}