| ILOG JRules User Guide > Testing Rules with Rule Scenario Manager > Tasks > Executing Scenarios, Scenario Suites, Simulations, and RSM Archives > RSM Archives Execution with Ant Commands |
RSM Archives Execution with Ant Commands |
PREVIOUS NEXT |
If you want to execute an RSM archive in a command line, you first have to write the corresponding JUnit tests (http://junit.sourceforge.net) and run it with a JUnit runner (textUI, SwingUI ...).
To do that, write a suite() method to create a suite containing all of your test methods:
package mypackage;
import java.io.File;
import java.io.FileInputStream;
import java.util.zip.ZipInputStream;
// jrules-rsm-core.jar
import ilog.rules.ras.core.archive.IlrRSMArchiveLoader;
// jrules-rsm-common.jar
import ilog.rules.ras.tools.IlrResourceLocator;
import ilog.rules.ras.tools.resource.IlrReadableZipResource;
// junit.jar
import junit.framework.Test;
public class MyRSMArchiveJUnit {
public static Test suite() throws Exception {
// Use the RSM Archive loader tool class to read the archive
String path = IlrResourceLocator.locate("pathTo/RSMArchiveFile.zip");
File file = new File(path);
ZipInputStream zis = new ZipInputStream(new FileInputStream(file));
Object readRsmObject = new IlrRSMArchiveLoader().load(new
IlrReadableZipResource(zis));
// Return the element that extends the JUnit TestSuite class
return (Test)readRsmObject;
}
}
Then, write the correct Ant task to run the JUnit class written previously, as described in Ant Commands for Scenario Execution.
An example of an Ant execution is the following:
<!-- =================================================================== -->
<!-- Run in text mode -->
<!-- =================================================================== -->
<target name="run.text" description="Run the unit tests in text mode">
<java classname="junit.textui.TestRunner">
<arg line=" mypackage.MyRSMArchiveJUnit"/>
<classpath refid="jrules.classpath" />
<classpath path="${basedir}/bin/." />
<classpath>
<pathelement location="${basedir}/lib/xom.jar"/>
</classpath>
<!-- Localization of scenarios files -->
<classpath path="${basedir}/data/scenario/." />
<classpath path="${basedir}/data/scenario/reports/excel/." />
<!-- Localization of the configuration and template files -->
<classpath path="${basedir}/config/." />
<classpath path="${basedir}/templates/." />
</java>
</target>
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |