Inherited by edu.cmu.hcii.calo.test.HistoryTest, edu.cmu.hcii.calo.test.NotificationTest, edu.cmu.hcii.calo.test.PackTest, edu.cmu.hcii.calo.test.RelevantInfoTest, edu.cmu.hcii.calo.test.ScheduleTest, and edu.cmu.hcii.calo.test.TaskTest.
Inheritance diagram for edu.cmu.hcii.calo.test.MessagePassingTestHarness:
MessagePassingTestHarness should be subclassed by tests that need to ensure that the right messages are being passed around when changes to a model object are made. It provides methods to quickly check that messages are received when expected and are exactly what they are expected to be.
Public Member Functions | |
void | clearMessages () |
Clears the list of messages, returning to the state that existed just after the test started. | |
Message | firstMessage () |
Retrieves the first (least recent) message received during this test. | |
boolean | hasMessages () |
Returns true if we have received any messages since the test began (or the last call to clearMessages()), false otherwise. | |
Iterator< Message > | iterator () |
Returns an iterator over the messages, in case direct access is needed. | |
Message | lastMessage () |
Retrieves the last (most recent) message received during this test. | |
void | onMessageReceived (Observable sender, Message msg) |
We override onMessageReceived so you don't have to™. | |
Protected Member Functions | |
void | expectMessage (Class<?extends Observable > managerClass, Class<?extends Message > messageClass, MessageType expectedType) |
Performs checks and assertions to ensure the following things are true:. | |
void | expectMessages (Class<?extends Observable > managerClasses[], Class<?extends Message > messageClasses[], MessageType expectedTypes[]) |
Performs checks and assertions to ensure the following things are true:. | |
void | expectUserInfoValueForKey (String key, Object value) |
Performs checks and assertions to ensure the following things are true:. | |
void | expectUserInfoValuesForKeys (String keys[], Object values[]) |
Performs checks and assertions to ensure the following things are true:. | |
Private Attributes | |
List< Message > | messages = new ArrayList<Message>() |
A list of all the messages we have received during this test since clearMessages() was last called. |
void edu.cmu.hcii.calo.test.MessagePassingTestHarness.clearMessages | ( | ) |
Clears the list of messages, returning to the state that existed just after the test started.
Message edu.cmu.hcii.calo.test.MessagePassingTestHarness.firstMessage | ( | ) |
Retrieves the first (least recent) message received during this test.
boolean edu.cmu.hcii.calo.test.MessagePassingTestHarness.hasMessages | ( | ) |
Returns true
if we have received any messages since the test began (or the last call to clearMessages()), false
otherwise.
true
if we have messages, false
if we don't Iterator<Message> edu.cmu.hcii.calo.test.MessagePassingTestHarness.iterator | ( | ) |
Returns an iterator over the messages, in case direct access is needed.
The iterator will return messages in order from least to most recent (earliest to latest received).
Message edu.cmu.hcii.calo.test.MessagePassingTestHarness.lastMessage | ( | ) |
Retrieves the last (most recent) message received during this test.
void edu.cmu.hcii.calo.test.MessagePassingTestHarness.onMessageReceived | ( | Observable | sender, | |
Message | msg | |||
) | [virtual] |
We override onMessageReceived so you don't have to™.
This onMessageReceived method checks to make sure that the message's sender matches the sender
argument, but performs no other checks.
sender | the sender of this message | |
msg | the message itself |
Implements edu.cmu.hcii.calo.messagePassing.MessageTarget.
void edu.cmu.hcii.calo.test.MessagePassingTestHarness.expectMessage | ( | Class<?extends Observable > | managerClass, | |
Class<?extends Message > | messageClass, | |||
MessageType | expectedType | |||
) | [protected] |
Performs checks and assertions to ensure the following things are true:.
1. We have received exactly one message since the start of the test.
2. The message we have received was from a manager of class managerClass
.
3. The message we have received is of the class messageClass
.
4. The message we have received has a MessageType equal to expectedType
.
managerClass | the manager class to check for | |
messageClass | the message class to check for | |
expectedType | the MessageType value to check for |
void edu.cmu.hcii.calo.test.MessagePassingTestHarness.expectMessages | ( | Class<?extends Observable > | managerClasses[], | |
Class<?extends Message > | messageClasses[], | |||
MessageType | expectedTypes[] | |||
) | [protected] |
Performs checks and assertions to ensure the following things are true:.
1. The managerClasses
, messageClasses
, and expectedTypes
arrays all contain the same number of elements (if not, this is a runtime assertion, not a test failure).
2. We have received exactly as many messages since the start of the test as there are items in the messageClasses
array.
3. For each message i
we have received:
a. The message was from a manager of class managerClasses
[i
].
b. The message we have received is of the class messageClasses
[i
].
c. The message we have received has a MessageType equal to expectedTypes
[i
].
managerClasses | the manager classes to check for | |
messageClasses | the message classes to check for | |
expectedTypes | the MessageType values to check for |
void edu.cmu.hcii.calo.test.MessagePassingTestHarness.expectUserInfoValueForKey | ( | String | key, | |
Object | value | |||
) | [protected] |
Performs checks and assertions to ensure the following things are true:.
1. We have received exactly one message since the start of the test.
2. The message we have received had a non-null userInfo map.
3. The value for key
in the userInfo map exists and is equal to value
.
key | the key to check for | |
value | the value to check for |
void edu.cmu.hcii.calo.test.MessagePassingTestHarness.expectUserInfoValuesForKeys | ( | String | keys[], | |
Object | values[] | |||
) | [protected] |
Performs checks and assertions to ensure the following things are true:.
1. The keys and values arrays have the same number of elements (if not, this is a runtime assertion, not a test failure).
2. We have received exactly as many messages since the start of the test as there are items in the keys
array.
3. For each message i
we have received:
2. The message had a non-null userInfo map.
3. The value for key
in the userInfo map exists and is equal to value
.
keys | the keys to check for | |
values | the values to check for |
List<Message> edu.cmu.hcii.calo.test.MessagePassingTestHarness.messages = new ArrayList<Message>() [private] |
A list of all the messages we have received during this test since clearMessages() was last called.