Fixing threading issue in testcase
This commit is contained in:
parent
8e98148350
commit
9a71d75003
|
@ -94,13 +94,12 @@ public class TrackingSocket extends WebSocketAdapter
|
|||
|
||||
public void awaitMessage(int expectedMessageCount, TimeUnit timeoutUnit, int timeoutDuration) throws TimeoutException
|
||||
{
|
||||
int startCount = messageQueue.size();
|
||||
long msDur = TimeUnit.MILLISECONDS.convert(timeoutDuration,timeoutUnit);
|
||||
long now = System.currentTimeMillis();
|
||||
long expireOn = now + msDur;
|
||||
LOG.debug("Now: {} - expireOn: {} ({} ms)",now,expireOn,msDur);
|
||||
LOG.debug("Await Message.. Now: {} - expireOn: {} ({} ms)",now,expireOn,msDur);
|
||||
|
||||
while (messageQueue.size() < (startCount + expectedMessageCount))
|
||||
while (messageQueue.size() < expectedMessageCount)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -118,6 +117,11 @@ public class TrackingSocket extends WebSocketAdapter
|
|||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
messageQueue.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketBinary(byte[] payload, int offset, int len)
|
||||
{
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.jetty.websocket.common.WebSocketFrame;
|
|||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -104,7 +103,6 @@ public class WebSocketClientTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Causing sporadic issues")
|
||||
public void testBasicEcho_FromServer() throws Exception
|
||||
{
|
||||
TrackingSocket wsocket = new TrackingSocket();
|
||||
|
|
Loading…
Reference in New Issue