use of org.xwiki.rendering.parser.StreamParser in project xwiki-platform by xwiki.
the class DefaultHTMLConverterTest method fromHTML.
/**
* Unit test for {@link DefaultHTMLConverter#fromHTML(String, String)}.
*/
@Test
public void fromHTML() throws Exception {
String html = "some HTML";
String syntaxId = "syntax/x.y";
// Verify the HTML is cleaned.
HTMLCleaner cleaner = mocker.getInstance(HTMLCleaner.class);
when(cleaner.clean(html)).thenReturn(html);
PrintRendererFactory printRendererFactory = this.mocker.registerMockComponent(PrintRendererFactory.class, syntaxId);
PrintRenderer printRenderer = mock(PrintRenderer.class);
when(printRendererFactory.createRenderer(any(WikiPrinter.class))).thenReturn(printRenderer);
Assert.assertEquals("", mocker.getComponentUnderTest().fromHTML(html, syntaxId));
// Verify the HTML is converted to the specified syntax.
StreamParser xhtmlStreamParser = mocker.getInstance(StreamParser.class, "xhtml/1.0");
verify(xhtmlStreamParser).parse(any(StringReader.class), same(printRenderer));
}
Aggregations