@Override public InputStream openStream() { return getAsStringAsset().openStream(); }
/** * Ensures that the contents of the asset match that which was passed in. */ @Test public void testRoundtrip() throws Exception { // Log log.info("testRoundtrip"); // Make contents String contents = StringAsset.class.getSimpleName(); // Make Asset final StringAsset asset = new StringAsset(contents); // Get the contents back out of the asset final InputStream stream = asset.openStream(); final ByteArrayOutputStream out = new ByteArrayOutputStream(contents.length()); int read; while ((read = stream.read()) != -1) { out.write(read); } String roundtrip = new String(out.toByteArray()); log.info("Roundtrip contents: " + roundtrip); Assert.assertEquals("Roundtrip did not equal passed in contents", contents, roundtrip); }