Package org.springframework.xml.transform

Examples of org.springframework.xml.transform.StringResult


    @Test
    public void testMarshalMime() throws Exception {
        MimeMarshaller marshallerMock = createMock(MimeMarshaller.class);
        MimeMessage messageMock = createMock(MimeMessage.class);

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

        replay(marshallerMock, messageMock);
View Full Code Here


                soapEnvelope.getName());
    }

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

                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://www.w3.org/2003/05/soap-envelope' />",
                result.toString());
    }
View Full Code Here

    @Test
    public void testAddMustUnderstandFault() throws Exception {
        SoapFault fault = soapBody.addMustUnderstandFault("SOAP Must Understand Error", Locale.ENGLISH);
        assertEquals("Invalid fault code", new QName("http://www.w3.org/2003/05/soap-envelope", "MustUnderstand"),
                fault.getFaultCode());
        StringResult result = new StringResult();
        transformer.transform(fault.getSource(), result);
        assertXMLEqual("Invalid contents of body",
                "<soapenv:Fault xmlns:soapenv='http://www.w3.org/2003/05/soap-envelope'>" +
                        "<soapenv:Code><soapenv:Value>" + soapBody.getName().getPrefix() +
                        ":MustUnderstand</soapenv:Value></soapenv:Code>" +
                        "<soapenv:Reason><soapenv:Text xml:lang='en'>SOAP Must Understand Error</soapenv:Text>" +
                        "</soapenv:Reason></soapenv:Fault>", result.toString());
    }
View Full Code Here

    @Test
    public void testAddSenderFault() throws Exception {
        SoapFault fault = soapBody.addClientOrSenderFault("faultString", Locale.ENGLISH);
        assertEquals("Invalid fault code", new QName("http://www.w3.org/2003/05/soap-envelope", "Sender"),
                fault.getFaultCode());
        StringResult result = new StringResult();
        transformer.transform(fault.getSource(), result);
        assertXMLEqual("Invalid contents of body",
                "<soapenv:Fault xmlns:soapenv='http://www.w3.org/2003/05/soap-envelope'>" +
                        "<soapenv:Code><soapenv:Value>" + soapBody.getName().getPrefix() +
                        ":Sender</soapenv:Value></soapenv:Code>" +
                        "<soapenv:Reason><soapenv:Text xml:lang='en'>faultString</soapenv:Text></soapenv:Reason>" +
                        "</soapenv:Fault>", result.toString());
    }
View Full Code Here

    @Test
    public void testAddReceiverFault() throws Exception {
        SoapFault fault = soapBody.addServerOrReceiverFault("faultString", Locale.ENGLISH);
        assertEquals("Invalid fault code", new QName("http://www.w3.org/2003/05/soap-envelope", "Receiver"),
                fault.getFaultCode());
        StringResult result = new StringResult();
        transformer.transform(fault.getSource(), result);
        assertXMLEqual("Invalid contents of body",
                "<soapenv:Fault xmlns:soapenv='http://www.w3.org/2003/05/soap-envelope'>" +
                        "<soapenv:Code><soapenv:Value>" + soapBody.getName().getPrefix() +
                        ":Receiver</soapenv:Value></soapenv:Code>" +
                        "<soapenv:Reason><soapenv:Text xml:lang='en'>faultString</soapenv:Text></soapenv:Reason>" +
                        "</soapenv:Fault>", result.toString());
    }
View Full Code Here

        SoapFaultDetail detail = fault.addFaultDetail();
        SoapFaultDetailElement detailElement =
                detail.addFaultDetailElement(new QName("namespace", "localPart", "prefix"));
        StringSource detailContents = new StringSource("<detailContents xmlns='namespace'/>");
        transformer.transform(detailContents, detailElement.getResult());
        StringResult result = new StringResult();
        transformer.transform(fault.getSource(), result);
        assertXMLEqual("Invalid source for body",
                "<soapenv:Fault xmlns:soapenv='http://www.w3.org/2003/05/soap-envelope'>" +
                        "<soapenv:Code><soapenv:Value>" + soapBody.getName().getPrefix() + ":Receiver</soapenv:Value>" +
                        "</soapenv:Code>" +
                        "<soapenv:Reason><soapenv:Text xml:lang='en'>faultString</soapenv:Text></soapenv:Reason>" +
                        "<soapenv:Detail><prefix:localPart xmlns:prefix='namespace'><detailContents xmlns='namespace'/>" +
                        "</prefix:localPart></soapenv:Detail></soapenv:Fault>", result.toString());
    }
View Full Code Here

    public void testAddFaultWithDetailResult() throws Exception {
        SoapFault fault = soapBody.addServerOrReceiverFault("faultString", Locale.ENGLISH);
        SoapFaultDetail detail = fault.addFaultDetail();
        transformer.transform(new StringSource("<detailContents xmlns='namespace'/>"), detail.getResult());
        transformer.transform(new StringSource("<detailContents xmlns='namespace'/>"), detail.getResult());
        StringResult result = new StringResult();
        transformer.transform(fault.getSource(), result);
        assertXMLEqual("Invalid source for body",
                "<soapenv:Fault xmlns:soapenv='http://www.w3.org/2003/05/soap-envelope'>" +
                        "<soapenv:Code><soapenv:Value>" + soapBody.getName().getPrefix() + ":Receiver</soapenv:Value>" +
                        "</soapenv:Code>" +
                        "<soapenv:Reason><soapenv:Text xml:lang='en'>faultString</soapenv:Text></soapenv:Reason>" +
                        "<soapenv:Detail>" + "<detailContents xmlns='namespace'/>" +
                        "<detailContents xmlns='namespace'/>" + "</soapenv:Detail></soapenv:Fault>", result.toString());
    }
View Full Code Here

        assertTrue("No subcode found", iterator.hasNext());
        assertEquals("Invalid subcode", subcode1, iterator.next());
        assertTrue("No subcode found", iterator.hasNext());
        assertEquals("Invalid subcode", subcode2, iterator.next());
        assertFalse("Subcode found", iterator.hasNext());
        StringResult result = new StringResult();
        transformer.transform(fault.getSource(), result);
        assertXMLEqual("Invalid source for body",
                "<soapenv:Fault xmlns:soapenv='http://www.w3.org/2003/05/soap-envelope'>" +
                        "<soapenv:Code><soapenv:Value>" + soapBody.getName().getPrefix() + ":Receiver</soapenv:Value>" +
                        "<soapenv:Subcode><soapenv:Value xmlns:spring-ws='http://www.springframework.org'>spring-ws:Subcode1</soapenv:Value>" +
                        "<soapenv:Subcode><soapenv:Value xmlns:spring-ws='http://www.springframework.org'>spring-ws:Subcode2</soapenv:Value>" +
                        "</soapenv:Subcode></soapenv:Subcode></soapenv:Code>" +
                        "<soapenv:Reason><soapenv:Text xml:lang='en'>faultString</soapenv:Text></soapenv:Reason>" +
                        "</soapenv:Fault>", result.toString());
    }
View Full Code Here

     * Marshalls the Object in the {@link ObjectMessage} to a string using XML
     * encoding
     */
  protected String marshall(Session session, ObjectMessage objectMessage)
      throws JMSException {
    StringResult result = new StringResult();
    try {
      marshaller.marshal(objectMessage.getObject(), result);
      return result.toString();
    } catch (Exception e) {
      throw new JMSException(e.getMessage());
    }
  }
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.