
jadex.bdi.testcases.misc.ModelLoadingPlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bdi Show documentation
Show all versions of jadex-applications-bdi Show documentation
The Jadex BDI applications package contain
several example applications, benchmarks and
testcases using BDI agents.
The newest version!
package jadex.bdi.testcases.misc;
import jadex.base.test.TestReport;
import jadex.bdi.IDynamicBDIFactory;
import jadex.bdi.runtime.Plan;
import jadex.bridge.service.types.cms.CreationInfo;
import jadex.bridge.service.types.cms.IComponentManagementService;
import jadex.commons.Tuple2;
import jadex.commons.future.DelegationResultListener;
import jadex.commons.future.Future;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Collection;
/**
* Create and test a hello world agent.
*/
public class ModelLoadingPlan extends Plan
{
//-------- attributes --------
/** The test report. */
protected TestReport tr = new TestReport("#1", "Test external model loading.");
//-------- methods --------
/**
* Perform the test.
*/
public void body()
{
InputStream input;
try
{
input = new FileInputStream("../jadex-applications-bdi/src/main/java/jadex/bdi/examples/helloworld/HelloWorld.agent.xml");
}
catch(FileNotFoundException fnfe)
{
throw new RuntimeException(fnfe);
}
IDynamicBDIFactory fac = (IDynamicBDIFactory)getServiceContainer().getRequiredService("factory").get(this);
fac.loadAgentModel("helloworld", input, "helloagent.agent.xml", getInterpreter().getModel().getResourceIdentifier()).get(this);
IComponentManagementService cms = (IComponentManagementService)getServiceContainer().getRequiredService("cms").get(this);
Future>> finished = new Future>>();
cms.createComponent("hw1", "helloagent.agent.xml", new CreationInfo(getComponentIdentifier()), new DelegationResultListener>>(finished)).get(this);
finished.get(this);
tr.setSucceeded(true);
getBeliefbase().getBeliefSet("testcap.reports").addFact(tr);
}
/**
* Test failed.
*/
public void failed()
{
getException().printStackTrace();
tr.setFailed(""+getException());
getBeliefbase().getBeliefSet("testcap.reports").addFact(tr);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy