Impracticallity with Test Suite assertEquals()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Impracticallity with Test Suite assertEquals()

Jonathan Rowell

Hi,


I have a minor issue with the assertEquals test in Test Suite which makes it rather hard to use.

The function under test decodes a string producing a piece of XML. The assert relies on comparing these two pieces of XML.

The documentation says 


 If the sequence returned by the function contains one or more XML elements, they will be normalized (i.e. ignorable whitespace is stripped). The assertion argument is then parsed into XML and the two node trees are compared using the deep-equals function.


Since my function constructs the XML out of a sequence of elements, there is no ignorable white space between the elements. But since the test has to be written in Test Suite it is almost impossible to achieve this.

Here is the example :


declare
%test:args('98YYYYYY99999920170201    0908542.00AO|AM|BXYYYYYYNYNNNNNNNN|AN|AF|AG|AY8AZEB63') 
%test:assertEquals('<sip2:acs-status  xmlns:sip2="http://www.3m.com/sip2">
                          <sip2:online-status>Y</sip2:online-status>
                          <sip2:checkin-ok>Y</sip2:checkin-ok>
                          <sip2:checkout-ok>Y</sip2:checkout-ok>
                          <sip2:ACS-renewal-policy>Y</sip2:ACS-renewal-policy>
                          <sip2:status-update-ok>Y</sip2:status-update-ok>
                          <sip2:offline-ok>Y</sip2:offline-ok>
                          <sip2:timeout-period>999</sip2:timeout-period>
                          <sip2:retries-allowed>999</sip2:retries-allowed>
                          <sip2:date-time-sync>20170201 090854</sip2:date-time-sync>
                          <sip2:protocol-version>2.00</sip2:protocol-version>
                          <sip2:institution-id/>
                          <sip2:library-name/>
                          <sip2:supported-messages>YYYYYYNYNNNNNNNN</sip2:supported-messages>
                          <sip2:terminal-location/>
                          <sip2:screen-message/>
                          <sip2:print-line/>
                          <sip2:sequence-number>8</sip2:sequence-number>
                          <sip2:check-sum>EB63</sip2:check-sum>
                          </sip2:acs-status>')
function sipp-test:decode98($mess as xs:string) as element() {
sipp:decode98($mess)
};

The test results in :-

<testcase name="sipp-test:decode98" class="sipp-test:decode98">
<failure message="assertEquals failed." type="failure-error-code-1">
<sip2:acs-status xmlns:sip2="http://www.3m.com/sip2">
 <sip2:online-status>Y</sip2:online-status>
 <sip2:checkin-ok>Y</sip2:checkin-ok>
 <sip2:checkout-ok>Y</sip2:checkout-ok>
 <sip2:ACS-renewal-policy>Y</sip2:ACS-renewal-policy>
 <sip2:status-update-ok>Y</sip2:status-update-ok>
 <sip2:offline-ok>Y</sip2:offline-ok>
 <sip2:timeout-period>999</sip2:timeout-period>
 <sip2:retries-allowed>999</sip2:retries-allowed>
 <sip2:date-time-sync>20170201 090854</sip2:date-time-sync>
 <sip2:protocol-version>2.00</sip2:protocol-version>
 <sip2:institution-id/> <sip2:library-name/>
 <sip2:supported-messages>YYYYYYNYNNNNNNNN</sip2:supported-messages>
 <sip2:terminal-location/> <sip2:screen-message/>
 <sip2:print-line/>
 <sip2:sequence-number>8</sip2:sequence-number>
 <sip2:check-sum>EB63</sip2:check-sum>
 </sip2:acs-status>
</failure>
<output>
<sip2:acs-status xmlns:sip2="http://www.3m.com/sip2">
<sip2:online-status>Y</sip2:online-status>
<sip2:checkin-ok>Y</sip2:checkin-ok>
<sip2:checkout-ok>Y</sip2:checkout-ok>
<sip2:ACS-renewal-policy>Y</sip2:ACS-renewal-policy>
<sip2:status-update-ok>Y</sip2:status-update-ok>
<sip2:offline-ok>Y</sip2:offline-ok>
<sip2:timeout-period>999</sip2:timeout-period>
<sip2:retries-allowed>999</sip2:retries-allowed>
<sip2:date-time-sync>20170201 090854</sip2:date-time-sync>
<sip2:protocol-version>2.00</sip2:protocol-version>
<sip2:institution-id/>
<sip2:library-name/>
<sip2:supported-messages>YYYYYYNYNNNNNNNN</sip2:supported-messages>
<sip2:terminal-location/>
<sip2:screen-message/>
<sip2:print-line/>
<sip2:sequence-number>8</sip2:sequence-number>
<sip2:check-sum>EB63</sip2:check-sum>
</sip2:acs-status>
</output>
</testcase>

As one can see the expected value has its whitespace between the elements reduced to one space. I have split the elements apart since they were all packed in one line.
The output on the other hand has no ignorable white space, but is formatted as if it had.


Unfortunately assertEquals() doesn't take a $variable as a result argument, so I can't declare the XML as, say, $output and compare it that way.
And I haven't yet fixed the documentation regarding assertXPath.

Jonathan

Ref:
multimedia.3m.com
3M™ Standard Interchange Protocol, Version 2.00 April 11, 2006 Document Rev. 2.12 Page 2 of 29 What’s New with the Standard Interchange Protocol?






------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Impracticallity with Test Suite assertEquals()

Jonathan Rowell

Hi,


further to this problem. The boundary white space declaration has no effect with the boundary white space caused by compiling the %test:args string into XML.


declare boundary-space strip;

It seems however to effect it with direct constructions (or at least that is what Wolfgang claimed in an E-Mail back in 2014) - my testing is not exhaustive.


Question regarding TestSuite : Ought not the declaration in the module apply to the parsing of the XML in an arg?


And if so, how can one query whether it is set for a module in XQuery (because TestSuite is written in XQuery)?


questions, questions....


Jonathan


 





From: Jonathan Rowell <[hidden email]>
Sent: Sunday, March 19, 2017 1:48 PM
To: eXist open
Subject: [Exist-open] Impracticallity with Test Suite assertEquals()
 

Hi,


I have a minor issue with the assertEquals test in Test Suite which makes it rather hard to use.

The function under test decodes a string producing a piece of XML. The assert relies on comparing these two pieces of XML.

The documentation says 


 If the sequence returned by the function contains one or more XML elements, they will be normalized (i.e. ignorable whitespace is stripped). The assertion argument is then parsed into XML and the two node trees are compared using the deep-equals function.


Since my function constructs the XML out of a sequence of elements, there is no ignorable white space between the elements. But since the test has to be written in Test Suite it is almost impossible to achieve this.

Here is the example :


declare
%test:args('98YYYYYY99999920170201    0908542.00AO|AM|BXYYYYYYNYNNNNNNNN|AN|AF|AG|AY8AZEB63') 
%test:assertEquals('<sip2:acs-status  xmlns:sip2="http://www.3m.com/sip2">
                          <sip2:online-status>Y</sip2:online-status>
                          <sip2:checkin-ok>Y</sip2:checkin-ok>
                          <sip2:checkout-ok>Y</sip2:checkout-ok>
                          <sip2:ACS-renewal-policy>Y</sip2:ACS-renewal-policy>
                          <sip2:status-update-ok>Y</sip2:status-update-ok>
                          <sip2:offline-ok>Y</sip2:offline-ok>
                          <sip2:timeout-period>999</sip2:timeout-period>
                          <sip2:retries-allowed>999</sip2:retries-allowed>
                          <sip2:date-time-sync>20170201 090854</sip2:date-time-sync>
                          <sip2:protocol-version>2.00</sip2:protocol-version>
                          <sip2:institution-id/>
                          <sip2:library-name/>
                          <sip2:supported-messages>YYYYYYNYNNNNNNNN</sip2:supported-messages>
                          <sip2:terminal-location/>
                          <sip2:screen-message/>
                          <sip2:print-line/>
                          <sip2:sequence-number>8</sip2:sequence-number>
                          <sip2:check-sum>EB63</sip2:check-sum>
                          </sip2:acs-status>')
function sipp-test:decode98($mess as xs:string) as element() {
sipp:decode98($mess)
};

The test results in :-

<testcase name="sipp-test:decode98" class="sipp-test:decode98">
<failure message="assertEquals failed." type="failure-error-code-1">
<sip2:acs-status xmlns:sip2="http://www.3m.com/sip2">
 <sip2:online-status>Y</sip2:online-status>
 <sip2:checkin-ok>Y</sip2:checkin-ok>
 <sip2:checkout-ok>Y</sip2:checkout-ok>
 <sip2:ACS-renewal-policy>Y</sip2:ACS-renewal-policy>
 <sip2:status-update-ok>Y</sip2:status-update-ok>
 <sip2:offline-ok>Y</sip2:offline-ok>
 <sip2:timeout-period>999</sip2:timeout-period>
 <sip2:retries-allowed>999</sip2:retries-allowed>
 <sip2:date-time-sync>20170201 090854</sip2:date-time-sync>
 <sip2:protocol-version>2.00</sip2:protocol-version>
 <sip2:institution-id/> <sip2:library-name/>
 <sip2:supported-messages>YYYYYYNYNNNNNNNN</sip2:supported-messages>
 <sip2:terminal-location/> <sip2:screen-message/>
 <sip2:print-line/>
 <sip2:sequence-number>8</sip2:sequence-number>
 <sip2:check-sum>EB63</sip2:check-sum>
 </sip2:acs-status>
</failure>
<output>
<sip2:acs-status xmlns:sip2="http://www.3m.com/sip2">
<sip2:online-status>Y</sip2:online-status>
<sip2:checkin-ok>Y</sip2:checkin-ok>
<sip2:checkout-ok>Y</sip2:checkout-ok>
<sip2:ACS-renewal-policy>Y</sip2:ACS-renewal-policy>
<sip2:status-update-ok>Y</sip2:status-update-ok>
<sip2:offline-ok>Y</sip2:offline-ok>
<sip2:timeout-period>999</sip2:timeout-period>
<sip2:retries-allowed>999</sip2:retries-allowed>
<sip2:date-time-sync>20170201 090854</sip2:date-time-sync>
<sip2:protocol-version>2.00</sip2:protocol-version>
<sip2:institution-id/>
<sip2:library-name/>
<sip2:supported-messages>YYYYYYNYNNNNNNNN</sip2:supported-messages>
<sip2:terminal-location/>
<sip2:screen-message/>
<sip2:print-line/>
<sip2:sequence-number>8</sip2:sequence-number>
<sip2:check-sum>EB63</sip2:check-sum>
</sip2:acs-status>
</output>
</testcase>

As one can see the expected value has its whitespace between the elements reduced to one space. I have split the elements apart since they were all packed in one line.
The output on the other hand has no ignorable white space, but is formatted as if it had.


Unfortunately assertEquals() doesn't take a $variable as a result argument, so I can't declare the XML as, say, $output and compare it that way.
And I haven't yet fixed the documentation regarding assertXPath.

Jonathan

Ref:
multimedia.3m.com
3M™ Standard Interchange Protocol, Version 2.00 April 11, 2006 Document Rev. 2.12 Page 2 of 29 What’s New with the Standard Interchange Protocol?






------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Loading...