mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Messenger facade, a few miscellaneous bits
* more logging * comments * more tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@33894 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,6 +31,7 @@ public class MessengerTestHelper
|
||||
{
|
||||
private String receivedMsg;
|
||||
private final static int SLEEP_MILLIS = 50;
|
||||
private static final int MAX_TRIES = 30;
|
||||
|
||||
|
||||
public MessengerTestHelper()
|
||||
@@ -51,7 +52,7 @@ public class MessengerTestHelper
|
||||
{
|
||||
int tries = 0;
|
||||
|
||||
while (tries < 30)
|
||||
while (tries < MAX_TRIES)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -72,6 +73,32 @@ public class MessengerTestHelper
|
||||
fail("No message received, tried " + tries +
|
||||
" times, sleeping " + SLEEP_MILLIS + "ms each time.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that no message was received in the given period.
|
||||
*/
|
||||
public void checkNoMessageReceived()
|
||||
{
|
||||
int tries = 0;
|
||||
|
||||
while (tries < MAX_TRIES)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(SLEEP_MILLIS);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
// Carry on
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (getReceivedMsg() != null)
|
||||
{
|
||||
fail("Message received but should NOT have been. Message was: " + getReceivedMsg());
|
||||
}
|
||||
tries++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the receivedMsg
|
||||
@@ -88,4 +115,16 @@ public class MessengerTestHelper
|
||||
{
|
||||
this.receivedMsg = receivedMsg;
|
||||
}
|
||||
|
||||
|
||||
public static class TestMessageReceiver implements MessageReceiver<String>
|
||||
{
|
||||
MessengerTestHelper helper = new MessengerTestHelper();
|
||||
|
||||
@Override
|
||||
public void onReceive(String message)
|
||||
{
|
||||
helper.setReceivedMsg(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user