Search in sources :

Example 41 with OMXMLParserWrapper

use of org.apache.axiom.om.OMXMLParserWrapper in project wso2-synapse by wso2.

the class SynapseTestCase method loadDescriptorInfoFile.

/**
 * Reads the specific descriptor file for the particular sample
 * from resource directory
 *
 * @return true if the configuration was loaded successfully
 */
private OMElement loadDescriptorInfoFile() {
    String sampleDescriptor = "/sample" + sampleId + ".xml";
    if (log.isDebugEnabled()) {
        log.debug("Reading sample descriptor file from " + sampleDescriptor);
    }
    try {
        InputStream in = this.getClass().getResourceAsStream(sampleDescriptor);
        if (in == null) {
            fail("Cannot read sample descriptor file");
        }
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(in);
        return builder.getDocumentElement();
    } catch (Exception e) {
        log.error("Error loading test descriptor", e);
        return null;
    }
}
Also used : InputStream(java.io.InputStream) OMXMLParserWrapper(org.apache.axiom.om.OMXMLParserWrapper) IOException(java.io.IOException)

Aggregations

OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)41 OMElement (org.apache.axiom.om.OMElement)23 StringReader (java.io.StringReader)13 XMLStreamReader (javax.xml.stream.XMLStreamReader)9 OMFactory (org.apache.axiom.om.OMFactory)9 InputSource (org.xml.sax.InputSource)8 InputStream (java.io.InputStream)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 OMNode (org.apache.axiom.om.OMNode)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 QName (javax.xml.namespace.QName)4 OMAttribute (org.apache.axiom.om.OMAttribute)3 OMDocument (org.apache.axiom.om.OMDocument)3 OMOutputFormat (org.apache.axiom.om.OMOutputFormat)3 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)3 DOMSource (javax.xml.transform.dom.DOMSource)2 SAXSource (javax.xml.transform.sax.SAXSource)2 NodeUnavailableException (org.apache.axiom.om.NodeUnavailableException)2 OMException (org.apache.axiom.om.OMException)2 OMNamespace (org.apache.axiom.om.OMNamespace)2