public class TestBehavior extends OneShotBehavior
test()
method of this behavior is called only once. Any
AssertionError
encountered during the test is stored
and can be later thrown using the checkAssertions()
method.
Typical usage of this behavior is shown below:
// setup Platform platform = new RealtimePlatform(); Container container = new Container(platform); Agent agent = new Agent(); container.add(agent); platform.start(); // test TestBehavior test = new TestBehavior() { public void test() { : : } }; test.runOn(agent); // tear down platform.shutdown();
Constructor and Description |
---|
TestBehavior()
Creates a test behavior.
|
TestBehavior(java.lang.Runnable runnable)
Creates a test behavior.
|
Modifier and Type | Method and Description |
---|---|
void |
action()
This method is repeatedly called during the life of a behavior.
|
void |
checkAssertions()
Throws any AssertionError that was encountered during the test.
|
boolean |
hasCompleted()
Checks if the test has been completed.
|
void |
reset()
Resets a behavior to its initial state.
|
void |
runOn(Agent agent)
Runs a test as a behavior of a specified agent.
|
void |
test()
This method should be overridden by sub-classes.
|
done
agent, agentForService, agentForService, agentsForService, agentsForService, block, block, compareTo, getPriority, isBlocked, onEnd, onStart, println, restart
public TestBehavior()
public TestBehavior(java.lang.Runnable runnable)
runnable
- Runnable to run.public final void action()
Behavior
public void reset()
Behavior
public boolean hasCompleted()
public void checkAssertions()
public void runOn(Agent agent)
agent
- agent to use for the test.public void test()