Closed danidemi closed 9 years ago
Ok, so I don't get the meaning of the regex() method...
Here another example... here I would like to assert that the body matches the regex .+
. Now... obviously the body should match it because .+
matches all.
java.lang.AssertionError: Request not found exactly once, expected:<{
"method" : "POST",
"body" : {
"type" : "REGEX",
"value" : ".+"
}
}> but was:<{
"method" : "POST",
"path" : "/",
"body" : "--ipL-ZAWLTXJsVcr0mD7neREQXV5KxOCfedJjpBy3\r\nContent-Disposition: form-data; name=\"VERSIONE\"\r\n\r\nversione\r\n--ipL-ZAWLTXJsVcr0mD7neREQXV5KxOCfedJjpBy3\r\nContent-Disposition: form-data; name=\"LOGINNAME \"\r\n\r\nlogin\r\n--ipL-ZAWLTXJsVcr0mD7neREQXV5KxOCfedJjpBy3\r\nContent-Disposition: form-data; name=\"PASSWORD \"\r\n\r\npassword\r\n--ipL-ZAWLTXJsVcr0mD7neREQXV5KxOCfedJjpBy3\r\nContent-Disposition: form-data; name=\"XMLSIP\"\r\n\r\n
Ok, I got it. The reg ex should match the whole body.
Here is how I fixed it...
mockServerClient.verify(
request().withMethod("POST").withBody(regex("[\\n.\\w\\W]*VERSIONE[\\n.\\w\\W]*versione[\\n.\\w\\W]*")),
VerificationTimes.exactly(1)
);
Or you can use multiline regexes that consider newlines as whitespaces by employing the (?ms)
flag at the beginning of your regex.
Hi.
I'm getting this exception following an assertion.
What it's strange is that I specified this assertion on the body...
...and if you check the body the XMLSIP string is actually there. So, if I'm getting the whole thing properly, it should not raise that exception, shouldn't it ?