use of org.xwiki.filter.input.DefaultURLInputSource in project xwiki-platform by xwiki.
the class AbstractInstanceFilterStreamTest method importFromXML.
protected void importFromXML(String resource, InstanceOutputProperties instanceProperties) throws FilterException {
if (instanceProperties == null) {
instanceProperties = new InstanceOutputProperties();
instanceProperties.setVerbose(false);
}
OutputFilterStream outputFilterStream = this.outputFilterStreamFactory.createOutputFilterStream(instanceProperties);
URL url = getClass().getResource("/filter/" + resource + ".xml");
FilterXMLInputProperties properties = new FilterXMLInputProperties();
properties.setSource(new DefaultURLInputSource(url));
InputFilterStream inputFilterStream = this.xmlInputFilterStreamFactory.createInputFilterStream(properties);
inputFilterStream.read(outputFilterStream.getFilter());
try {
inputFilterStream.close();
} catch (IOException e) {
throw new FilterException("Failed to close input wiki stream", e);
}
try {
outputFilterStream.close();
} catch (IOException e) {
throw new FilterException("Failed to close output wiki stream", e);
}
}
use of org.xwiki.filter.input.DefaultURLInputSource in project xwiki-platform by xwiki.
the class XWikiDocumentFilterUtilsTest method assertXML.
private void assertXML(Object entity, String resource) throws FilterException, IOException, ComponentLookupException {
URL url = getClass().getResource("/filter/xar/" + resource + ".xml");
assertNotNull(url);
String expected = IOUtils.toString(url, "UTF-8");
expected = StringUtils.removeStart(expected, "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n\n");
// Import
Object importedEntity = this.mocker.getComponentUnderTest().importEntity(entity, new DefaultURLInputSource(url));
// Export
String actual = this.mocker.getComponentUnderTest().exportEntity(importedEntity);
// Validate
assertEquals(expected, actual);
}
use of org.xwiki.filter.input.DefaultURLInputSource in project xwiki-platform by xwiki.
the class ExtensionInstanceOutputFilterStreamTest method importFromXML.
protected void importFromXML(String resource, InstanceOutputProperties instanceProperties) throws FilterException {
if (instanceProperties == null) {
instanceProperties = new InstanceOutputProperties();
instanceProperties.setVerbose(false);
}
OutputFilterStream outputFilterStream = this.outputFilterStreamFactory.createOutputFilterStream(instanceProperties);
URL url = getClass().getResource("/" + resource + ".xml");
FilterXMLInputProperties properties = new FilterXMLInputProperties();
properties.setSource(new DefaultURLInputSource(url));
InputFilterStream inputFilterStream = this.xmlInputFilterStreamFactory.createInputFilterStream(properties);
inputFilterStream.read(outputFilterStream.getFilter());
try {
inputFilterStream.close();
} catch (IOException e) {
throw new FilterException("Failed to close input wiki stream", e);
}
try {
outputFilterStream.close();
} catch (IOException e) {
throw new FilterException("Failed to close output wiki stream", e);
}
}
Aggregations