
jadex.bdi.testcases.misc.ConfigElementRefWorkerPlan 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.runtime.GoalFailureException;
import jadex.bdi.runtime.IMessageEvent;
import jadex.bdi.runtime.IPlan;
import jadex.bdi.runtime.Plan;
import jadex.bdi.runtime.TimeoutException;
import jadex.bridge.fipa.SFipa;
import java.util.ArrayList;
import java.util.List;
/**
* Check if the initial and end elements are correctly named.
*/
public class ConfigElementRefWorkerPlan extends Plan
{
//-------- attributes --------
/** List for test reports. */
protected List reports;
//-------- constructors --------
/**
* Create plan.
*/
public ConfigElementRefWorkerPlan()
{
this.reports = new ArrayList();
}
//-------- methods --------
/**
* Plan body.
*/
public void body()
{
// Initial goal.
TestReport report = new TestReport("initial goal", "Check if the initial goal is correctly named.");
try
{
/*IGoal goal = */waitForGoal("testgoal", 100);
// if(goal.getName().equals("namedinitialgoal"))
// {
report.setSucceeded(true);
// }
// else
// {
// report.setReason("Goal has wrong name '"+goal+"'.");
// }
}
catch(GoalFailureException e)
{
report.setSucceeded(true);
}
catch(TimeoutException e)
{
report.setReason("No goal detected.");
}
reports.add(report);
// Initial internal event.
report = new TestReport("initial internal event", "Check if the initial internal event is correctly named.");
try
{
/*IInternalEvent event = */waitForInternalEvent("testevent", 100);
// if(event.getName().equals("namedinitialevent"))
// {
report.setSucceeded(true);
// }
// else
// {
// report.setReason("Event has wrong name '"+event+"'.");
// }
}
catch(TimeoutException e)
{
report.setReason("No event detected.");
}
reports.add(report);
// Initial message event.
report = new TestReport("initial message event", "Check if the initial message event is correctly named.");
try
{
// Hack!!! getting reply to event is only way to access original name!?
/*IMessageEvent msg = */waitForMessageEvent("testmsg", 100);
// IRMessageEvent orig = ((IRMessageEvent)((MessageEventWrapper)msg).unwrap()).getInReplyMessageEvent();
// if(orig!=null && orig.getName().equals("namedinitialmsg"))
// {
report.setSucceeded(true);
// }
// else
// {
// report.setReason("Message has wrong name '"+msg+"'.");
// }
}
catch(TimeoutException e)
{
report.setReason("No message detected.");
}
reports.add(report);
// Initial goal from capability.
report = new TestReport("initial capa goal", "Check if initial goal from capability is correctly named.");
try
{
/*IGoal goal = */waitForGoal("configrefcap.testgoal", 100);
// if(goal.getName().equals("namedcapinitialgoal"))
// {
report.setSucceeded(true);
// }
// else
// {
// report.setReason("Goal has wrong name '"+goal+"'.");
// }
}
catch(GoalFailureException e)
{
report.setSucceeded(true);
}
catch(TimeoutException e)
{
report.setReason("No goal detected.");
}
reports.add(report);
// Initial internal event from capability.
report = new TestReport("initial capa internal event", "Check if initial internal event from capability is correctly named.");
try
{
/*IInternalEvent event = */waitForInternalEvent("configrefcap.testevent", 100);
// if(event.getName().equals("namedcapinitialevent"))
// {
report.setSucceeded(true);
// }
// else
// {
// report.setReason("Event has wrong name '"+event+"'.");
// }
}
catch(TimeoutException e)
{
report.setReason("No event detected.");
}
reports.add(report);
// Initial message event from capability.
report = new TestReport("initial message event", "Check if initial message event from capability is correctly named.");
try
{
/*IMessageEvent msg =*/ waitForMessageEvent("configrefcap.testmsg", 100);
// Hack!!! getting reply to event is only way to access original name!?
// IRMessageEvent orig = ((IRMessageEvent)((MessageEventWrapper)msg).unwrap()).getInReplyMessageEvent();
// List origs = orig.getAllOccurrences();
// for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy