Skip to content
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

Removing specific expectations #42

Closed
ninckblokje opened this issue May 21, 2014 · 5 comments
Closed

Removing specific expectations #42

ninckblokje opened this issue May 21, 2014 · 5 comments
Assignees

Comments

@ninckblokje
Copy link

Hi,

I have a question concerning the removing of specific expectations. Is it possible to remove a single expectation for a specific path?

For example: I have set an expectation for path /test with an XPath body match on //test=1. I have set a second expectation for path /test with an XPath body match on //test=2. Is it possible to remove the first expectation without removing the second one, even if no message has been received by the mock server?

Jeroen

@jamesdbloom
Copy link
Collaborator

Yes it is possible, if you use the clear function it will only remove the expectations that exactly match the request you provide, i.e:

mockServerClient.clear(
        request()
                .withPath("/test")
                .withBody(xpath("//test=1"))
);

@ninckblokje
Copy link
Author

Hi,

Thanks for the quick response! When I try that using JSON the expectations appears to remain.

My JSON for setting the expectation looks like this:
httpRequest": {
"method": "POST",
"path": "/test",
"body": {
"type": "XPATH",
"value": "//test=1"
},
"headers": [
{
"name": "SOAPAction",
"values": [""""]
}
]
},
"httpResponse": {
"statusCode": 200,
"headers": [
{
"name": "Content-Type",
"values": ["application/soap+xml; charset=utf-8"]
}
],
"body": "[SOME_SOAP_ENVELOPE]"
}

My JSON for removing the expectation looks like this:
{
"method": "POST",
"path": "/test",
"body": {
"type": "XPATH",
"value": "//test=1"
},
"headers": [
{
"name": "SOAPAction",
"values": [""""]
}
]
}

When I ommit the body part the expectation is removed.

Jeroen

@jamesdbloom
Copy link
Collaborator

ok I'll take a look

@jamesdbloom
Copy link
Collaborator

I've been away this weekend but I'll take a look in the next couple of days and add extra tests to make sure there aren't any bugs (or fix them if there are).

jamesdbloom added a commit that referenced this issue May 27, 2014
…XPath expectation (it only matched an actual XPath body)
@jamesdbloom
Copy link
Collaborator

I resolved the issue and added a test for this scenario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants