Smock spring-ws-test whitespace issue

80 views
Skip to first unread message

danhunter

unread,
Apr 15, 2011, 11:57:19 AM4/15/11
to smock-info, virt...@gmail.com
I have just started using Smock for testing spring-ws and I’m having a
problem when I have whitespace in my
retrieveCustomerDetailsResponse.xml file. If I remove all the
whitespace and have all of the xml on one line the test passes.
Otherwise I get the following failure message: Expected number of
child nodes '5' but was '2'

This is what I have in my test as per your examples:
ParametrizableResponseMatcher parametrizableResponseMatcher =
message("retrieveCustomerDetailsResponse.xml");


mockClient.sendRequest(withMessage("retrieveCustomerDetailsRequest.xml")
.withParameters(inParams))
.andExpect(parametrizableResponseMatcher
.withParameters(outParams));

Please can you tell me how to ignore whitespace.
Thanks,
Dan.

Lukáš Křečan

unread,
Apr 16, 2011, 7:14:53 AM4/16/11
to smock...@googlegroups.com, danhunter, virt...@gmail.com
Hi,
try to call this prior executing your test:

XMLUnit.setIgnoreWhitespace(true);

Please let me know if it helps. The same piece of code is invoked
automatically when creating the ResponseMatcher so it was supposed to
work out of the box.
Cheers
Lukas

danhunter

unread,
Apr 20, 2011, 3:07:10 AM4/20/11
to smock-info
Hi Lukas,
I didn't need to use XMLUnit.setIgnoreWhitespace(true); in the test,
it appears I just needed to have XMLUnit on the class-path. As I'm
using Maven for this project all I needed to do was to add XMLUnit 1.3
to the dependancies in the POM, and that resolved the whitespace
issue:

<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.3</version>
</dependency>

Thanks for you help.
Dan.


On Apr 16, 12:14 pm, Lukáš Křečan <lu...@krecan.net> wrote:
> Hi,
> try to call this prior executing your test:
>
> XMLUnit.setIgnoreWhitespace(true);
>
> Please let me know if it helps. The same piece of code is invoked
> automatically when creating the ResponseMatcher so it was supposed to
> work out of the box.
> Cheers
> Lukas
>
>
>
>
>
>
>
> > I have just started usingSmockfor testing spring-ws and I'm having a
Reply all
Reply to author
Forward
0 new messages