Package org.springframework.xml.transform

Examples of org.springframework.xml.transform.StringResult


    public void testGetPayloadSourceText() throws Exception {
        saajMessage.getSOAPBody().addTextNode(" ");
        saajMessage.getSOAPBody().addChildElement("child");
        Source source = soapMessage.getPayloadSource();
        StringResult result = new StringResult();
        transformer.transform(source, result);
        assertXMLEqual("Invalid source", "<child/>", result.toString());
    }
View Full Code Here


                streamWriter.writeEndElement();
                streamWriter.writeEndElement();
            }
        });

        StringResult result = new StringResult();
        transformer.transform(streamingMessage.getPayloadSource(), result);

        String expected = "<root xmlns='http://springframework.org'><child>Foo</child></root>";
        assertXMLEqual(expected, result.toString());

        soapMessage.writeTo(new ByteArrayOutputStream());
    }
View Full Code Here

        httpServletRequest.addHeader("Content-Length", Integer.toString(bytes.length));
        httpServletRequest.addHeader(HEADER_NAME, HEADER_VALUE);
        httpServletRequest.setContent(bytes);
        SaajSoapMessage message = (SaajSoapMessage) connection.receive(messageFactory);
        Assert.assertNotNull("No message received", message);
        StringResult result = new StringResult();
        Transformer transformer = transformerFactory.newTransformer();
        transformer.transform(message.getPayloadSource(), result);
        assertXMLEqual("Invalid message", CONTENT, result.toString());
        SOAPMessage saajMessage = message.getSaajMessage();
        String[] headerValues = saajMessage.getMimeHeaders().getHeader(HEADER_NAME);
        Assert.assertNotNull("Response has no header", headerValues);
        assertEquals("Response has invalid header", 1, headerValues.length);
        assertEquals("Response has invalid header values", HEADER_VALUE, headerValues[0]);
View Full Code Here

                soapHeader.getName());
    }

    @Test
    public void testGetSource() throws Exception {
        StringResult result = new StringResult();
        transformer.transform(soapHeader.getSource(), result);
        assertXMLEqual("Invalid contents of header", "<Header xmlns='http://www.w3.org/2003/05/soap-envelope' />",
                result.toString());
    }
View Full Code Here

    @Test
    public void testAddNotUnderstood() throws Exception {
        Soap12Header soap12Header = (Soap12Header) soapHeader;
        QName headerName = new QName("http://www.springframework.org", "NotUnderstood", "spring-ws");
        soap12Header.addNotUnderstoodHeaderElement(headerName);
        StringResult result = new StringResult();
        transformer.transform(soapHeader.getSource(), result);
        assertXMLEqual("Invalid contents of header", "<Header xmlns='http://www.w3.org/2003/05/soap-envelope' >" +
                "<NotUnderstood qname='spring-ws:NotUnderstood' xmlns:spring-ws='http://www.springframework.org' />" +
                "</Header>", result.toString());
    }
View Full Code Here

    public void testAddUpgrade() throws Exception {
        String[] supportedUris =
                new String[]{"http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/2003/05/soap-envelope"};
        Soap12Header soap12Header = (Soap12Header) soapHeader;
        SoapHeaderElement header = soap12Header.addUpgradeHeaderElement(supportedUris);
        StringResult result = new StringResult();
        transformer.transform(soapHeader.getSource(), result);
        assertEquals("Invalid name", header.getName(), new QName("http://www.w3.org/2003/05/soap-envelope", "Upgrade"));
        // XMLUnit can't test this:
/*
        assertXMLEqual("Invalid contents of header", "<Header xmlns='http://www.w3.org/2003/05/soap-envelope' >" +
View Full Code Here

                soapEnvelope.getName());
    }

    @Test
    public void testGetSource() throws Exception {
        StringResult result = new StringResult();
        transformer.transform(soapEnvelope.getSource(), result);
        assertXMLEqual("<Envelope xmlns='http://www.w3.org/2003/05/soap-envelope'><Header/>" + "<Body/></Envelope>",
                result.toString());
    }
View Full Code Here

        assertEquals("Invalid qualified name", SoapVersion.SOAP_11.getBodyName(), soapBody.getName());
    }

    @Test
    public void testGetSource() throws Exception {
        StringResult result = new StringResult();
        transformer.transform(soapBody.getSource(), result);
        assertXMLEqual("Invalid contents of body", "<Body xmlns='http://schemas.xmlsoap.org/soap/envelope/' />",
                result.toString());
    }
View Full Code Here

                soapHeader.getName());
    }

    @Test
    public void testGetSource() throws Exception {
        StringResult result = new StringResult();
        transformer.transform(soapHeader.getSource(), result);
        assertXMLEqual("Invalid contents of header",
                "<SOAP-ENV:Header xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' />", result.toString());
    }
View Full Code Here

    @Test
    public void testMarshal() throws Exception {
        Marshaller marshallerMock = createMock(Marshaller.class);
        WebServiceMessage messageMock = createMock(WebServiceMessage.class);

        Result result = new StringResult();
        Object marshalled = new Object();
        expect(messageMock.getPayloadResult()).andReturn(result);
        marshallerMock.marshal(marshalled, result);

        replay(marshallerMock, messageMock);
View Full Code Here

TOP

Related Classes of org.springframework.xml.transform.StringResult

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.