Testing ruleset execution

You can test the execution of a particular ruleset through a testing interface.

Before you begin

To test rulesets with a managed Java™ XOM, you prepare for the test in one of the following ways:
  • Construct the Java input parameters by using the options provided in the interface.
  • Temporarily set the ruleset.managedxom.uris ruleset property to the location of the Java XOM .jar files.
    Tip:

    When you add this property to a ruleset, all execution requests use this same property value. In a production environment, this is unlikely to be the intended behavior.

About this task

The Rule Execution Server console provides a web testing interface for you to enter ruleset parameter values and call a deployed ruleset.

Restriction:
  1. The web testing interface is not a programmatic interface and is not designed for automated execution.
  2. On zRule Execution Server for z/OS®, you cannot test a ruleset from its Ruleset View: the Test Ruleset button is not available in the menu bar.
  3. You can use the testing feature only when the console is deployed in a Java EE environment where an execution unit (XU) is reachable through a JNDI lookup. You can verify that your deployment conforms to this configuration by checking that the result of the Local XU connectivity test is green. For more information, see Monitoring and managing the server.
  4. You cannot use the Test Ruleset feature for rulesets that are built with an incompatible engine version. In case of incompatibility, the Ruleset View provides more information.

Procedure

  1. In the Navigator panel, browse through the RuleApps tree, then click the relevant ruleset.
  2. In the Ruleset View, click Test ruleset icon. Test Ruleset.

    The Test Ruleset View shows a table that lists the input parameters for the ruleset. If dependencies exist between your ruleset parameters, you can reorder them accordingly. If your ruleset parameters are XML-based, no value is set for them. If they are based on Java, a default value is set.

  3. Select a parameter by using the check box, and then click Up to move the parameter up the table, or click Down to move it down the table.
  4. To edit the values for each of the input parameters, you can use plain text or upload a file:
    • To enter text, click the Edit mode icon next to the field and type a value for the parameter.
    • To enter data from an XML or Groovy file, click Upload file icon. Upload file, and then click Browse to select a file from the Choose File dialog.

    Here is an example for an XML parameter named customer.

    Note:
    1. The elements must be ordered as specified in the corresponding XSD schema file.
    2. Enter a valid XML string. Do not leave the XML string empty.
    <?xml version="1.0" encoding="UTF-8"?> 
    <customer xmlns:ns="http://www.ibm.com/rules/customer"> 
       <name>John Smith</name> 
       <owner>George Smith@ILOG</owner> 
       <initialValue>2000.0</initialValue> 
       <currentValue>800.0</currentValue> 
       <sectorPosition>800.0</sectorPosition> 
       <bankStockPosition>800.0</bankStockPosition> 
       <oilStockPosition>800.0</oilStockPosition> 
       <railStockPosition>800.0</railStockPosition> 
       <bondPosition>800.0</bondPosition> 
       <futurnPosition>800.0</futurnPosition> 
       <stockPosition>800.0</stockPosition>
       <currency>Euro</currency>
    </customer>
    Here is a Groovy code sample to instantiate a Java XOM parameter:
    import loan.*;
    
    Borrower borrower =
      new Borrower("John", "Smith",
      new Date(70, 1,1), "123456789"); 
  5. Click Visualization mode icon. Visualization mode to save the value.
  6. If you want to execute the ruleset by using a known rule task, select the Execute Task check box and enter the name of the task in the text box.
  7. Click Execute.

Results

The Test Ruleset View page displays the results of the call. Two boxes are displayed:
Execution result

This box provides information about ruleset execution:

Label Description
Executed canonical ruleset path The complete path for the ruleset, including its version number
Execution duration In milliseconds
Number of rules The number of rules in the ruleset
Rules fired The names of the rules that the rule engine executed
Number of tasks The number of rule flow tasks in the ruleset
Executed tasks The names of the tasks that the rule engine executed
Output Strings that are written to print.out
Warnings Any warnings that were raised during execution
Output Parameters

This box contains the values of the output parameters set on the ruleset. The values are displayed as strings. With the ruleset property ruleset.bom.enabled at true, these strings result from the BOM serialization. Otherwise, the strings are equal to the return value of the toString method.