Tutorial tests

This section contains some additional tests that aims to check that new releases of RefleX won't break the examples runnable in the tutorial section.

Each test consist on unmarshalling the active sheets of the tutorials and running them with some input datas. The tutorials that relies on an XML native database (XQuery) are not tested here; since 0.4.0, SQL tutorials have been added. Since 0.3.1, Web applications are tested as well with WUnit.

Don't be confused by the system output : some are showing errors because the normal output of theses examples are to produce an error (and the test case consist on checking that we do get an error).

Report

[tests/xunit/tutorial/tutorial-err.xml]

 
Skip
Test name
TestsErrorsFailure
0
Summary of tutorial tests
26
(1126)
0
(0)
0
(0)
1/26[Web] Welcome page7700
2/26[Web] Gallery page1000
3/26[Web] Upload page400
4/26[Web] Delete page : AJAX2000
5/26[Web] Delete page : form600
6/26[Web] Delete page : Javascript400
7/26[Web] Scenario1200
8/26XML validation with Active Schema (co-occurrence constraint on classification level)100
9/26XML validation with Active Schema (co-occurrence constraint on table columns)100
10/26XML validation with Active Schema (algorithmic validation) - variant 100100
11/26XML validation with Active Schema (algorithmic validation) - variant 105100
12/26XML validation with Active Schema (algorithmic validation) - variant 95100
13/26Splitting a SAX source to multiple XML chunks thanks to XPath-based filters3400
14/26Hello world !2000
15/26Hello world ! (template)2000
16/26Parsing a multipart SOAP message with a regular expression1800
17/26Text to XML8800
18/26Playing with datatypes and PSVI - variant 1400
19/26Playing with datatypes and PSVI - variant 2400
20/26Playing with datatypes and PSVI - variant 3400
21/26Playing with datatypes and PSVI - variant 4400
22/26[Web] Hello world !2600
23/26[Web] SQL20700
24/26[Web] Publication with XSLT1200
25/26Publication with XSLT40000
26/26XUnit step by step14700

Tests detail

[doc/tests/xunit/tutorial/tutorial.cat]

<?xml version="1.0" encoding="iso-8859-1"?>
<cat:catalog xmlns:cat="http://ns.inria.org/active-catalog" xmlns:exp="http://ns.inria.org/active-tags/exp"> <cat:resource name="http://reflex.gforge.inria.fr/tests-tutorial.html" uri="tutorial.exp"
selector="exp:module"/> </cat:catalog>

[doc/tests/xunit/tutorial/tutorial.exp]

<?xml version="1.0" encoding="iso-8859-1"?>
<exp:module version="1.0" target="test" xmlns:xcl="http://ns.inria.org/active-tags/xcl" xmlns:sys="http://ns.inria.org/active-tags/sys" xmlns:io="http://ns.inria.org/active-tags/io" xmlns:web="http://ns.inria.org/active-tags/web" xmlns:rdbms="http://ns.inria.org/active-tags/rdbms" xmlns:exp="http://ns.inria.org/active-tags/exp" xmlns:xunit="http://reflex.gforge.inria.fr/xunit.html" xmlns:wunit="http://reflex.gforge.inria.fr/wunit.html" xmlns:test="http://reflex.gforge.inria.fr/tests-tutorial.html"> <exp:element name="test:wsql"> <xunit:test-case name="report/wsql" label="[Web] SQL"> <rdbms:connect name="db" url="jdbc:hsqldb:file:doc/tutorial/sql/db/po"> <xcl:fallback> <xunit:skip message="JDBC driver not available (hsqldb.jar)"/> </xcl:fallback> </rdbms:connect> <wunit:conversation application="../../../tutorial/sql/component/web/WEB-INF/web.xml"
uri="http://www.example.com" xcl:if="{ $db }"> <wunit:submit method="GET" url="http://www.example.com"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:response-code ) }" expected="200"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:mime-type ) }" expected="text/html"/> <xcl:document name="oe"><select name="order-id"><option value="1234">1234</option><option value="5678">5678</option></select></xcl:document> <xunit:assert-node-equals result="{ $wunit:document/html/body/form/select }" expected="{ $oe/select }"/> <wunit:fill-form form="{ $wunit:document/html/body/form }"> <xcl:param name="order-id" value="1234"/> </wunit:fill-form> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:response-code ) }" expected="200"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:mime-type ) }" expected="text/html"/> <xcl:parse name="oe" source="result/wsql/purchase-order-1234.html"/> <xunit:assert-node-equals result="{ $wunit:document//table }" expected="{ $oe/table }"/> <wunit:click target="{ $wunit:document//a[.='Home'] }"/> <wunit:fill-form form="{ $wunit:document/html/body/form }"> <xcl:param name="order-id" value="5678"/> </wunit:fill-form> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:response-code ) }" expected="200"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:mime-type ) }" expected="text/html"/> <xcl:parse name="oe" source="result/wsql/purchase-order-5678.html"/> <xunit:assert-node-equals result="{ $wunit:document//table }" expected="{ $oe/table }"/> </wunit:conversation> </xunit:test-case> </exp:element> <exp:element name="test:wgallery"> <!--the test suite already exist, just run it...--> <exp:invoke processor="../../../tutorial/wunit/test-suite/1-welcome-page.xcl"/> <exp:invoke processor="../../../tutorial/wunit/test-suite/2-gallery-page.xcl"/> <exp:invoke processor="../../../tutorial/wunit/test-suite/3-upload-page.xcl"/> <exp:invoke processor="../../../tutorial/wunit/test-suite/4-delete-page.xcl"/> <exp:invoke processor="../../../tutorial/wunit/test-suite/5-scenario.xcl"/> <!--...and acquire the reports--> <io:copy source="../../../tutorial/wunit/test-suite/report/" target="."
filter="{ not(./@io:is-file) or not(parent::report) }"/> </exp:element> <exp:element name="test:hello-template"> <xunit:test-case name="report/hello-template" label="Hello world ! (template)"> <exp:unmarshal name="hello" source="../../../tutorial/basic/hello/hello-world-template.xcl"/> <xcl:append referent="{ $sys:env }"> <xcl:item name="who" value="John Doe"/> </xcl:append> <exp:invoke name="result" processor="{ $hello }"/> <!--check the result--> <xcl:parse source="result/hello.xml" name="oe"/> <!--check the root element because one is a fragment, the other is a document--> <xunit:assert-node-equals result="{ $result/* }" expected="{ $oe/* }"/> </xunit:test-case> </exp:element> <exp:element name="test:hello"> <xunit:test-case name="report/hello" label="Hello world !"> <exp:unmarshal name="hello" source="../../../tutorial/basic/hello/hello-world.xcl"/> <xcl:append referent="{ $sys:env }"> <xcl:item name="who" value="John Doe"/> </xcl:append> <exp:invoke processor="{ $hello }"/> <!--check the result--> <xcl:parse source="result/hello.xml" name="oe"/> <xcl:parse source="{ $sys:OUT }" name="result"/> <!--check the root element because one is a fragment, the other is a document--> <xunit:assert-node-equals result="{ $result/* }" expected="{ $oe/* }"/> </xunit:test-case> </exp:element> <exp:element name="test:whello"> <xunit:test-case name="report/whello" label="[Web] Hello world !"> <wunit:conversation application="../../../tutorial/basic/hello/web/WEB-INF/web.xml"
uri="http://www.example.com/hello"> <wunit:submit method="GET" url="http://www.example.com/hello/index.xml?who=John Doe&a=b"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:response-code ) }" expected="200"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:mime-type ) }" expected="application/xml"/> <xcl:parse source="result/hello.xml" name="oe"/> <xunit:assert-node-equals result="{ $wunit:document }" expected="{ $oe }"/> </wunit:conversation> </xunit:test-case> </exp:element> <exp:element name="test:xslt"> <xunit:test-case name="report/xslt" label="Publication with XSLT"> <exp:unmarshal name="xslt" source="../../../tutorial/basic/xslt/active-sheet.xcl"/> <exp:invoke processor="{ $xslt }"/> <!--check the result--> <xcl:set name="files"
value="{ io:file('result/xslt/')//*[@io:is-file][@io:extension='html'] }"/> <xunit:assert-number-equals result="{ count( $files ) }" expected="3"/> <xcl:echo value="----------"/> <xcl:for-each name="file" select="{ $files }"> <xcl:set name="result"
value="{ io:resolve-uri( io:file( '../../../tutorial/basic/xslt/build/' ), io:relativize-uri( io:file( 'result/xslt/' ), $file ) ) }"/> <xcl:echo value="Compare { io:relativize-uri( io:file( '.'), $file ) }"/> <xcl:echo
value=" with ../../../{ io:relativize-uri( io:file( '../../../' ), io:file( $result ) ) }"/> <xcl:parse-html source="{ $file }" name="oe"/> <xcl:parse-html source="{ $result }" name="result"/> <xunit:assert-node-equals result="{ $result }" expected="{ $oe }"/> </xcl:for-each> </xunit:test-case> </exp:element> <exp:element name="test:wxslt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xunit:test-case name="report/wxslt" label="[Web] Publication with XSLT"> <wunit:conversation application="../../../tutorial/basic/xslt/web/WEB-INF/web.xml"
uri="http://www.example.com/xslt"> <wunit:submit method="GET" url="http://www.example.com/xslt/index.html"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:response-code ) }" expected="200"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:mime-type ) }" expected="text/html"/> <xcl:parse-html source="result/xslt/index.html" name="oe" elems-name="lower"/> <xcl:transform source="{ $wunit:document }" name="dom" style="tree"
stylesheet="../reflex/wunit/prune.xsl"/> <xunit:assert-node-equals result="{ $dom/body }" expected="{ $oe/body }"/> <wunit:submit event="click" target="{ $wunit:document//a[@href][contains(.,'1234')] }"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:response-code ) }" expected="200"/> <xunit:assert-string-equals result="{ string( $wunit:frame/@wunit:mime-type ) }" expected="text/html"/> <xcl:parse-html source="result/xslt/purchase-orders/1234.html" name="oe" elems-name="lower"/> <xcl:transform source="{ $wunit:document }" name="dom" style="tree"
stylesheet="../reflex/wunit/prune.xsl"/> <xunit:assert-node-equals result="{ $dom/body }" expected="{ $oe/body }"/> </wunit:conversation> </xunit:test-case> </exp:element> <exp:element name="test:active-schema-co-oc"> <xunit:test-case name="report/active-schema-co-oc"
label="XML validation with Active Schema (co-occurrence constraint on table columns)"> <exp:unmarshal name="active-schema" source="../../../tutorial/schema/co-oc/validate.xcl"/> <exp:invoke processor="{ $active-schema }"/> <!--check the result--> <xcl:parse source="result/active-schema-co-oc.txt" name="oe"/> <xcl:parse source="{ $sys:OUT }" name="result"/> <xunit:assert-string-equals result="{ string( $result ) }" expected="{ string( $oe ) }"/> </xunit:test-case> </exp:element> <exp:element name="test:active-schema-classification"> <xunit:test-case name="report/active-schema-classification"
label="XML validation with Active Schema (co-occurrence constraint on classification level)"> <exp:unmarshal name="active-schema"
source="../../../tutorial/schema/classification/validate.xcl"/> <exp:invoke processor="{ $active-schema }"/> <!--check the result--> <xcl:parse source="result/active-schema-classification.txt" name="oe"/> <xcl:parse source="{ $sys:OUT }" name="result"/> <xunit:assert-string-equals result="{ string( $result ) }" expected="{ string( $oe ) }"/> </xunit:test-case> </exp:element> <exp:element name="test:active-schema-vote-count"> <xunit:test-case name="report/active-schema-vote-count-{ value( $exp:params/@variant ) }"
label="XML validation with Active Schema (algorithmic validation) - variant { value( $exp:params/@variant ) }"> <exp:unmarshal name="validation" source="../../../tutorial/schema/vote-count/validate.xcl"/> <xcl:append referent="{ $sys:env }"> <xcl:item name="n" value="{ value( $exp:params/@variant ) }"/> </xcl:append> <exp:invoke processor="{ $validation }"/> <!--check the result--> <xcl:parse source="result/active-schema-vote-count-{ value( $exp:params/@variant ) }.txt"
name="oe"/> <xcl:parse source="{ $sys:OUT }" name="result"/> <xunit:assert-string-equals result="{ string( $result ) }" expected="{ string( $oe ) }"/> </xunit:test-case> </exp:element> <exp:element name="test:weather-report"> <xunit:test-case name="report/weather-report-{ value( $exp:params/@variant ) }"
label="Playing with datatypes and PSVI - variant { value( $exp:params/@variant ) }"> <exp:unmarshal name="weather-report"
source="../../../tutorial/schema/weather-report/weather-report.xcl"/> <xcl:append referent="{ $sys:env }"> <xcl:item name="n" value="{ value( $exp:params/@variant ) }"/> </xcl:append> <exp:invoke processor="{ $weather-report }"/> <!--check the result--> <xcl:parse source="result/weather-report.txt" name="oe"/> <xcl:parse source="{ $sys:OUT }" name="result"/> <xunit:assert-node-equals result="{ $result }" expected="{ $oe }"/> </xunit:test-case> </exp:element> <exp:element name="test:big"> <xunit:test-case name="report/big"
label="Splitting a SAX source to multiple XML chunks thanks to XPath-based filters"> <exp:unmarshal name="big" source="../../../tutorial/pipeline/big/big.xcl"/> <xcl:append referent="{ $sys:env }"> <xcl:item name="file" value="Bibliotheque32Kilos.xml"/> </xcl:append> <exp:invoke processor="{ $big }"/> <!--check the result--> <xcl:set name="files"
value="{ io:file('../../../tutorial/pipeline/big/split/')//*[@io:is-file][@io:extension='xml'] }"/> <xunit:assert-number-equals result="{ count( $files ) }" expected="33"/> <xcl:for-each name="file" select="{ $files }"> <xcl:parse name="output" source="{ $file }"/> <!--check that they are not empty--> <xunit:assert-true result="{ $output/dict }"/> </xcl:for-each> </xunit:test-case> </exp:element> <exp:element name="test:poem"> <xunit:test-case name="report/poem" label="Text to XML"> <exp:unmarshal name="poem" source="../../../tutorial/pipeline/poem/poem.xcl"/> <exp:invoke processor="{ $poem }"/> <!--check the result--> <xcl:parse source="result/poem.xml" name="oe"/> <xcl:parse source="../../../tutorial/pipeline/poem/poem.xml" name="result"/> <xunit:assert-node-equals result="{ $result }" expected="{ $oe }"/> </xunit:test-case> </exp:element> <exp:element name="test:mime"> <xunit:test-case name="report/mime"
label="Parsing a multipart SOAP message with a regular expression"> <exp:unmarshal name="mime" source="../../../tutorial/pipeline/mime/mime.xcl"/> <exp:invoke processor="{ $mime }"/> <!--check the results--> <xcl:parse source="result/soap-part-0.xml" name="oe"/> <xcl:parse source="../../../tutorial/pipeline/mime/soap-part-0.xml" name="result"/> <xunit:assert-node-equals result="{ $oe }" expected="{ $result }"/> <xcl:parse source="result/soap-part-1.xml" name="oe"/> <xcl:parse source="../../../tutorial/pipeline/mime/soap-part-1.xml" name="result"/> <xunit:assert-node-equals result="{ $oe }" expected="{ $result }"/> </xunit:test-case> </exp:element> <exp:element name="test:xunit"> <xunit:test-case name="report/xunit" label="XUnit step by step"> <exp:unmarshal name="xunit" source="../../../tutorial/xunit/run-tests.xcl"> <!--must have absolute URL here (see in the troubleshooting section : "The engine fails to resolve a relative URL")--> <xcl:param name="use-catalog"
value="{ io:file( '../../../tutorial/xunit/use-cases.cat' ) }"/> <xcl:param name="use-catalog"
value="{ io:file( '../../../tutorial/xunit/po-catalog.cat' ) }"/> </exp:unmarshal> <exp:invoke processor="{ $xunit }"/> <!--check the results--> <xcl:parse source="result/xunit-report-ok.xml" name="oe"/> <xcl:parse source="../../../tutorial/xunit/report-ok-err.xml" name="result"/> <xunit:assert-node-equals result="{ $oe/* }" expected="{ $result/* }"/> <xcl:parse source="result/xunit-report-bad-attributes.xml" name="oe"/> <xcl:parse source="../../../tutorial/xunit/report-bad-attributes-err.xml" name="result"/> <xunit:assert-node-equals result="{ $oe/* }" expected="{ $result/* }"/> <xcl:parse source="result/xunit-report-bad-element-name.xml" name="oe"/> <xcl:parse source="../../../tutorial/xunit/report-bad-element-name-err.xml" name="result"/> <xunit:assert-node-equals result="{ $oe/* }" expected="{ $result/* }"/> </xunit:test-case> </exp:element> <exp:element name="test:all"> <!--Web tutorials--> <test:wgallery/> <test:wxslt/> <test:whello/> <!--Web/SQL tutorials--> <test:wsql/> <!--xunit tutorial--> <test:xunit/> <!--basic tutorials--> <test:xslt/> <test:hello/> <test:hello-template/> <!--schema tutorials--> <test:active-schema-co-oc/> <test:active-schema-classification/> <test:active-schema-vote-count variant="100"/> <test:active-schema-vote-count variant="105"/> <test:active-schema-vote-count variant="95"/> <test:weather-report variant="1"/> <test:weather-report variant="2"/> <test:weather-report variant="3"/> <test:weather-report variant="4"/> <!--filter tutorials--> <test:mime/> <test:poem/> <test:big/> <xunit:merge-reports name="Summary of tutorial tests" source="{ io:file( 'report/' ) }"
output="{ io:file( 'tutorial-err.xml' ) }"/> </exp:element> </exp:module>