[Asterisk-code-review] Add tests to verify pidf+xml & xpidf+xml NOTIFY bodies. (testsuite[master])

Mark Michelson asteriskteam at digium.com
Tue Aug 4 16:47:30 CDT 2015


Mark Michelson has posted comments on this change.

Change subject: Add tests to verify pidf+xml & xpidf+xml NOTIFY bodies.
......................................................................


Patch Set 3: Code-Review-2

(1 comment)

https://gerrit.asterisk.org/#/c/1023/3/tests/channels/pjsip/subscriptions/presence/pidf_xml/sipp/subscribe.xml
File tests/channels/pjsip/subscriptions/presence/pidf_xml/sipp/subscribe.xml:

Line 29:      <ereg regexp="<presence entity=\"sip:bob at 127.0.0.1(:5060)?\" xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\" xmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\" xmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\">
       :  <note>Ready</note>
       :  <tuple id=\"bob\">
       :   <status>
       :    <basic>open</basic>
       :   </status>
       :   <contact priority=\"1\">&quot\;alice&quot\; &lt\;sip:alice at 127.0.0.1&gt\;</contact>
       :  </tuple>
       :  <pp:person>
       :   <status />
       :  </pp:person>
       : </presence>" check_it="true" search_in="body" assign_to="body1" />
       :     </action>
       :   </recv>
Regex is not a good tool for verifying an XML document. A regex such as this one is particular about formatting, such as the number of spaces at the beginning of a line of content, whether the contents of an XML element are divided onto multiple lines or printed on a single line, and how XML elements with no text are formatted (such as the <status /> on line 38).

If you want to check that all parts of a NOTIFY body's XML document are what you expect them to be, you'll have much better luck running the XML text through a parser and then iterating over the document's elements programmatically. This way, changes in the XML's presentation will not cause the test to fail.


-- 
To view, visit https://gerrit.asterisk.org/1023
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib852d1d42ea391fe4e7d1abf0eb7ea6eabb62cba
Gerrit-PatchSet: 3
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: John Bigelow <jbigelow at digium.com>
Gerrit-Reviewer: John Bigelow <jbigelow at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-HasComments: Yes



More information about the asterisk-code-review mailing list