|
Rule Designer API | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
---|---|
IlrSSPClient | Used to invoke a remote SSP server using HTTP. |
IlrSSPServiceFactory | Factory that creates instances of an SSP service. |
Provides the entry point for running test suites and simulations.
You can use the DVS API to connect your application to an SSP server to launch the execution of your scenario suite and retrieve an execution report.
The main steps are:
More explanations including code examples are provided in the sections below.
To prepare the input data:
The following code shows how to do this:
// Define the scenario suite format to use IlrScenarioFormatDescriptor formatDescriptor = IlrScenarioFormatDescriptorFactory.getInstance().createScenarioFormatDescriptor(); formatDescriptor.setScenarioFormatName("my excel format"); formatDescriptor.setScenarioProviderClassName("ilog.rules.dvs.core.scenarioproviders.IlrExcel2003ScenarioProvider"); IlrComparisonPrecisionDescriptor comparisonPrecision = new IlrComparisonPrecisionDescriptor(); comparisonPrecision.setDecimalPrecision(2); // To compare numbers up to two digits to the right of the decimal point formatDescriptor.setComparisonPrecisionDescriptor(comparisonPrecision); // Create a scenario suite descriptor IlrScenarioSuiteDescriptor scenarioSuiteDescriptor = new IlrScenarioSuiteDescriptorFactory().createScenarioSuiteDescriptor(formatDescriptor); // Load the ruleset to test and store it in the scenario suite descriptor InputStream miniloanInputStream = SynchronousRunner.class.getResourceAsStream("/loanvalidation-rules.jar"); IlrRulesetArchive rulesetToTest = IlrRulesetArchive.extractArchive(new IlrJarArchiveLoader(new JarInputStream(miniloanInputStream))); scenarioSuiteDescriptor.setProductionRulesetArchive(rulesetToTest); // The RES server to use to run the tests scenarioSuiteDescriptor.setResURL(new URL("http://localhost:9080/res")); scenarioSuiteDescriptor.setResUser("resAdmin"); scenarioSuiteDescriptor.setResPassword("resAdmin"); // Add the scenario data to the scenario suite descriptor. // The excel scenario provider expects the excel file as a byte array, in a property named excel2003BinaryData ByteArrayOutputStream os = new ByteArrayOutputStream(); InputStream inputStream = null; try { inputStream = SynchronousRunner.class.getClassLoader().getResourceAsStream("loanvalidation-scenarios.xls"); byte[] buffer = new byte[4096]; int readen = 0; while ((readen = inputStream.read(buffer)) > 0) { os.write(buffer, 0, readen); } } finally { if (inputStream != null) { inputStream.close(); } } byte[] scenarioData = os.toByteArray(); scenarioSuiteDescriptor.add("excel2003BinaryData", scenarioData);
The following code shows how to connect to the SSP running on localhost, port 9080:
ssp = IlrSSPServiceFactory.getInstance().createHTTPClient(new URL("http://localhost:9080/testing"), "resAdmin", "resAdmin");
Running the scenario suite can by done synchronously ou asynchronously. The following example shows an asynchronous run:
// Start the execution of the scenario suite on the remote server String jobID = ssp.createJob(scenarioSuiteDescriptor); IlrSSPJobResult jobResult = null; boolean jobHasNotYetCompleted = true; System.out.print("Waiting for job completion"); while (jobHasNotYetCompleted) { try { jobResult = ssp.getJobResult(jobID); jobHasNotYetCompleted = false; System.out.println("\nJob has completed"); } catch (IlrRunnerException e) { // The job has not yet completed System.out.print("."); Thread.sleep(20); } } IlrScenarioSuiteTestResult globalResult = jobResult.getResult();
The following code shows how to run the scenario suite synchronously:
IlrScenarioSuiteTestResult globalResult = ssp.run(scenarioSuiteDescriptor);
The following example shows how to display the test result on system out:
ListscenarioResults = globalResult.getScenarioTestResults(); for (IlrScenarioTestResult scenarioResult: scenarioResults) { System.out.println(scenarioResult.getName() + ": " + scenarioResult.getStatus()); List testResults = scenarioResult.getTestResults(); for (IlrTestResult testResult: testResults) { System.out.println("\t" + testResult.getName() + ": " + testResult.getStatus() + " (" + testResult.getMessage() + ")"); } }
|
Rule Designer API | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |