Examples of OMXMLParserWrapper


Examples of org.apache.axiom.om.OMXMLParserWrapper

            XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
            xmlHelper.save(dataObject, elementQName.getNamespaceURI(), elementQName.getLocalPart(), baos);
            baos.close();

            XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray()));
            OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), xsr);
            OMElement omElement = builder.getDocumentElement();

            return omElement;

        } catch (IOException e) {
            throw new ServiceRuntimeException(e);
View Full Code Here

Examples of org.apache.axiom.om.OMXMLParserWrapper

        } finally {
            in.close();
        }
        in = getFileAsStream();
        try {
            OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
                    StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, in);
            try {
                OMElement element = builder.getDocumentElement();
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                if (cache) {
                    element.serialize(baos);
                } else {
                    element.serializeAndConsume(baos);
                }
                assertXMLIdentical(compareXML(new InputSource(new ByteArrayInputStream(control)),
                        new InputSource(new ByteArrayInputStream(baos.toByteArray()))), true);
                if (cache) {
                    assertTrue(element.isComplete());
                } else {
                    // TODO: need to investigate why assertConsumed is not working here
                    assertFalse(element.isComplete());
//                    assertConsumed(element);
                }
            } finally {
                builder.close();
            }
        } finally {
            in.close();
        }
    }
View Full Code Here

Examples of org.apache.axiom.om.OMXMLParserWrapper

        InputStream in1 = getFileAsStream();
        InputStream in2 = getFileAsStream();
        try {
            XMLStreamReader expected = StAXUtils.createXMLStreamReader(in1);
            try {
                OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), in2);
                try {
                    XMLStreamReader actual = builder.getDocument().getXMLStreamReader(cache);
                    new XMLStreamReaderComparator(new RootWhitespaceFilter(expected),
                            new RootWhitespaceFilter(actual)).compare();
                } finally {
                    builder.close();
                }
            } finally {
                expected.close();
            }
        } finally {
View Full Code Here

Examples of org.apache.axiom.om.OMXMLParserWrapper

    protected SOAPEnvelope getSOAPEnvelope(String relativePath, String resourceName) {
        try {
            XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
                    getResource(relativePath, resourceName));
            OMXMLParserWrapper wrapper = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                    OMAbstractFactory.getSOAP11Factory(), reader);
            return (SOAPEnvelope) wrapper.getDocumentElement();

        } catch (XMLStreamException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of org.apache.axiom.om.OMXMLParserWrapper

       
        // Write out the message
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(baos, oof);
       
        OMXMLParserWrapper builder =
            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments);
        OMElement om = builder.getDocumentElement();
        om.serialize(writer);
        om.close(false);
        String outNormal = baos.toString();
       
        assertTrue(outNormal.indexOf("base64") == -1);
       
        // Now do it again but use base64 content-type-encoding for
        // binary attachments
        baos = new ByteArrayOutputStream();
        oof.setProperty(OMOutputFormat.USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS,
                        Boolean.TRUE);
        writer = new MTOMXMLStreamWriter(baos, oof);
        builder =
            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments);
        om = builder.getDocumentElement();
        om.serialize(writer);
        om.close(false);
        String outBase64 = baos.toString();
       
       
        // Do a quick check to see if the data is base64 and is
        // writing base64 compliant code.
        assertTrue(outBase64.indexOf("base64") != -1);
        assertTrue(outBase64.indexOf("GBgcGBQgHBwcJCQgKDBQNDAsL") != -1);
       
        // Now read the data back in
        InputStream is = new ByteArrayInputStream(outBase64.getBytes());
        Attachments attachments2 = new Attachments(is, testMessage.getContentType());
       
        // Now write it back out with binary...
        baos = new ByteArrayOutputStream();
        oof.setProperty(OMOutputFormat.USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS,
                        Boolean.FALSE);
        writer = new MTOMXMLStreamWriter(baos, oof);
        builder =
            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments2);
        om = builder.getDocumentElement();
        om.serialize(writer);
        om.close(false);
        String outBase64ToNormal = baos.toString();
       
        assertTrue(outBase64ToNormal.indexOf("base64") == -1);
       
        // Now do it again but use base64 content-type-encoding for
        // binary attachments
        is = new ByteArrayInputStream(outBase64.getBytes());
        attachments2 = new Attachments(is, testMessage.getContentType());
        baos = new ByteArrayOutputStream();
        oof.setProperty(OMOutputFormat.USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS,
                        Boolean.TRUE);
        writer = new MTOMXMLStreamWriter(baos, oof);
        builder =
            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments2);
        om = builder.getDocumentElement();
        om.serialize(writer);
        om.close(false);
        String outBase64ToBase64 = baos.toString();
       
        // Do a quick check to see if the data is base64 and is
View Full Code Here

Examples of org.apache.axiom.om.OMXMLParserWrapper

    public void submitPurchaseOrderTest()
            throws Exception {
        SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope env = omFactory.getDefaultEnvelope();
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(
                omFactory, new InputStreamReader(
                                new ByteArrayInputStream(xmlText2.getBytes())));
        env.getBody().addChild(builder.getDocumentElement());

        // not sure why this test was created. Just checking whether serialization has worked or not. Someone
        // wanna check the correct thing later?
        String outputString = env.toString();
        assertTrue(outputString != null && !"".equals(outputString) && outputString.length() > 1);
View Full Code Here

Examples of org.apache.axiom.om.OMXMLParserWrapper

    protected void runTest() throws Throwable {
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);

        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(
                metaFactory.getOMFactory(), element.getXMLStreamReader());
        OMDocument omDocument = builder.getDocument();
        Iterator it = omDocument.getChildren();
        while (it.hasNext()) {
            OMNode omNode = (OMNode) it.next();
            // TODO: quick fix required because OMChildrenIterator#next() no longer builds the node
            omNode.getNextOMSibling();
View Full Code Here

Examples of org.apache.axiom.om.OMXMLParserWrapper

    }

    public abstract OMXMLParserWrapper getBuilder();
   
    public void close(boolean build) {
        OMXMLParserWrapper builder = getBuilder();
        if (build) {
            this.build();
        }
        setComplete(true);
       
View Full Code Here

Examples of org.apache.axiom.om.OMXMLParserWrapper

    protected void runTest() throws Throwable {
        // Note: We test getElementText on a child element ("b") of the element from which we request
        //       the XMLStreamReader ("a"). This is to make sure that the XMLStreamReader implementation actually
        //       delegates to the underlying parser (which is not necessarily the case on "a").
        OMXMLParserWrapper builder = builderFactory.getBuilder(metaFactory, new InputSource(
                new StringReader("<a><b>AB<!--comment text-->CD</b></a>")));
        OMElement element = builder.getDocumentElement();
       
        XMLStreamReader reader = element.getXMLStreamReader(cache);
        assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
        assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
View Full Code Here

Examples of org.apache.axiom.om.OMXMLParserWrapper

    protected void runTest() throws Throwable {
        OMElement documentElement = null;
       
        // first build the OM tree without caching and see whether we can discard
        // an element from it
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
                AbstractTestCase.getTestResource(TestConstants.SOAP_SOAPMESSAGE));
        documentElement = builder.getDocumentElement();

        documentElement.getFirstElement().discard();

        String envelopeString = documentElement.toStringWithConsume();
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.