Package org.springframework.xml.transform

Examples of org.springframework.xml.transform.StringSource


    public void xpathExistsNonMatch() throws Exception {
        final Map<String, String> ns = Collections.singletonMap("ns", "http://example.com");

        server.expect(xpath("/ns:foo", ns).exists());

        template.sendSourceAndReceiveToResult(new StringSource("<request xmlns='http://example.com'/>"),
                new StringResult());
    }
View Full Code Here


                new StringResult());
    }

    @Test
    public void anythingMatch() throws Exception {
        Source request = new StringSource("<request xmlns='http://example.com'/>");
        Source response = new StringSource("<response xmlns='http://example.com'/>");

        server.expect(anything()).andRespond(withPayload(response));

        StringResult result = new StringResult();
        template.sendSourceAndReceiveToResult(request, result);
        assertXMLEqual(result.toString(), response.toString());

        server.verify();
    }
View Full Code Here

        server.verify();
    }

    @Test(expected = IllegalStateException.class)
    public void recordWhenReplay() throws Exception {
        Source request = new StringSource("<request xmlns='http://example.com'/>");
        Source response = new StringSource("<response xmlns='http://example.com'/>");

        server.expect(anything()).andRespond(withPayload(response));
        server.expect(anything()).andRespond(withPayload(response));

        StringResult result = new StringResult();
        template.sendSourceAndReceiveToResult(request, result);
        assertXMLEqual(result.toString(), response.toString());

        server.expect(anything()).andRespond(withPayload(response));
    }
View Full Code Here

        server.verify();
    }

    @Test(expected = SoapFaultClientException.class)
    public void fault() throws Exception {
        Source request = new StringSource("<request xmlns='http://example.com'/>");

        server.expect(anything()).andRespond(withClientOrSenderFault("reason", Locale.ENGLISH));

        StringResult result = new StringResult();
        template.sendSourceAndReceiveToResult(request, result);
View Full Code Here

    }

    @Test
    public void normal() throws IOException {
        MockSenderConnection connection = new MockSenderConnection();
        connection.andRespond(withPayload(new StringSource("<response/>")));
        assertFalse(connection.hasError());
        assertNull(connection.getErrorMessage());
    }
View Full Code Here

    }

    @Test(expected = AssertionError.class)
    public void noRequestMatchers() throws IOException {
        MockSenderConnection connection = new MockSenderConnection();
        connection.andRespond(withPayload(new StringSource("<response/>")));
        connection.send(null);
    }
View Full Code Here

        mockServer = MockWebServiceServer.createServer(client);
    }

    @Test
    public void basic() throws Exception {
        Source expectedRequestPayload = new StringSource(
                "<customerCountRequest xmlns='http://springframework.org/spring-ws'>" +
                        "<customerName>John Doe</customerName>" + "</customerCountRequest>");
        Source responsePayload = new StringSource(
                "<customerCountResponse xmlns='http://springframework.org/spring-ws'>" +
                        "<customerCount>10</customerCount>" + "</customerCountResponse>");

        mockServer.expect(payload(expectedRequestPayload)).andRespond(withPayload(responsePayload));
View Full Code Here

        interceptor.setSecurementActions("Signature");
        interceptor.setEnableSignatureConfirmation(false);
        interceptor.setSecurementPassword("123456");
        interceptor.setSecurementUsername("rsaKey");
        SOAPMessage saajMessage = saajSoap11MessageFactory.createMessage();
        transformer.transform(new StringSource(PAYLOAD), new DOMResult(saajMessage.getSOAPBody()));
        SoapMessage message = new SaajSoapMessage(saajMessage, saajSoap11MessageFactory);
        MessageContext messageContext = new DefaultMessageContext(message, new SaajSoapMessageFactory(saajSoap11MessageFactory));

        interceptor.secureMessage(message, messageContext);
View Full Code Here

    }

    @Test
    public void withPayloadSource() throws Exception {
        String payload = "<payload xmlns='http://springframework.org'/>";
        ResponseCreator responseCreator = ResponseCreators.withPayload(new StringSource(payload));

        WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory);

        assertXMLEqual(payload, getPayloadAsString(response));
View Full Code Here

    xmlBuilder.append("<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope'>");
    xmlBuilder.append("<soap:Header><header xmlns='http://springframework.org'/></soap:Header>");
    xmlBuilder.append("<soap:Body><payload xmlns='http://springframework.org'/></soap:Body>");
    xmlBuilder.append("</soap:Envelope>");
    String envelope = xmlBuilder.toString();
    ResponseCreator responseCreator = ResponseCreators.withSoapEnvelope(new StringSource(envelope));
        WebServiceMessage response = responseCreator.createResponse(null, null, messageFactory);
        assertXMLEqual(envelope, getSoapEnvelopeAsString((SoapMessage)response));
    }
View Full Code Here

TOP

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

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.