Search in sources :

Example 1 with AbstractPullOMDataSource

use of org.apache.axiom.om.ds.AbstractPullOMDataSource in project webservices-axiom by apache.

the class TestGetReaderException method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMSourcedElement element = factory.createOMElement(new AbstractPullOMDataSource() {

        @Override
        public XMLStreamReader getReader() throws XMLStreamException {
            throw new XMLStreamException("Test exception");
        }

        @Override
        public boolean isDestructiveRead() {
            return true;
        }
    });
    try {
        element.getLocalName();
        fail("Expected OMException");
    } catch (OMException ex) {
        Throwable cause = ex.getCause();
        assertTrue(cause instanceof XMLStreamException);
        assertEquals("Test exception", cause.getMessage());
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) AbstractPullOMDataSource(org.apache.axiom.om.ds.AbstractPullOMDataSource) OMSourcedElement(org.apache.axiom.om.OMSourcedElement) OMException(org.apache.axiom.om.OMException)

Aggregations

XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 OMException (org.apache.axiom.om.OMException)1 OMFactory (org.apache.axiom.om.OMFactory)1 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)1 AbstractPullOMDataSource (org.apache.axiom.om.ds.AbstractPullOMDataSource)1