[英]Tsung match tag : How to match specific xml tag (Server response is XML)
我正在使用tsung测试Web应用程序。 当请求时,服务器以xml响应。
我要做什么:如果发生错误,请在请求中使用tsung match标记进行记录。
如果发生错误,则xml响应如下:
<?xml version="1.0" encoding="UTF-8" ?>
<toto:root xmlns:toto="toto_url" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<toto:header>
<toto:trace-id>Testing</toto:trace-id>
<toto:timestamp>1420441279107</toto:timestamp>
<toto:command>MyServiceName</toto:command>
<toto:version>2.4</toto:version>
<toto:operation-id/>
<toto:calling-user>Tester</toto:calling-user>
<toto:calling-application>Tester</toto:calling-application>
<toto:calling-channel/>
<toto:locale-code>en</toto:locale-code>
<toto:country-code>EN</toto:country-code>
<toto:error>
<toto:applicative>
<toto:code>002</toto:code>
<toto:message>No record found</toto:message>
</toto:applicative>
</toto:error>
</toto:header>
<app:data xmlns:app="url_toto_service">
<app:totoNullPayload>
<app:result>OK</app:result>
</app:totoNullPayload>
</app:data>
我需要为错误代码值002和其他错误代码值登录match.log的特定名称。
到目前为止,我已经完成了这项工作。 当我在响应中获得值002时,它将登录到匹配日志中。 问题是即使它不在标记内,它也匹配002值。 因此,它有时会匹配包含此值的常规xml响应。 002008
我的问题是如何匹配错误值及其在标记内的事实?
tsung请求部分是:
<request subst="true">
<match name="Norecord" do="log" when="match" skip_headers="http" subst="true">002</match>
<match name="Request Error" do="log" when="match" skip_headers="http" subst="true">008</match>
<http url="/myApp/XmlHttpInbound" method="POST" version="1.1"
content_type="application/xml"
contents_from_file="/tmp/query.xml">
</http>
更新:
Tsung测试计划指定为xml文件,因此您应该转义期望的xml符号。 要在标签内匹配002和008错误代码,可以使用:
<request subst="true">
<match do="log" when="match" skip_headers="http" subst="true"><toto:code>002</toto:code></match>
<match do="log" when="match" skip_headers="http" subst="true"><toto:code>008</toto:code></match>
<http url="/myApp/XmlHttpInbound" method="POST" version="1.1"
content_type="application/xml"
contents_from_file="/tmp/query.xml">
</http>
</request>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.