/** * Creates a new print writer which performs the tag injection. * * @param originalWriter * The writer which is wrapped. * @param tagToInject * The tag(s) to insert. */ public TagInjectionPrintWriter(PrintWriter originalWriter, String tagToInject) { super(originalWriter); this.originalWriter = originalWriter; injector = new StreamedHtmlScriptInjector(tagToInject); }
@BeforeMethod public void init() { injector = new StreamedHtmlScriptInjector(TAG_TO_INJECT); }
@Test public void testPreventDoubleInejection() { String src = loadHtmlSource("/html/testCase-HeadInjection.html"); String modifiedA = runInjector(src); String modified = new StreamedHtmlScriptInjector(TAG_TO_INJECT).performInjection(modifiedA); assertThat(modified, equalTo(null)); }