The language for specifying tests contains the following main constructs:
The nodes in a test specification are executed sequentially as they are encountered.
Tag substitution is performed before the node is evaluated. Tag substitution refers to the substitution of ##{<value name>} with the content of the named value. The named value can come from two sources:
<message_publish name="[<name>]" channel="[<channel name>]">
<message_builder command="[java|shell]:[<command id>]" template_path="[<path to a template>]">
<param>[<command parameter 1>]</param>
<param>[<command parameter 2>]</param>
...
</message_builder>
</message_publish>
Build a message from a template and publish it to the «OutgoingOrder» channel:
<message_publish name="PublishOrder" channel="OutgoingOrder">
<message_builder command="java:org.mactor.extensions.xml.XPathTemplateMessageBuilder" template_path="templates/order.xml">
<param>Header/MessageId=##{MessageId}</param>
<param>Data/OrderId=##{OrderId}</param>
</message_builder>
</message_publish>
Similar using the template without modifications:
<message_publish name="PublishOrder" channel="OutgoingOrder">
<message_builder command="java:org.mactor.extensions.xml.XPathTemplateMessageBuilder" template_path="templates/order.xml"/>
</message_publish>
Using a system executable to build a message:
<message_publish name="PublishOrder" channel="OutgoingOrder">
<message_builder command="shell:my_message_producer.sh" />
</message_publish>
<message_subscribe name="[<name>]" channel="[<channel name>]">
<message_selector command="[java]:[<command id>]">
<param>[<command parameter 1>]</param>
<param>[<command parameter 2>]</param>
...
</message_selector>
</message_subscribe>
Subscribe to messages coming in on the «IncomingOrderStatus» channel. Only messages acceptet by the message_selector command is passed on:
<message_subscribe name="OrderStatus" channel="IncomingOrderStatus">
<message_selector command="java:org.mactor.extensions.xml.BasicMessageSelector">
<param>Header/CorrelationId=##{MessageId}</param>
</message_selector>
</message_subscribe>
<message_receive name="[<name>]"
message_subscribe_node_name="[<name if the subscribe node>]"
max_message_count="[<count>]"
min_message_count="[<count>]"
max_timeout_seconds="[<seconds>]"
block_until_timeout="true|false"/>
Receive exactly one message using a previously defined message subscribe node named «SubscribeForOrderStatus»:
<message_receive name="ReceiveOrderStatus" message_subscribe_node_name="SubscribeForOrderStatus"
max_message_count="1" min_message_count="1" max_timeout_seconds="600" block_until_timeout="false"/>
Receive 10 messages, perform an action (described later) and send a response message (also described later) for each for the received messages :
<message_receive name="ReceiveOrder" message_subscribe_node_name="SubscribeForOrder"
max_message_count="10" min_message_count="10" max_timeout_seconds="600" block_until_timeout="false">
<action name="ValidateOrder" command="java:org.mactor.extensions.xml.XPathIgnoreNsValidator">
<param>//StatsId==1</param>
<param>//ProductId==##{ExpectedProductId}</param>
</action>
<message_respond name="SendOrderResponse" >
<message_builder command="java:org.mactor.extensions.xml.XPathTemplateMessageBuilder" template_path="templates/order_soap_reponse_envelope.xml">
<param>Data/OrderId=##{OrderId}</param>
</message_builder>
</message_publish>
</message_receive>
A message_respond node enables the sending of a synchronous response to a received message. A message_respond node can only be used within a message_receive node. The message_respond node must typically be used while dealing with synchronous message transfer protocols (i.e. such as SOAP)
<message_respond name="[<name>]" >
<message_builder command="[java|shell]:[<command id>]" template_path="[<path to a template>]">
<param>[<command parameter 1>]</param>
<param>[<command parameter 2>]</param>
...
</message_builder>
</message_respond>
Build a message from a template and publish it to the «OutgoingOrder» channel:
<message_respond name="SendOrderResponse" >
<message_builder command="java:org.mactor.extensions.xml.XPathTemplateMessageBuilder" template_path="templates/order_soap_reponse_envelope.xml">
<param>Data/OrderId=##{OrderId}</param>
</message_builder>
</message_publish>
<action name="[<name>]" command="[java|shell|sql]:[<command id>]">
<param>[<command parameter 1>]</param>
<param>[<command parameter 2>]</param>
...
</action>
Assert that the parameter is not null (if the value named «OrderId» is null, the command will throw an exeption and the test will fail):
<action name="ValidateOrderExist" command="java:org.mactor.extensions.AssertNotNullValidator">
<param>##{OrderId}</param>
</action>
Assert that the internet connection is up (ping will give an exit value other than 0 if the destination cannot be reached and the test will fail):
<action name="CheckInternetConnection" command="shell:ping -n 1 -w 200 vg.no"/>
Run a sql expression:
<action name="DeleteOrder" command="sql:order_db:delete order where id=##{OrderId}"/>
Assuming that the global config file contains definition of order_db. I.e:
<global_config xmlns="http://schemas.mactor.org/framework" max_test_threads="15">
<group name="order_db">
<value name="driver">oracle.jdbc.driver.OracleDriver</value>
<value name="url">jdbc:oracle:thin:@12.12.12.12:2121</value>
<value name="username">lars</value>
<value name="password">abc</value>
</group>
</global_config>
Run a sql expression:
<action name="InitDb" command="sql:order_db:init_db.sql"/>
<value name="[<name>]" command="[java|shell|sql]:[<command id>]">
<param>[<command parameter 1>]</param>
<param>[<command parameter 2>]</param>
...
</value>
Initialize the varible named «CurrentTime» with the current time:
<value name="CurrentTime" command="java:org.mactor.extensions.CurrentTimeExtractor"/>
Initialize the varible named «MessageId1» with the next value in the sequence named «msgid» (starting at 200):
<value name="MessageId1" command="sequence:msgid">
<param>200</param>
</value>
Initialize the varible named «MessageId2» with the next value in the sequence named «msgid»:
<value name="MessageId2" command="sequence:msgid"/>
Initialize the varible named «DbOrderStatus» with the result of the database query:
<value name="DbOrderStatus" command="sql:order_db:=select status from order where id='##{OrderId}'"/>
Assuming that a config group named «order_db» is defined in the global config file, and that the «OrderId» value is defined
Initialize the variable named «OrderId» with field from the last received message:
<value name="OrderId" command="java:org.mactor.extensions.xml.XPathIgnoreNsValueExtractor">
<param>//OrderId</param>
</value>
Assuming that the last received message contains an element matching the //OrderId XPath
<loop name="[<name>]" count="[<the number for times to loop>]">
...
</loop>
Publish 100 orders:
<loop name="MainLoop" count="100">
<message_publish name="PublishOrderStatus" channel="OutgoingOrderStatus">
<message_builder command="java:org.mactor.extensions.xml.XPathTemplateMessageBuilder" template_path="templates/order_status.xml"/>
</message_publish>
</loop>
Receive 1000 orders, and publish an OrderStatus for each of the:
<message_subscribe name="SubscribeForOrder" channel="IncomingOrder">
<message_selector command="java:org.mactor.extensions.xml.XPathIgnoreNsMessageSelector"></message_selector>
</message_subscribe>
<loop name="MainLoop" count="10000">
<message_receive name="ReceiveOrder" message_subscribe_node_name="SubscribeForOrder" max_message_count="1" min_message_count="1" max_timeout_seconds="10000" block_until_timeout="true"></message_receive>
<value name="MessageId" command="sequence:msgid">
<param>999000</param>
</value>
<value name="CorrelationId" command="java:org.mactor.extensions.xml.XPathIgnoreNsValueExtractor">
<param>//Header/MessageId</param>
</value>
<message_publish name="PublishOrderStatus" channel="OutgoingOrderStatus">
<message_builder command="java:org.mactor.extensions.xml.XPathTemplateMessageBuilder" template_path="templates/order_status.xml">
<param>//Header/MessageId==##{MessageId}</param>
<param>//Header/CorrelationId==##{CorrelationId}</param>
<param>//Status==0</param>
</message_builder>
</message_publish>
</loop>