I was wondering if anyone out there has developed methods for unit testing pipelines.
Bill,
You could use the ProcessorTest class, which is not bundled in OXF but that I will send to you in a private email. This class implements a JUnit TestCase. So you can run it as you would run any JUnit test, with the text test runner or with the Swing test runner.
When started, the test will read an XML file that describes the tests to run. The format is pretty simple: for each test you list the processor to run (its URI), the inputs of the processor, and the expected output. ProcessorTest will compare the actual output with the expected output and the test fails if there is a mismatch.
When running the JUnit test runner, you have to set a few properties. See below a fragment of Ant build.xml that runs JUnit's TestRunner with the appropriate parameters (see running.xml). Also attached, see an example of what you can put in the tests.xml, with here two tests: the first is trivial and uses just the Identity processor; the second test imbricated <p:for-each>.
Alex
<java classname="junit.textui.TestRunner" fork="yes" jvm="C:\Program Files\jdk1.4\bin\java.exe">
<sysproperty key="oxf.resources.factory" value="org.orbeon.oxf.resources.PriorityResourceManagerFactory"/>
<sysproperty key="oxf.resources.flatfile.rootdir" value="test/resources"/>
<sysproperty key="oxf.resources.priority.1" value="org.orbeon.oxf.resources.FlatFileResourceManagerFactory"/>
<sysproperty key="oxf.resources.priority.2" value="org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory"/>
<sysproperty key="oxf.test.config" value="tests.xml"/>
<arg line="-class org.orbeon.oxf.test.ProcessorTest"/>
<classpath>...</classpath>
</java>
<tests xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xforms="http://www.w3.org/2002/01/xforms" xmlns:xalan="http://xml.apache.org/xalan" xmlns:delegation="http://orbeon.org/oxf/xml/delegation" xmlns:d="http://orbeon.org/oxf/xml/document" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xu="http://www.xmldb.org/xupdate">
<test description="Identity" uri="oxf/processor/identity">
<input name="data"><root><a/><b/></root></input>
<output name="data"><root><a/><b/></root></output>
</test>
<test description="XPL: for-each" uri="oxf/processor/pipeline">
<input name="data">
<x:company xmlns:x="http://localhost/company">
<x:department>
<x:employee firstname="John"/>
<x:employee firstname="Peter"/>
</x:department>
<x:department>
<x:employee firstname="Carl"/>
</x:department>
</x:company>
</input>
<input name="config">
<p:config xmlns:y="http://localhost/company">
<p:param type="input" name="data"/>
<p:param type="output" name="data"/>
<p:for-each href="#data" select="/y:company/y:department" root="emps" ref="data">
<p:for-each href="current()" select="/y:department/y:employee" root="emps" id="emps">
<p:processor uri="oxf/processor/identity">
<p:input name="data" href="current()"/>
<p:output name="data" ref="emps"/>
</p:processor>
</p:for-each>
<p:processor uri="oxf/processor/identity">
<p:input name="data" href="#emps#xpointer(/emps/*)"/>
<p:output name="data" ref="data"/>
</p:processor>
</p:for-each>
</p:config>
</input>
<output name="data">
<emps>
<x:employee xmlns:x="http://localhost/company" firstname="John"/>
<x:employee xmlns:x="http://localhost/company" firstname="Peter"/>
<x:employee xmlns:x="http://localhost/company" firstname="Carl"/>
</emps>
</output>
</test>
</tests>
_______________________________________________ oxf-users mailing list [EMAIL PROTECTED] http://mail.orbeon.com/mailman/listinfo/oxf-users
