私はWiremocksでケースを作成していますが、私はレスポンスモックを生成しています。XpathバリデーションのワイヤモックマッチXPath式
私はこのようなXML要求を持っている:入力/ XW:要素1 = 0100、XW:入力/ XW:要素2 = 741とI
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xw="http://example.com">
<soapenv:Header/>
<soapenv:Body>
<xw:gen>
<xw:input>
<xw:element1>0100</xw:element1>
<xw:element2>741</xw:element2>
<xw:element3>JAVA</xw:element3>
<xw:element4>123</xw:element4>
</xw:input>
<xw:global>
<xw:obj1>
<xw:attr1>john</xw:attr1>
<xw:attr2>doe</xw:attr2>
</xw:obj1>
</xw:global>
</xw:gen>
</soapenv:Body>
</soapenv:Envelope>
私だけXWことを検証する必要がありますxw:globalノードに何かがあることが必要です。 xw:globalの唯一の条件は空ではありません。 (このノードは<xw:global></xw:global>
になります)。
これは、JSONの私のモックです:
{
"request" : {
"url" : "/myweb/myrequest.asmx",
"headers": {
"SOAPAction": {
"equalTo": "\"http://example.com/gen\""
}
},
"bodyPatterns" : [ {
"matchesXPath": "//xw:input[xw:element1=\"0100\" and xw:element2=\"741\" ]",
"xPathNamespaces" : {
"xw" : "http://example.com"
}
}]
},
"response" : {
"status" : 200,
"headers": {
"Content-Type": "text/xml;charset=UTF-8"
},
"body" : "<Abody>"
}
}
質問です:グローバル空いていないかnullではない:私はノードXWがあることを検証することができますか?
私はこのmatchesXPathと試みたが、私は幸運持っていなかった。
"matchesXPath": "//xw:input[xw:element1=\"0100\" and xw:element2=\"741\" ] and count(//xw:global) > 0"
を。
ありがとうございました。
スタブ定義に名前空間を指定しましたか?そうでなければ、XPath式でそれらを使用することはできません。 – Tom
はい。私は名前空間を指定しました。ありがとう。 – dani77