use of org.xwiki.filter.xar.input.XARInputProperties in project xwiki-platform by xwiki.
the class XARInputFilterStreamTest method testSkipFirstDocument.
@Test
public void testSkipFirstDocument() throws FilterException, IOException, ComponentLookupException {
XARInputProperties xarProperties = new XARInputProperties();
xarProperties.setSource(new DefaultFileInputSource(extensionPackager.getExtensionFile(new ExtensionId("xar1", "1.0"))));
EntityReferenceSet entities = new EntityReferenceSet();
entities.includes(new LocalDocumentReference("space2", "page2"));
xarProperties.setEntities(entities);
assertXML("testSkipFirstDocument", xarProperties);
assertTrue(this.allLogRule.getMarker(0).contains(WikiDocumentFilter.LOG_DOCUMENT_SKIPPED));
}
use of org.xwiki.filter.xar.input.XARInputProperties in project xwiki-platform by xwiki.
the class XARInputFilterStreamTest method assertXML.
private void assertXML(String resource, XARInputProperties xarProperties) throws FilterException, IOException, ComponentLookupException {
URL url = getClass().getResource("/xar/" + resource + ".output.xml");
String expected = IOUtils.toString(url, "UTF-8");
expected = StringUtils.removeStart(expected, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n");
BeanInputFilterStreamFactory<XARInputProperties> inputFilterStreamFactory = this.mocker.getInstance(InputFilterStreamFactory.class, FilterStreamType.XWIKI_XAR_CURRENT.serialize());
InputFilterStream inputFilterStream = inputFilterStreamFactory.createInputFilterStream(xarProperties);
StringWriterOutputTarget writer = new StringWriterOutputTarget();
FilterXMLOutputProperties properties = new FilterXMLOutputProperties();
properties.setTarget(writer);
BeanOutputFilterStreamFactory<FilterXMLOutputProperties> xmlOutputFilterStreamFactory = this.mocker.getInstance(OutputFilterStreamFactory.class, FilterStreamType.FILTER_XML.serialize());
OutputFilterStream outputFilterStream = xmlOutputFilterStreamFactory.createOutputFilterStream(properties);
inputFilterStream.read(outputFilterStream.getFilter());
inputFilterStream.close();
outputFilterStream.close();
Assert.assertEquals(expected, writer.getBuffer().toString());
}
use of org.xwiki.filter.xar.input.XARInputProperties in project xwiki-platform by xwiki.
the class XARInputFilterStreamTest method testSkipLastSpace.
@Test
public void testSkipLastSpace() throws FilterException, IOException, ComponentLookupException {
XARInputProperties xarProperties = new XARInputProperties();
xarProperties.setSource(new DefaultFileInputSource(extensionPackager.getExtensionFile(new ExtensionId("xar1", "1.0"))));
EntityReferenceSet entities = new EntityReferenceSet();
entities.excludes(new EntityReference("space2", EntityType.SPACE));
xarProperties.setEntities(entities);
assertXML("testSkipLastSpace", xarProperties);
assertTrue(this.allLogRule.getMarker(0).contains(WikiDocumentFilter.LOG_DOCUMENT_SKIPPED));
}
Aggregations