Search in sources :

Example 1 with InstanceInputProperties

use of org.xwiki.filter.instance.input.InstanceInputProperties in project xwiki-platform by xwiki.

the class AbstractInstanceInputFilterStreamTest method assertXML.

protected void assertXML(String resource, InstanceInputProperties instanceProperties) throws FilterException, IOException {
    if (instanceProperties == null) {
        instanceProperties = new InstanceInputProperties();
        instanceProperties.setVerbose(false);
    }
    URL url = getClass().getResource("/filter/" + resource + ".xml");
    String expected = IOUtils.toString(url, "UTF-8");
    expected = StringUtils.removeStart(expected, "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n\n");
    InputFilterStream inputFilterStream = this.inputFilterStreamFactory.createInputFilterStream(instanceProperties);
    StringWriterOutputTarget writer = new StringWriterOutputTarget();
    FilterXMLOutputProperties properties = new FilterXMLOutputProperties();
    properties.setTarget(writer);
    OutputFilterStream outputFilterStream = this.xmlOutputFilterStreamFactory.createOutputFilterStream(properties);
    inputFilterStream.read(outputFilterStream.getFilter());
    inputFilterStream.close();
    outputFilterStream.close();
    Assert.assertEquals(expected, writer.getBuffer().toString());
}
Also used : FilterXMLOutputProperties(org.xwiki.filter.filterxml.output.FilterXMLOutputProperties) OutputFilterStream(org.xwiki.filter.output.OutputFilterStream) InstanceInputProperties(org.xwiki.filter.instance.input.InstanceInputProperties) StringWriterOutputTarget(org.xwiki.filter.output.StringWriterOutputTarget) InputFilterStream(org.xwiki.filter.input.InputFilterStream) URL(java.net.URL)

Aggregations

URL (java.net.URL)1 FilterXMLOutputProperties (org.xwiki.filter.filterxml.output.FilterXMLOutputProperties)1 InputFilterStream (org.xwiki.filter.input.InputFilterStream)1 InstanceInputProperties (org.xwiki.filter.instance.input.InstanceInputProperties)1 OutputFilterStream (org.xwiki.filter.output.OutputFilterStream)1 StringWriterOutputTarget (org.xwiki.filter.output.StringWriterOutputTarget)1