public void testComplexFactory() throws Exception { Map<String, String> rules = new HashMap<String, String>(10); rules.put(StringReplacerTest.JAVASCRIPT, ""); ReplaceFactory factory = new ReplaceFactory(rules); ReplaceReader replacer = factory.getReplacer(); String actual = replacer.transform(StringReplacerTest.JAVASCRIPT + "foo"); assertEquals("Complex factory based replacement should work", "foo", actual); }
/* This used to fail due to a missing proper initialization of minBufferSize when using a factory together with stream bases replacing. */ public void testComplexFactoryStream() throws Exception { Map<String, String> rules = new HashMap<String, String>(10); rules.put(StringReplacerTest.JAVASCRIPT, ""); ReplaceFactory factory = new ReplaceFactory(rules); StringReader ir = new StringReader(StringReplacerTest.JAVASCRIPT + "foo"); ReplaceReader replacer = factory.getReplacer(ir); CircularCharBuffer actual = new CircularCharBuffer(10, Integer.MAX_VALUE); replacer.read(actual, Integer.MAX_VALUE); assertEquals( "Complex factory & stream based replacement should work", "foo", actual.toString()); }