ReplacingInputStream extends FilterInputStream { @Override public String toString() { return state.name() + " " + matchedIndex + " " + replacedIndex + " " + unbufferIndex; } ReplacingInputStream(InputStream in, String pattern, String replacement);  ReplacingInputStream(InputStream in, byte[] pattern, byte[] replacement); @Override int read(byte[] b, int off, int len); @Override int read(byte[] b); @Override int read(); @Override String toString();  }
@Test public void replacementTest() { InputStream ris = new ReplacingInputStream(mMainJSOrigin, "tvMastheadRenderer".getBytes(), "tvMastheadRendererOld".getBytes()); assertEquals(TestHelpers.unescapeJavaString(Helpers.toString(mMainJSResult)), TestHelpers.unescapeJavaString(Helpers.toString(ris))); }