Search in sources :

Example 6 with XARInputProperties

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));
}
Also used : EntityReferenceSet(org.xwiki.model.reference.EntityReferenceSet) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) XARInputProperties(org.xwiki.filter.xar.input.XARInputProperties) DefaultFileInputSource(org.xwiki.filter.input.DefaultFileInputSource) ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Example 7 with XARInputProperties

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());
}
Also used : XARInputProperties(org.xwiki.filter.xar.input.XARInputProperties) FilterXMLOutputProperties(org.xwiki.filter.filterxml.output.FilterXMLOutputProperties) OutputFilterStream(org.xwiki.filter.output.OutputFilterStream) StringWriterOutputTarget(org.xwiki.filter.output.StringWriterOutputTarget) InputFilterStream(org.xwiki.filter.input.InputFilterStream) URL(java.net.URL)

Example 8 with XARInputProperties

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));
}
Also used : EntityReferenceSet(org.xwiki.model.reference.EntityReferenceSet) XARInputProperties(org.xwiki.filter.xar.input.XARInputProperties) EntityReference(org.xwiki.model.reference.EntityReference) DefaultFileInputSource(org.xwiki.filter.input.DefaultFileInputSource) ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Aggregations

XARInputProperties (org.xwiki.filter.xar.input.XARInputProperties)8 DocumentInstanceOutputProperties (org.xwiki.filter.instance.output.DocumentInstanceOutputProperties)4 EntityReferenceSet (org.xwiki.model.reference.EntityReferenceSet)3 Test (org.junit.Test)2 ExtensionId (org.xwiki.extension.ExtensionId)2 BeanInputFilterStreamFactory (org.xwiki.filter.input.BeanInputFilterStreamFactory)2 DefaultFileInputSource (org.xwiki.filter.input.DefaultFileInputSource)2 DefaultInputStreamInputSource (org.xwiki.filter.input.DefaultInputStreamInputSource)2 EntityReference (org.xwiki.model.reference.EntityReference)2 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiException (com.xpn.xwiki.XWikiException)1 XARImportedEvent (com.xpn.xwiki.internal.event.XARImportedEvent)1 XARImportingEvent (com.xpn.xwiki.internal.event.XARImportingEvent)1 XWikiDocumentFilterUtils (com.xpn.xwiki.internal.filter.XWikiDocumentFilterUtils)1 EntityOutputFilterStream (com.xpn.xwiki.internal.filter.output.EntityOutputFilterStream)1 XWikiDocumentOutputFilterStream (com.xpn.xwiki.internal.filter.output.XWikiDocumentOutputFilterStream)1 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)1 PropertyClass (com.xpn.xwiki.objects.classes.PropertyClass)1 Package (com.xpn.xwiki.plugin.packaging.Package)1