Search in sources :

Example 56 with OMException

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

the class TestAddHeaderBlockWithoutNamespace1 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPHeader header = soapFactory.createSOAPHeader(envelope);
    try {
        header.addHeaderBlock("test", null);
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMException(org.apache.axiom.om.OMException) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 57 with OMException

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

the class TestGetDocumentElementWithIllFormedDocument method runTest.

@Override
protected void runTest() throws Throwable {
    OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), new StringReader("<!--comment1-->"));
    try {
        builder.getDocumentElement();
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : StringReader(java.io.StringReader) OMXMLParserWrapper(org.apache.axiom.om.OMXMLParserWrapper) OMException(org.apache.axiom.om.OMException)

Example 58 with OMException

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

the class TestRemoveAttributeNotOwner method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement element1 = factory.createOMElement("test", null);
    element1.addAttribute("attr", "value", null);
    OMElement element2 = factory.createOMElement("test", null);
    OMAttribute attr = element2.addAttribute("attr", "value", null);
    try {
        element1.removeAttribute(attr);
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMElement(org.apache.axiom.om.OMElement) OMAttribute(org.apache.axiom.om.OMAttribute) OMException(org.apache.axiom.om.OMException)

Example 59 with OMException

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

the class TestAddHeaderBlockWithoutNamespace2 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
    SOAPHeader header = soapFactory.createSOAPHeader(envelope);
    OMNamespace ns = soapFactory.createOMNamespace("", "");
    try {
        header.addHeaderBlock("test", ns);
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMException(org.apache.axiom.om.OMException) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 60 with OMException

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

the class BlobOMDataSourceCustomBuilder method create.

@Override
public OMDataSource create(OMElement element) throws OMException {
    try {
        WritableBlob blob = blobFactory.createBlob();
        OutputStream out = blob.getOutputStream();
        try {
            element.serializeAndConsume(out);
        } finally {
            out.close();
        }
        return new BlobOMDataSource(blob, encoding);
    } catch (XMLStreamException ex) {
        throw new OMException(ex);
    } catch (IOException ex) {
        throw new OMException(ex);
    }
}
Also used : BlobOMDataSource(org.apache.axiom.om.ds.BlobOMDataSource) XMLStreamException(javax.xml.stream.XMLStreamException) OutputStream(java.io.OutputStream) WritableBlob(org.apache.axiom.blob.WritableBlob) IOException(java.io.IOException) 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