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();
}
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();
}
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();
}
}
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();
}
}
Aggregations