jadex.bdi.testcases.misc.ReceiveStreamPlan 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.
package jadex.bdi.testcases.misc;
import jadex.base.test.TestReport;
import jadex.bdi.runtime.IMessageEvent;
import jadex.bdi.runtime.Plan;
import jadex.bridge.IInputConnection;
import jadex.bridge.fipa.SFipa;
/**
*
*/
public class ReceiveStreamPlan extends Plan
{
/**
* The plan body.
*/
public void body()
{
// System.out.println("triggered: "+this);
IMessageEvent msg = (IMessageEvent)getReason();
IInputConnection con = (IInputConnection)msg.getParameter(SFipa.CONTENT).getValue();
int cnt = 0;
// try
// {
// while(true)
// {
// byte b = con.areadNext().get(this);
// cnt++;
// System.out.println("Read: "+b);
// }
// }
// catch(Exception e)
// {
// // stream closed
//// e.printStackTrace();
// }
TestReport report = new TestReport("#1", "Testing stream read.");
if(cnt==5)
report.setSucceeded(true);
else
report.setReason("Received wrong number of bytes: "+cnt);
getBeliefbase().getBeliefSet("testcap.reports").addFact(report);
}
}