Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMXMLParserWrapper


    public void submitPurchaseOrderTest()
            throws Exception {
        SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope env = omFactory.getDefaultEnvelope();
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(
                omFactory,
                StAXUtils.createXMLStreamReader(
                        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


    }

    protected void setUp() throws Exception {
        XMLStreamReader xmlStreamReader = StAXUtils.createXMLStreamReader(
                getTestResource(TestConstants.SOAP_SOAPMESSAGE1));
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                OMAbstractFactory.getSOAP11Factory(), xmlStreamReader);
        envelope = (SOAPEnvelope) builder.getDocumentElement();
        tempFile = File.createTempFile("temp", "xml");

    }
View Full Code Here

    }

    protected void runTest() throws Throwable {
        InputStream in = getFileAsStream();
        try {
            OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
                    StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, in);
            try {
                OMContainer container = containerFactory.getContainer(builder);
                // We need to clone the InputSource objects so that we can dump their contents
                // if the test fails
                InputSource control[] = duplicateInputSource(containerFactory.getControl(getFileAsStream()));
                InputSource actual[] = duplicateInputSource(serializationMethod.serialize(container));
                try {
                    assertXMLIdentical(compareXML(control[0], actual[0]), true);
                } catch (AssertionFailedError ex) {
                    System.out.println("Control:");
                    dumpInputSource(control[1]);
                    System.out.println("Actual:");
                    dumpInputSource(actual[1]);
                    throw ex;
                }
                if (serializationMethod.isCaching()) {
                    assertTrue(container.isComplete());
                } else {
                    // TODO: need to investigate why assertConsumed is not working here
                    assertFalse(container.isComplete());
//                    assertConsumed(element);
                }
            } finally {
                builder.close();
            }
        } finally {
            in.close();
        }
    }
View Full Code Here

        assertTrue(outputString != null && !"".equals(outputString) && outputString.length() > 1);

    }

    public void testElementPullStream1() throws Exception {
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                OMAbstractFactory.getSOAP11Factory(),
                reader);
        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
        StreamingOMSerializer serializer = new StreamingOMSerializer();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream);

        serializer.serialize(env.getXMLStreamReaderWithoutCaching(), writer);
View Full Code Here

            fail("Expecting an XMLStreamException, but got instead: " + e.getClass().getName() + ": " + e.getMessage());
        }
    }

    public void testElementPullStream2() throws Exception {
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                OMAbstractFactory.getSOAP11Factory(),
                reader);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream);

        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
        SOAPBody body = env.getBody();
        StreamingOMSerializer serializer = new StreamingOMSerializer();
        serializer.serialize(body.getXMLStreamReaderWithoutCaching(),
                             writer);
        writer.flush();
View Full Code Here

        final String USR_DEF = "xmlns:usr";
       
        reader =
            XMLInputFactory.newInstance()
                           .createXMLStreamReader(getTestResource("soap/soapmessageWithXSI.xml"));
        OMXMLParserWrapper builder =
            OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMAbstractFactory.getSOAP11Factory(),
                                                           reader);
       
        // Get the envelope and then get the body
        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
        SOAPBody body = env.getBody();
       
        StreamingOMSerializer serializer = new StreamingOMSerializer();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream);
View Full Code Here

        final String USR_DEF = "xmlns:usr";
       
        reader =
            XMLInputFactory.newInstance()
                           .createXMLStreamReader(getTestResource("soap/soapmessageWithXSI.xml"));
        OMXMLParserWrapper builder =
            OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMAbstractFactory.getSOAP11Factory(),
                                                           reader);
       
        // Get and build the whole tree...this will cause no streaming when doing the write
        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
        env.build();
       
        // Get the body
        SOAPBody body = env.getBody();
       
View Full Code Here

     */
    public void testSerializeToXMLWriterFromReader() throws Exception {
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);

        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(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

     */
    public void testSerializeToXMLWriterFromReaderEmbedded() throws Exception {
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);

        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(root.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

                omElement.isComplete());

    }

    public void testCreateOMElement() throws Exception {
        OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
                getTestResource(TestConstants.WHITESPACE_MESSAGE));
        OMElement envelope = omBuilder.getDocumentElement();
       
        // The body is the second element
        OMNode node = envelope.getFirstElement();
        node = node.getNextOMSibling();
        while (node != null && !(node instanceof OMElement)) {
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMXMLParserWrapper

Copyright © 2018 www.massapicom. 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.