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

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>

Related Concepts

RSM Archives
Scenarios
Scenario Suites
Simulations

Related Tasks

Executing a Scenario, Scenario Suite, or Simulation
Ant Commands for Scenario Execution
RSM Archive Execution from an HTTP Client

Related Reference

RSM Archive Definition

Related Samples

How to Test Rules in Rule Scenario Manager Using Java Binding
How to Test Rules in Rule Scenario Manager using XML Binding