| Samples > Rule Scenario Manager Demonstration > How to Test Rules in Rule Scenario Manager Using Java Binding |
How to Test Rules in Rule Scenario Manager Using Java Binding |
PREVIOUS NEXT |
This sample shows how to test rules in Rule Scenario Manager using Java data binding.
A scenario is a defined collection of components including the path to a deployed ruleset, input data, and performance tests, which is executed as a test case on a set of business rules. See Scenarios for a more detailed description.
Scenarios can be grouped together into scenario suites, which are lists of scenarios with a KPI that is calculated over the scenario results. See Scenario Suites for a more detailed description.
A simulation is a list of scenario suites together with a KPI, which provides global feedback on the executed scenarios. See Simulations for a more detailed description.
Scenario, scenario suite and simulation executions produce reports in different formats that you can view and store.
Note that most Rule Scenario Manager artifacts can be generated using a wizard. For more details, see Defining Rule Scenario Manager Artifacts.
Key features include:
To install the sample:
scenariomanager > basics-javabinding sample.
deploy.ruleapp command to deploy the loanvalidationruleapp Replay used in this sample to the Rule Execution Server.
Deploy succeeded.
build command to compile the source code.
deploy command to package the XOM JAR file into the SSP WAR file and deploy the new SSP.
This sample can only be opened and run in the Samples Console.
When executing a simple scenario, you can view the results in XML and HTML format.
To run a simple scenario:
run.scenario target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/xml.
loanValidationReport0.xml file with any text editor.
<InstallDir>/doc/schemas/rsmExecutiontrace.xsd
run.report target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/junit.
index.html file in your browser.
MyScenarioJUnit link in the left pane. The results of the execution are displayed in the right pane:
This sample provides a number of scenario suites for you to run. When executing a simple scenario suite, you can view the results in Excel and HTML format. When executing a scenario suite with generated scenarios, or a custom scenario suite, you can view them in XML and HTML format.
To run a simple scenario suite:
run.scenariosuite target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/excel.
loanValidationSuiteReport1.xls Excel file. This report file contains all data related to the execution:
run.report target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/junit.
index.html file in your browser.
MyScenarioSuiteJUnit link in the left pane. The results of the execution are displayed in the right pane.
To run a scenario suite with generated scenarios:
run.scenariosuitetemplate target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/template/reports.
LoanValidationSuiteXMLReport.xml file is the report for the scenario suite execution. The other files correspond to each scenario generated.
run.report target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/junit.
index.html file in your browser.
MyScenarioSuiteTemplateJUnit link in the left pane. The results of the execution are displayed in the right pane.
To run a custom scenario suite:
run.customsuite target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/excel.
resultReport.xls and resultReport.xml. These are both reports for the scenario suite executed, but in a different formats.
run.report target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/junit.
index.html file in your browser.
MyCustomSuiteJUnit link in the left pane. The results of the execution are displayed in the right pane.
When executing a simulation, you can view the results in Excel, XML and HTML format.
To run a simulation:
run.simulation target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/excel and open the fileloanValidationSuiteReport1.xls.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/xml. You will find the following files:
run.report target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/junit.
index.html file in your browser.
MySimulationJUnit link in the left pane.
To run scenarios from an RSM archive:
run.archive target.| Note |
The run.archive target fails if Excel is still open on the previous resulting files. All files previously loaded in Excel should be closed before running the target.
|
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/excel. You will find a file named loanValidationSuiteReport1.xls. This is a report on the archive execution.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/xml. You will find four files:
run.report target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/reports/junit.
index.html file in your browser.
MyArchiveJUnit link in the left pane. The results of the execution are displayed in the right pane.
To run a simulation with the JUnit User Interface (TestRunner):
run.uimode target. A JUnit window is displayed.| Note |
The run.uimode target fails if Excel is still open on the previous resulting files. All files previously loaded in Excel should be closed before running the target.
|
This sample helps you to generate the input data files from your Java object.
To generate the input files:
run.inoutparameters target.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/inputs/excel. An input Excel file has been generated.
<InstallDir>/scenariomanager/samples/basics-javabinding/data/scenario/inputs/xml. An input XML file has been generated.
This sample is located in <InstallDir>/scenariomanager/samples/basics-javabinding.Only the files used in the samples are listed here.
myPackage.MyScenarioJUnit.java - to run a simple scenario
myPackage/MyScenarioSuiteJUnit.java - to launch a simple suite
myPackage/MyScenarioSuiteTemplateJUnit.java - to launch a scenario suite with generated scenarios
myPackage/MyCustomSuiteJUnit.java and myPackage/userDefined/CustomSuiteExcelBinding.java - to launch a custom scenario suite
myPackage/MySimulationJUnit.java - to run a simulation
myPackage/MyArchiveJUnit.java - to run scenarios from an RSM archive
myPackage/MySimulationJUnit.java - to run a simulation with the JUnit User Interface (TestRunner)
myPackage/MyInOutParametersJUnit.java - to generate Rule Scenario Manager input data files (XML or Excel) from Java objects
Highlights for this sample are described in the following sections.
As the rules are executed against a Java XOM (loanvalidation-xom.jar), the XOM needs to be deployed within the web-inf\lib directory of the SSP WAR file. You can see how this is done by looking at the deploy target in the build.xml file.
Environment configuration data, which can be applied to scenarios, scenario suites, and simulations, are contained in XML files. See Configurations for an explanation of how scenarios are controlled by their configuration.
You use this XML data configuration to define the following:
In this sample, the configuration is specified by the loanValidationConfigurationXML.xml file or the loanValidationConfigurationExcel.xml file. These files specify the properties required to execute the scenarios, such as the executor class and the input and output databinding classes.
Note that all requests for executions are sent to a remote Scenario Service Provider through the IlrHTTPExecutorImpl executor. This class allows you to execute rulesets remotely using the HTTP protocol.
The configuration also defines the method by which the input data is read. To read XML data, the configuration specifies IlrXMLInOutParametersImpl as the input binding class. To read Excel data, the configuration specifies IlrExcelInOutParametersImpl as the input binding class.
The Rule Scenario Manager testing artifacts, scenarios, suites and simulations, are defined in XML files.
You use this XML file to define scenarios using the following data:
Input data is the source data on which a ruleset (defined by the ruleset path) is executed.
After the ruleset is executed, an execution response is generated. The response includes such information as the time taken to complete the ruleset execution, the rules fired, the tasks executed, the number of rules fired, the number of tasks executed, and so on. You can use filters to determine how much information you retrieve from the ruleset execution; see Filters for further information.
A scenario report represents the results of a scenario execution. It contains the name and description of the scenario, the tests that were performed over the ruleset execution results, and the test results. Output data is the data returned by the rule engine on the execution of the ruleset - the results of firing the rules.
You use this XML file to define scenario suites using the following data:
This sample uses the scenario suite KPI class myPackage.MyCoverageKpi, which calculates the rules coverage percentage (the number of rules fired over the total number of rules).
You use this XML file to define simulations using the following data:
This sample uses the simulation KPI class myPackage.MyBestCoverageKpi, which calculates the best rules coverage percentage from the member scenario suites. This class works with the myPackage.MyCoverageKpi class, which calculates the rules coverage percentage (the number of rules fired over the total number of rules).
myPackage/MyScenarioJUnit.java
loanValidationConfigurationXML.xml
loanValidationAloneXML.xml
loanValidationSuiteExcel.xml file contains the list of scenarios to execute. The scenario files use Excel input data. The following files are used in this sample:
loanValidationSuiteXML.xml file does not contain a static list of scenarios. Instead, it contains a link to a scenario template file and a link to input data files, which are used to generate the scenarios "on-the-fly". The contents of the scenario definition files are not predefined, but are built while executing the scenario suite. The template defines the file format and the input data files determine the file content. The following files are used in this sample:
CustomSuiteExcelBinding.getHardCodedConfiguration() method. The scenario suite definition (name, description, scenarios, KPI) is defined in an Excel file and is read by the CustomSuiteExcelBinding.fromBinding() method. The following files are used in this sample:
loanValidationSimulation.xml file, along with the KPI class and simulation report file. In this simulation, each scenario suite specifies its own configuration. The following files are used in this sample:
myPackage/MySimulationJUnit.java
loanValidationConfigurationXML.xml
loanValidationSimulation.xml
data/loanValidationSimulation.zip). Typically, an RSM archive contains a complete collection of simulation, scenario suite and scenario definitions together with the configurations, input data, KPIs and baseline reports needed to execute them. The following files are used in this sample:
myPackage/MyArchiveJUnit.java
myPackage/MySimulationJUnit.java
loanValidationConfigurationXML.xml
loanValidationSimulation.xml
To rebuild the sample:
build target to compile the code.
deploy target.
run target.
run.report target.
deploy.ruleapp target.
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |