Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/IncomingFramesCapture.java')
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/IncomingFramesCapture.java31
1 files changed, 22 insertions, 9 deletions
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/IncomingFramesCapture.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/IncomingFramesCapture.java
index 81d207a66d..46479791c6 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/IncomingFramesCapture.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/IncomingFramesCapture.java
@@ -35,7 +35,7 @@ public class IncomingFramesCapture implements IncomingFrames
private static final Logger LOG = Log.getLogger(IncomingFramesCapture.class);
private LinkedList<WebSocketFrame> frames = new LinkedList<>();
- private LinkedList<WebSocketException> errors = new LinkedList<>();
+ private LinkedList<Throwable> errors = new LinkedList<>();
public void assertErrorCount(int expectedCount)
{
@@ -44,6 +44,19 @@ public class IncomingFramesCapture implements IncomingFrames
public void assertFrameCount(int expectedCount)
{
+ if (frames.size() != expectedCount)
+ {
+ // dump details
+ System.err.printf("Expected %d frame(s)%n",expectedCount);
+ System.err.printf("But actually captured %d frame(s)%n",frames.size());
+ for (int i = 0; i < frames.size(); i++)
+ {
+ Frame frame = frames.get(i);
+ System.err.printf(" [%d] Frame[%s] - %s%n", i,
+ OpCode.name(frame.getOpCode()),
+ BufferUtil.toDetailString(frame.getPayload()));
+ }
+ }
Assert.assertThat("Captured frame count",frames.size(),is(expectedCount));
}
@@ -59,17 +72,18 @@ public class IncomingFramesCapture implements IncomingFrames
public void assertHasFrame(byte op, int expectedCount)
{
- Assert.assertThat(OpCode.name(op),getFrameCount(op),is(expectedCount));
+ String msg = String.format("%s frame count",OpCode.name(op));
+ Assert.assertThat(msg,getFrameCount(op),is(expectedCount));
}
public void assertHasNoFrames()
{
- Assert.assertThat("Has no frames",frames.size(),is(0));
+ Assert.assertThat("Frame count",frames.size(),is(0));
}
public void assertNoErrors()
{
- Assert.assertThat("Has no errors",errors.size(),is(0));
+ Assert.assertThat("Error count",errors.size(),is(0));
}
public void dump()
@@ -86,7 +100,7 @@ public class IncomingFramesCapture implements IncomingFrames
public int getErrorCount(Class<? extends WebSocketException> errorType)
{
int count = 0;
- for (WebSocketException error : errors)
+ for (Throwable error : errors)
{
if (errorType.isInstance(error))
{
@@ -96,7 +110,7 @@ public class IncomingFramesCapture implements IncomingFrames
return count;
}
- public LinkedList<WebSocketException> getErrors()
+ public LinkedList<Throwable> getErrors()
{
return errors;
}
@@ -120,7 +134,7 @@ public class IncomingFramesCapture implements IncomingFrames
}
@Override
- public void incomingError(WebSocketException e)
+ public void incomingError(Throwable e)
{
LOG.debug(e);
errors.add(e);
@@ -129,8 +143,7 @@ public class IncomingFramesCapture implements IncomingFrames
@Override
public void incomingFrame(Frame frame)
{
- WebSocketFrame copy = new WebSocketFrame(frame);
- frames.add(copy);
+ frames.add(WebSocketFrame.copy(frame));
}
public int size()

Back to the top