我正在尝试为规则设计器创建自定义场景提供程序,并创建了一个插件来通过运行配置执行它。我能够创建插件并运行 DVS Runner;但是,我在 IlrDVSRunner 收到 NullPointerException。我无法通过各种方式解决异常。任何帮助将不胜感激。
MotorScenarioProvider.java
public class MotorScenarioProvider implements IlrScenarioProvider, Serializable {
private static final long serialVersionUID = 20150702L;
public MotorScenarioProvider() {
super();
System.out.println("MotorScenarioProvider - Constructor");
}
public void initialize(IlrScenarioSuiteExecutionContext context)
throws IlrInitializationException {
System.out.println("MotorScenarioProvider - Initialize");
}
public int getScenarioCount() throws IlrScenarioProviderException {
System.out.println("MotorScenarioProvider - getScenarioCount");
return 1;
}
public IlrScenario getScenarioAt(int indx)
throws IlrScenarioProviderException {
System.out.println("MotorScenarioProvider - getScenarioAt");
IlrScenarioImpl scenario = new IlrScenarioImpl();
Map<String, Object> inputParameters = new HashMap<String, Object>();
//Setting Blank Scenario for testing purpose
scenario.setName("Scenario 1");
inputParameters.put("req", new Object());
inputParameters.put("req", new Object());
scenario.setInputParameters(inputParameters);
return scenario;
}
MotorScenarioProviderRunner.java
public class MotorScenarioProviderRunner extends IlrDVSRunner {
/**
* Create a DVS scenario suite descriptor
*
* @return The scenario suite descriptor
*/
public IlrScenarioSuiteDescriptor createScenarioSuiteDescriptor() {
IlrScenarioSuiteDescriptorFactory scenarioSuiteDescriptorFactory = new IlrScenarioSuiteDescriptorFactory();
IlrScenarioFormatDescriptor formatDescriptor = IlrScenarioFormatDescriptorFactory
.getInstance().createScenarioFormatDescriptor();
formatDescriptor
.setScenarioProviderClassName(MotorScenarioProvider.class.getName());
IlrScenarioSuiteDescriptor suiteDescriptor = scenarioSuiteDescriptorFactory
.createScenarioSuiteDescriptor(formatDescriptor);
suiteDescriptor.setKPIEnabled(false);
suiteDescriptor.setTestEnabled(true);
suiteDescriptor.setProductionRulesetArchive(new IlrRulesetArchive());
System.out.println("MotorScenarioProviderRunner: createScenarioSuiteDescriptor");
suiteDescriptor.add("SCENARIO_NAME", "Scenario 1");
return suiteDescriptor;
}
/**
* The main method run from the {@link IlrDVSLaunchConfigurationDelegate}
* launch method.
*
* @param args
* The args needed to run the scenarios and build the scenario
* suite descriptor.
*/
public static void main(String[] args) {
MotorScenarioProviderRunner runner = new MotorScenarioProviderRunner();
String[] data = runner.extractCustomArgs(args);
// TODO read the custom parameters from the 'data' attribute and not
// from the 'args' attribute
System.out.println("MotorScenarioProviderRunner: main");
try {
IlrScenarioSuiteDescriptor scenarioSuite = runner
.createScenarioSuiteDescriptor();
if(scenarioSuite == null)
System.out.println("scenarioSuite is NULL");
if(args == null)
System.out.println("args is NULL");
runner.run(args, scenarioSuite); **//EXCEPTION OCCURS HERE**
} catch (IOException e) {
e.printStackTrace();
}
} }