Search in sources :

Example 1 with XMLStreamReaderComparator

use of org.apache.axiom.testutils.stax.XMLStreamReaderComparator in project webservices-axiom by apache.

the class XMLFragmentStreamReaderTest method test.

/**
     * Test comparing the output of {@link XMLFragmentStreamReader} with that
     * of a native StAX parser. In particular this tests the behavior for START_DOCUMENT
     * and END_DOCUMENT events.
     * 
     * @throws Exception
     */
public void test() throws Exception {
    String xml = "<ns:a xmlns:ns='urn:ns'>test</ns:a>";
    XMLStreamReader expected = StAXUtils.createXMLStreamReader(new StringReader(xml));
    XMLStreamReader reader = StAXUtils.createXMLStreamReader(new StringReader(xml));
    reader.nextTag();
    XMLStreamReader actual = new XMLFragmentStreamReader(reader);
    new XMLStreamReaderComparator(expected, actual).compare();
    assertEquals(XMLStreamReader.END_DOCUMENT, reader.getEventType());
    expected.close();
    reader.close();
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamReaderComparator(org.apache.axiom.testutils.stax.XMLStreamReaderComparator) StringReader(java.io.StringReader)

Example 2 with XMLStreamReaderComparator

use of org.apache.axiom.testutils.stax.XMLStreamReaderComparator in project webservices-axiom by apache.

the class XOPDecodingStreamReaderTest method testCompareToInlined.

public void testCompareToInlined() throws Exception {
    XMLStreamReader expected = StAXUtils.createXMLStreamReader(MTOMSample.SAMPLE1.getInlinedMessage());
    XMLStreamReader actual = getXOPDecodingStreamReader();
    XMLStreamReaderComparator comparator = new XMLStreamReaderComparator(expected, actual);
    comparator.addPrefix("xop");
    comparator.compare();
    expected.close();
    actual.close();
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamReaderComparator(org.apache.axiom.testutils.stax.XMLStreamReaderComparator)

Example 3 with XMLStreamReaderComparator

use of org.apache.axiom.testutils.stax.XMLStreamReaderComparator in project webservices-axiom by apache.

the class XOPEncodingStreamReaderTest method test.

public void test() throws Exception {
    Attachments[] attachments = new Attachments[2];
    XMLStreamReader[] soapPartReader = new XMLStreamReader[2];
    for (int i = 0; i < 2; i++) {
        attachments[i] = new Attachments(MTOMSample.SAMPLE1.getInputStream(), MTOMSample.SAMPLE1.getContentType());
        soapPartReader[i] = StAXUtils.createXMLStreamReader(attachments[i].getRootPartInputStream());
    }
    XMLStreamReader actual = new XOPEncodingStreamReader(new XOPDecodingStreamReader(soapPartReader[1], new AttachmentsMimePartProvider(attachments[1])), contentIDGenerator, OptimizationPolicy.DEFAULT);
    new XMLStreamReaderComparator(soapPartReader[0], actual).compare();
    for (int i = 0; i < 2; i++) {
        soapPartReader[i].close();
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamReaderComparator(org.apache.axiom.testutils.stax.XMLStreamReaderComparator) AttachmentsMimePartProvider(org.apache.axiom.om.impl.builder.AttachmentsMimePartProvider) Attachments(org.apache.axiom.attachments.Attachments)

Example 4 with XMLStreamReaderComparator

use of org.apache.axiom.testutils.stax.XMLStreamReaderComparator in project webservices-axiom by apache.

the class TestGetXMLStreamReader method runTest.

@Override
protected final void runTest() throws Throwable {
    InputStream in = file.getInputStream();
    try {
        XMLStreamReader expected = StAXUtils.createXMLStreamReader(TEST_PARSER_CONFIGURATION, file.getUrl().toString(), in);
        try {
            OMXMLParserWrapper builder = builderFactory.getBuilder(metaFactory, new InputSource(file.getUrl().toString()));
            try {
                XMLStreamReader actual = containerExtractor.getContainer(builder).getXMLStreamReader(cache);
                XMLStreamReaderComparator comparator = new XMLStreamReaderComparator(containerExtractor.filter(expected), containerExtractor.filter(actual));
                builderFactory.configureXMLStreamReaderComparator(comparator);
                comparator.compare();
            } finally {
                builder.close();
            }
        } finally {
            expected.close();
        }
    } finally {
        in.close();
    }
}
Also used : InputSource(org.xml.sax.InputSource) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamReaderComparator(org.apache.axiom.testutils.stax.XMLStreamReaderComparator) InputStream(java.io.InputStream) OMXMLParserWrapper(org.apache.axiom.om.OMXMLParserWrapper)

Aggregations

XMLStreamReader (javax.xml.stream.XMLStreamReader)4 XMLStreamReaderComparator (org.apache.axiom.testutils.stax.XMLStreamReaderComparator)4 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 Attachments (org.apache.axiom.attachments.Attachments)1 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)1 AttachmentsMimePartProvider (org.apache.axiom.om.impl.builder.AttachmentsMimePartProvider)1 InputSource (org.xml.sax.InputSource)1