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

jadex.bdi.testcases.events.MessageReceiverPlan Maven / Gradle / Ivy

Go to download

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

The newest version!
package jadex.bdi.testcases.events;

import jadex.base.test.TestReport;
import jadex.bdi.runtime.IMessageEvent;
import jadex.bdi.runtime.Plan;
import jadex.bdi.runtime.TimeoutException;
import jadex.bridge.fipa.SFipa;
import jadex.commons.SUtil;

/**
 *  Receives messages sent by initial event test.
 */
public class MessageReceiverPlan extends Plan
{
	public void body()
	{
		TestReport tr = new TestReport("receive_message", "Receive initial message event", true, null);
		try
		{
			IMessageEvent	me	= waitForMessageEvent("just_born_receive", 3000);
			if(!"initial value".equals(me.getParameter(SFipa.CONTENT).getValue()))
			{
				tr.setReason("Wrong content: "+me.getParameter(SFipa.CONTENT).getValue());
			}
			else if(!getWaitqueue().isEmpty())
			{
				tr.setReason("Received too much events: "+SUtil.arrayToString(getWaitqueue().getElements()));
			}
		}
		catch(TimeoutException e)
		{
			tr.setReason("No message received.");
		}
		getBeliefbase().getBeliefSet("testcap.reports").addFact(tr);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy