Package org.springframework.xml.transform

Examples of org.springframework.xml.transform.StringResult


    @Test
    public void testResponse() throws Exception {
        WebServiceMessage requestMock = createMock(WebServiceMessage.class);
        expect(requestMock.getPayloadSource()).andReturn(new StringSource("<request/>"));
        WebServiceMessage responseMock = createMock(WebServiceMessage.class);
        expect(responseMock.getPayloadResult()).andReturn(new StringResult());
        WebServiceMessageFactory factoryMock = createMock(WebServiceMessageFactory.class);
        expect(factoryMock.createWebServiceMessage()).andReturn(responseMock);
        MessageContext messageContext = new DefaultMessageContext(requestMock, factoryMock);

        Method response = getClass().getMethod("response", MyGenericType.class);
View Full Code Here


    @Test
    public void testInvokeSource() throws Exception {
        WebServiceMessage requestMock = createMock(WebServiceMessage.class);
        WebServiceMessage responseMock = createMock(WebServiceMessage.class);
        expect(requestMock.getPayloadSource()).andReturn(new StringSource(CONTENTS));
        expect(responseMock.getPayloadResult()).andReturn(new StringResult());
        WebServiceMessageFactory factoryMock = createMock(WebServiceMessageFactory.class);
        expect(factoryMock.createWebServiceMessage()).andReturn(responseMock);
        replay(requestMock, responseMock, factoryMock);

        MessageContext messageContext = new DefaultMessageContext(requestMock, factoryMock);
View Full Code Here

  private static final String WS_URI = "http://localhost:8080/ws-inbound-gateway/echoservice";
  private final WebServiceTemplate template = new WebServiceTemplate();

  @Test
  public void testWebServiceRequestAndResponse() {
    StringResult result = new StringResult();
    Source payload = new StringSource(
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
        "<echoRequest xmlns=\"http://www.springframework.org/spring-ws/samples/echo\">hello</echoRequest>");

    template.sendSourceAndReceiveToResult(WS_URI, payload, result);
    logger.info("RESULT: " + result.toString());
    assertThat(result.toString(), equalTo(
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
        "<echoResponse xmlns=\"http://www.springframework.org/spring-ws/samples/echo\">hello</echoResponse>"));
  }
View Full Code Here

*/
public class XmlUtil {

  public static String docAsString(Document doc) {
    try {
      StringResult res = new StringResult();
      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      transformer.transform(new DOMSource(doc), res);
      return res.toString();
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    Transformer transformer = createIndentingTransformer();

    transformer.setOutputProperty(OutputKeys.METHOD, "xml");

    try {
      StringResult streamResult = new StringResult();
      transformer.transform(new DOMSource(document), streamResult);
    } catch (Exception ex) {
      throw new IllegalStateException(ex);
    }
  }
View Full Code Here

        this.webServiceTemplate = webServiceTemplate;
    }

    public void testJmsTransport() throws Exception {
        String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
        StringResult result = new StringResult();
        webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
        XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
        applicationContext.close();
    }
View Full Code Here


    @Test
    public void testMailTransport() throws Exception {
        String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
        StringResult result = new StringResult();
        webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
        applicationContext.close();
        assertEquals("Server mail message not deleted", 0, Mailbox.get("server@example.com").size());
        assertEquals("No client mail message received", 1, Mailbox.get("client@example.com").size());
        XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());

    }
View Full Code Here

    }

    @Test
    public void testTemporaryQueue() throws Exception {
        String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
        StringResult result = new StringResult();
        webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
        XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
    }
View Full Code Here

    @Test
    public void testPermanentQueue() throws Exception {
        String url = "jms:RequestQueue?deliveryMode=NON_PERSISTENT;replyToName=ResponseQueue";
        String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
        StringResult result = new StringResult();
        webServiceTemplate.sendSourceAndReceiveToResult(url, new StringSource(content), result);
        XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
    }
View Full Code Here

    @Test
    public void testSaxPayload() throws Exception {
        SAXSource saxSource = new SAXSource(SaxUtils.createInputSource(payload));
        transformer.transform(saxSource, webServiceMessage.getPayloadResult());
        StringResult stringResult = new StringResult();
        transformer.transform(webServiceMessage.getPayloadSource(), stringResult);
        assertXMLEqual(getExpectedString(), stringResult.toString());
        validateMessage();
    }
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.