Search in sources :

Example 16 with OMException

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

the class TestDeclareDefaultNamespaceConflict1 method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = factory.createOMElement("test", null);
    try {
        element.declareDefaultNamespace("urn:test");
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMElement(org.apache.axiom.om.OMElement) OMException(org.apache.axiom.om.OMException)

Example 17 with OMException

use of org.apache.axiom.om.OMException 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)

Example 18 with OMException

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

the class TestInsertSiblingAfterOnChild method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = factory.createOMElement("test", null);
    OMText text = factory.createOMText("test");
    element.addChild(text);
    try {
        text.insertSiblingAfter(element);
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement) OMException(org.apache.axiom.om.OMException)

Example 19 with OMException

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

the class TestInsertSiblingAfterOnOrphan method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory fac = metaFactory.getOMFactory();
    OMText text1 = fac.createOMText("text1");
    OMText text2 = fac.createOMText("text2");
    try {
        text1.insertSiblingBefore(text2);
        fail("Expected OMException because node has no parent");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMText(org.apache.axiom.om.OMText) OMException(org.apache.axiom.om.OMException)

Example 20 with OMException

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

the class TestInsertSiblingBeforeOnChild method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element = factory.createOMElement("test", null);
    OMText text = factory.createOMText("test");
    element.addChild(text);
    try {
        text.insertSiblingBefore(element);
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement) OMException(org.apache.axiom.om.OMException)

Aggregations

OMException (org.apache.axiom.om.OMException)89 OMElement (org.apache.axiom.om.OMElement)35 XMLStreamException (javax.xml.stream.XMLStreamException)31 IOException (java.io.IOException)30 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)21 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)18 InputStream (java.io.InputStream)16 QName (javax.xml.namespace.QName)13 OMFactory (org.apache.axiom.om.OMFactory)12 ArrayList (java.util.ArrayList)11 MalformedURLException (java.net.MalformedURLException)10 Test (org.junit.Test)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)9 ParseException (org.json.simple.parser.ParseException)9 APIMgtResourceAlreadyExistsException (org.wso2.carbon.apimgt.api.APIMgtResourceAlreadyExistsException)9 APIMgtResourceNotFoundException (org.wso2.carbon.apimgt.api.APIMgtResourceNotFoundException)9 FaultGatewaysException (org.wso2.carbon.apimgt.api.FaultGatewaysException)9 MonetizationException (org.wso2.carbon.apimgt.api.MonetizationException)9 UnsupportedPolicyTypeException (org.wso2.carbon.apimgt.api.UnsupportedPolicyTypeException)9