wait-for-update-001
Tests that cx:wait-for-update works. It relies on the fact that calling
the time-of-day service only updates every 10 seconds, so it’s highly likely
to have to wait a bit.
Test is expected to pass.
The pipeline
<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:t="http://xproc.org/ns/testsuite/3.0" name="main" version="3.0">
<p:import href="https://xmlcalabash.com/ext/library/wait-for-update.xpl"/>
<p:import href="https://xmlcalabash.com/ext/library/pipeline-messages.xpl"/>
<p:output port="result" sequence="true"/>
<p:option name="WHOST"
select="'http://localhost:8246'" static="true"/>
<cx:wait-for-update name="wait"
href="{$WHOST}/service/time-of-day"/>
<cx:pipeline-messages p:depends="wait" level="debug"/>
</p:declare-step>
Result
<cx:messages xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<cx:message date="2025-06-19T18:02:48X"
level="DEBUG"
message="Waiting for http://apache2/service/time-of-day to update..."/>
</cx:messages>
Schematron checks
<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
<s:ns prefix="cx"
uri="http://xmlcalabash.com/ns/extensions"/>
<s:pattern>
<s:rule context="/">
<s:assert test="cx:messages">The root is wrong.</s:assert>
<s:assert test="exists(cx:messages/cx:message [@level = 'DEBUG' and starts-with(@message, 'Waiting for http:')])">Did not find waiting message.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 23 May 2025, Norm Tovey-Walsh
- Added static options for web server host and port.
- 05 May 2025, Norm Tovey-Walsh
- Created test.