All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bdi.testcases.planlib.RPTestPlan Maven / Gradle / Ivy

Go to download

The Jadex BDI applications package contain several example applications, benchmarks and testcases using BDI agents.

There is a newer version: 2.4
Show newest version
package jadex.bdi.testcases.planlib;

import jadex.base.test.TestReport;
import jadex.bdi.runtime.GoalFailureException;
import jadex.bdi.runtime.IGoal;
import jadex.bdi.testcases.AbstractMultipleAgentsPlan;

import java.util.List;
import java.util.Map;

/**
 *  Test the request protocol execution.
 */
public class RPTestPlan extends AbstractMultipleAgentsPlan
{
	/**
	 *  The plan body.
	 */
	public void body()
	{
		// Create 1 participants
		Map[] args = new Map[1];
		List agents = createAgents("/jadex/bdi/testcases/planlib/RPReceiver.agent.xml", args);	

		TestReport tr = new TestReport("#1", "Test request protocol.");
		if(assureTest(tr))
		{
			try
			{
				IGoal request = createGoal("procap.rp_initiate");
				request.getParameter("action").setValue("Request a task.");
				request.getParameter("receiver").setValue(agents.get(0));
				dispatchSubgoalAndWait(request);
				getLogger().info("Request result:"+request.getParameter("result").getValue());
				tr.setSucceeded(true);
			}
			catch(GoalFailureException e)
			{
				tr.setFailed("Exception occurred: "+e);
			}
		}
		getBeliefbase().getBeliefSet("testcap.reports").addFact(tr);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy