1

My mock scenario is as below.

Scenario: pathMatches('/tokenisationservice/TokenisationWS_1_3') && bodyPath('/Envelope/Body/getToken/GetTokenRequest/enterpriseID') == '1'

url to be mocked- 'http://localhost:8080/tokenisationservice/TokenisationWS_1_3'

Request XML

<soapenv:Envelope blah blah blah>
   <soapenv:Header/>
   <soapenv:Body>
      <tok:getToken>
            <GetTokenRequest>
            <enterpriseID>1</enterpriseID>
            <merchantGroupID>1</merchantGroupID>
            <pan>1234567890123456</pan>
         </GetTokenRequest>
      </tok:getToken>
   </soapenv:Body>
</soapenv:Envelope>

Running standalone karate-netty. This gives the below error and not giving the desired response back.

15:53:19.159 [nioEventLoopGroup-3-3] WARN com.intuit.karate - scenario match evaluation failed: javascript evaluation failed: pathMatches('/tokenisationservice/TokenisationWS_1_3') && bodyPath('/Enve lope/Body/getToken/GetTokenRequest/enterpriseID') == '1'

Sindhu
  • 47
  • 7

1 Answers1

0

Looks like a typo in your mock / feature. I tried it and it works for me. Also note that bodyPath() was introduced in Karate 0.8.0 only

mock:

Scenario: pathMatches('/tokenisationservice/TokenisationWS_1_3') && bodyPath('/Envelope/Body/getToken/GetTokenRequest/enterpriseID') == '1'
  * print request
  * def response = { success: true }

test:

* url karate.properties['mock.url']
* path '/tokenisationservice/TokenisationWS_1_3'
* request
"""
<soapenv:Envelope>
   <soapenv:Header/>
   <soapenv:Body>
      <tok:getToken>
            <GetTokenRequest>
            <enterpriseID>1</enterpriseID>
            <merchantGroupID>1</merchantGroupID>
            <pan>1234567890123456</pan>
         </GetTokenRequest>
      </tok:getToken>
   </soapenv:Body>
</soapenv:Envelope>
"""
* method post
* status 200
* print response
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Hi, I copied the scenario line from your comment but still the same error. Interesting to note that if I delete the '&& bodyPath(....)' part in the Scenario line and run it with just the pathMatches, the mock works as expected with the test. – Sindhu Feb 27 '19 at 18:36
  • @Sindhu - ok time for me to point you to this process, all the best: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Feb 27 '19 at 18:44
  • Another observation - the same statement works without any issues in a maven project but fails when run standalone. Karate-netty-0.9.1 is used as the standalone jar. Same version is used in maven too. Do I need to attach a maven project for creating the issue in Git? – Sindhu Feb 27 '19 at 23:17
  • @Sindhu karate-netty !? in this case upload a zip file with your project structure - you can omit the jar but specify where you got it from – Peter Thomas Feb 28 '19 at 00:46
  • Will do. But concerned with your expression against karate-netty. Should I not be using it? Got it from here. https://mvnrepository.com/artifact/com.intuit.karate/karate-netty/0.9.1. – Sindhu Feb 28 '19 at 11:01
  • @Sindhu that’s wrong. can you please read the docs and find the right link ? – Peter Thomas Feb 28 '19 at 11:06