-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XML body matching #243
Comments
Nobody has provided any examples of XML body matching, and there is no DSL like for JSON bodies. |
XML response matching would be very useful to me as well.
It seems to me, from the following tests
My question is, is there any way to match XML which uses an explicit namespace and not just the default namespace? How can this be specified using the Pact Specification? |
XML matching is quite basic, and can not be applied based on namespaces. There is also no DSL like for JSON. You'll have to setup the matchers correctly, but it will work. |
Hi, is there any update on an XML DSL for matching? |
@mkinoo We're added an initial version of XML support to Pact-JS with a DSL. Once we have some feedback from the community, that can be ported to Pact-JVM. What testing framework and language would you use? |
@uglyog thanks for the info! |
Having tried the new XML DSL, I really like it! Thanks for implementing it so quickly. One problem I have found is when omitting the namespace from the
Looking at the code in question, I suspect it's because when the namespace is omitted,
which seems to add the root element to the document. The following code replicates this behaviour for me: new PactXmlBuilder("address").build(root -> {
root.appendElement("organisationName", emptyMap(), organisationName ->
organisationName.setAttributes(singletonMap("name", "organisationName0")));
} Furthermore, within this DSL, how would one add values to a tag as opposed to children? |
4.1.1 has been released with the fix |
Hi, I've had a look at the PactXmlBuilder - thanks for the updates on that! Unfortunately, what we really need is a DSL that generates the matching rules for an XML response, as it is implemented for JSON. I belive this is also what other people commenting on this issue were looking for? Could you reopen the issue and give an update on whether (and possibly when) you are planning to implement this? Thanks a lot and best regards, |
@mfbieber It does generate the matching rules. See https://github.com/DiUS/pact-jvm/blob/master/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/xml/TodoXmlTest.java |
Oh yes, you are right of course. In the example I tested it didn't. Thanks for pointing to the other example, I think that might work for us! Sorry for misunderstanding ;) |
Hi, Do we have an example of PactXmlBuilder for apache kafka please ? Many Thanks! |
@shivkavitha MessagePactBuilder already supports messages built with PactXmlBuilder |
is there a way to do only Schema Matchings for xml response using PactXmlBuilder ? i can see we can add matchers for attributes but it requires exact content to match to pass from provider side |
No, that is no support for schema matching. There are lots of tools that would do that, and it makes no sense to make Pact another one. |
I later found we can still achieve same behaviour that is it can support schema testing as well. |
Hi there,
Are there any examples for XML response body matching in consumer tests? This pull request suggests this has been implemented, but it is not very clear to me how to do this.
Thanks!
The text was updated successfully, but these errors were encountered: