在创建模拟服务时使用bodyPath()时出错

时间:2019-02-27 15:58:05

标签: karate

我的模拟场景如下。

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

要模拟的网址-'http://localhost:8080/tokenisationservice/TokenisationWS_1_3'

请求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>

运行独立的空手道网。这会产生以下错误,而无法给出期望的响应。

15:53:19.159 [nioEventLoopGroup-3-3]警告com.intuit.karate-方案匹配评估失败:javascript评估失败:pathMatches('/ tokenisationservice / TokenisationWS_1_3')&& bodyPath('/ Enve lope / Body / getToken / GetTokenRequest / enterpriseID')=='1'

1 个答案:

答案 0 :(得分:0)

看起来像是您的模拟/功能中的错字。我尝试过,它对我有用。还请注意,import spark.implicits._ val dummyDf = Seq(("John[", "Ha", "Smith?"), ("Julie", "Hu", "Burol"), ("Ka%rl", "G", "Hu!"), ("(Harold)", "Ju", "Di+") ).toDF("FirstName", "MiddleName", "LastName") dummyDf.show() +---------+----------+--------+ |FirstName|MiddleName|LastName| +---------+----------+--------+ | John[| Ha| Smith?| | Julie| Hu| Burol| | Ka%rl| G| Hu!| | (Harold)| Ju| Di+| +---------+----------+--------+ Expected Output +---------+----------+--------+ |FirstName|MiddleName|LastName| +---------+----------+--------+ | John[| Ha| Smith?| | Ka%rl| G| Hu!| | (Harold)| Ju| Di+| +---------+----------+--------+ 仅在Karate 0.8.0中引入

模拟:

bodyPath()

测试:

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