Search in sources :

Example 11 with OMException

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

the class TestGetDocumentElementWithDiscardDocumentIllFormedEpilog method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<root/> there shouldn't be text here!"));
    OMElement element = builder.getDocumentElement(true);
    try {
        element.build();
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) StringReader(java.io.StringReader) OMElement(org.apache.axiom.om.OMElement) OMXMLParserWrapper(org.apache.axiom.om.OMXMLParserWrapper) OMException(org.apache.axiom.om.OMException)

Example 12 with OMException

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

the class TestAddChildWithExistingDocumentElement method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMDocument document = factory.createOMDocument();
    document.addChild(factory.createOMElement(new QName("root1")));
    try {
        document.addChild(factory.createOMElement(new QName("root2")));
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) QName(javax.xml.namespace.QName) OMException(org.apache.axiom.om.OMException) OMDocument(org.apache.axiom.om.OMDocument)

Example 13 with OMException

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

the class TestCreateOMBuilderFromDOMWithNSUnawarePrefixedAttribute method runTest.

@Override
protected void runTest() throws Throwable {
    Element domElement = DOMImplementation.XERCES.newDocument().createElementNS(null, "test");
    domElement.setAttribute("p:attr", "value");
    try {
        OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), domElement, false).getDocument().build();
        fail("Expected OMException");
    } catch (OMException ex) {
    // Expected
    }
}
Also used : Element(org.w3c.dom.Element) OMException(org.apache.axiom.om.OMException)

Example 14 with OMException

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

the class AbstractOMDataSource method getXMLBytes.

@Override
public final byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OMOutputFormat format = new OMOutputFormat();
    format.setCharSetEncoding(encoding);
    try {
        serialize(baos, format);
    } catch (XMLStreamException ex) {
        throw new OMException(ex);
    }
    return baos.toByteArray();
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OMOutputFormat(org.apache.axiom.om.OMOutputFormat) OMException(org.apache.axiom.om.OMException)

Example 15 with OMException

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

the class TextContent method appendTo.

@Override
public void appendTo(StringBuilder buffer) {
    if (binary) {
        Base64EncodingStringBufferOutputStream out = new Base64EncodingStringBufferOutputStream(buffer);
        try {
            getDataHandler().writeTo(out);
            out.complete();
        } catch (IOException ex) {
            throw new OMException(ex);
        }
    } else {
        buffer.append(value);
    }
}
Also used : Base64EncodingStringBufferOutputStream(org.apache.axiom.util.base64.Base64EncodingStringBufferOutputStream) 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