Package org.springframework.xml.transform

Examples of org.springframework.xml.transform.StringSource


        XPathExpectationsHelper helper = new XPathExpectationsHelper("//b");
        WebServiceMessageMatcher matcher = helper.evaluatesTo(2);
        assertNotNull(matcher);

        WebServiceMessage message = createMock(WebServiceMessage.class);
        expect(message.getPayloadSource()).andReturn(new StringSource("<a><b>1</b></a>")).times(2);

        replay(message);

        matcher.match(message);
    }
View Full Code Here


        WebServiceMessageMatcher matcher = helper.exists();
        assertNotNull(matcher);

        WebServiceMessage message = createMock(WebServiceMessage.class);
        expect(message.getPayloadSource())
                .andReturn(new StringSource("<a:a xmlns:a=\"http://example.org\"><a:b/></a:a>"));

        replay(message);

        matcher.match(message);
View Full Code Here

        WebServiceMessageMatcher matcher = helper.exists();
        assertNotNull(matcher);

        WebServiceMessage message = createMock(WebServiceMessage.class);
        expect(message.getPayloadSource())
                .andReturn(new StringSource("<a:a xmlns:a=\"http://example.org\"><a:b/></a:a>")).times(2);

        replay(message);

        matcher.match(message);
    }
View Full Code Here

    xmlBuilder.append("<soap:Body><payload xmlns='http://example.com'/></soap:Body>");
    xmlBuilder.append("</soap:Envelope>");
    String xml = xmlBuilder.toString();
    DOMResult result = new DOMResult();
    TransformerHelper transformerHelper = new TransformerHelper();
    transformerHelper.transform(new StringSource(xml), result);
        SoapMessage message = createMock(SoapMessage.class);
        expect(message.getDocument()).andReturn((Document)result.getNode()).once();
        replay(message);

        SoapEnvelopeDiffMatcher matcher = new SoapEnvelopeDiffMatcher(new StringSource(xml));
        matcher.match(message);

        verify(message);
    }
View Full Code Here

    xmlBuilder.append("</soap:Envelope>");
    String xml = xmlBuilder.toString();
    String actual = String.format(xml, "1");
    DOMResult result = new DOMResult();
    TransformerHelper transformerHelper = new TransformerHelper();
    transformerHelper.transform(new StringSource(actual), result);
        SoapMessage message = createMock(SoapMessage.class);
        expect(message.getDocument()).andReturn((Document)result.getNode()).once();
        replay(message);

        String expected = String.format(xml, "2");
        SoapEnvelopeDiffMatcher matcher = new SoapEnvelopeDiffMatcher(new StringSource(expected));
        matcher.match(message);
    }
View Full Code Here

    @Test
    public void match() throws Exception {
        String xml = "<element xmlns='http://example.com'/>";
        WebServiceMessage message = createMock(WebServiceMessage.class);
        expect(message.getPayloadSource()).andReturn(new StringSource(xml)).times(2);
        replay(message);

        PayloadDiffMatcher matcher = new PayloadDiffMatcher(new StringSource(xml));
        matcher.match(message);

        verify(message);
    }
View Full Code Here

    @Test(expected = AssertionError.class)
    public void nonMatch() throws Exception {
        String actual = "<element1 xmlns='http://example.com'/>";
        WebServiceMessage message = createMock(WebServiceMessage.class);
        expect(message.getPayloadSource()).andReturn(new StringSource(actual)).times(2);
        replay(message);

        String expected = "<element2 xmlns='http://example.com'/>";
        PayloadDiffMatcher matcher = new PayloadDiffMatcher(new StringSource(expected));
        matcher.match(message);
    }
View Full Code Here

        matcher.match(message);
    }

    @Test(expected = AssertionError.class)
    public void noPayload() throws Exception {
        PayloadDiffMatcher matcher = new PayloadDiffMatcher(new StringSource("<message/>"));
        MessageFactory messageFactory = MessageFactory.newInstance();
        SoapMessage soapMessage = new SaajSoapMessage(messageFactory.createMessage());

        matcher.createDiff(soapMessage);
    }
View Full Code Here

        schema2 = new ClassPathResource("schemaValidatingMatcherTest-2.xsd", SchemaValidatingMatcherTest.class);
    }

    @Test
    public void singleSchemaMatch() throws IOException, AssertionError {
        expect(message.getPayloadSource()).andReturn(new StringSource(
                "<test xmlns=\"http://www.example.org/schema\"><number>0</number><text>text</text></test>"));

        SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema);

        replay(message);
View Full Code Here

        verify(message);
    }

    @Test(expected = AssertionError.class)
    public void singleSchemaNonMatch() throws IOException, AssertionError {
        expect(message.getPayloadSource()).andReturn(new StringSource(
                "<test xmlns=\"http://www.example.org/schema\"><number>a</number><text>text</text></test>")).times(2);

        SchemaValidatingMatcher matcher = new SchemaValidatingMatcher(schema);

        replay(message);
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.