mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-03 12:29:31 +00:00
Issue #3406 - fix SessionTracker and JettyWebSocketFrameHandlerTest
Signed-off-by: lachan-roberts <lachlan@webtide.com>
This commit is contained in:
parent
59ec0da768
commit
01bc9d3835
@ -21,6 +21,7 @@ package org.eclipse.jetty.websocket.javax.common;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import javax.websocket.Session;
|
||||
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
@ -44,7 +45,7 @@ public class SessionTracker extends AbstractLifeCycle implements JavaxWebSocketS
|
||||
@Override
|
||||
public void onJavaxWebSocketSessionClosed(JavaxWebSocketSession session)
|
||||
{
|
||||
sessions.remove(sessions);
|
||||
sessions.remove(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,10 +19,12 @@
|
||||
package org.eclipse.jetty.websocket.common;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
|
||||
import static org.eclipse.jetty.toolchain.test.matchers.RegexMatcher.matchesPattern;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class EventQueue extends LinkedBlockingDeque<String>
|
||||
{
|
||||
@ -33,10 +35,18 @@ public class EventQueue extends LinkedBlockingDeque<String>
|
||||
|
||||
public void assertEvents(String... regexEvents)
|
||||
{
|
||||
Iterator<String> capturedIterator = iterator();
|
||||
for (int i = 0; i < regexEvents.length; i++)
|
||||
int i = 0;
|
||||
try
|
||||
{
|
||||
assertThat("Event [" + i + "]", capturedIterator.next(), matchesPattern(regexEvents[i]));
|
||||
Iterator<String> capturedIterator = iterator();
|
||||
for (i = 0; i < regexEvents.length; i++)
|
||||
{
|
||||
assertThat("Event [" + i + "]", capturedIterator.next(), matchesPattern(regexEvents[i]));
|
||||
}
|
||||
}
|
||||
catch (NoSuchElementException e)
|
||||
{
|
||||
fail("Event [" + (i) + "] not found: " + regexEvents[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class JettyWebSocketFrameHandlerTest
|
||||
// Trigger Events
|
||||
localEndpoint.onOpen(channel, Callback.NOOP);
|
||||
localEndpoint.onFrame(new Frame(OpCode.TEXT).setPayload("Hello?").setFin(true), Callback.NOOP);
|
||||
localEndpoint.onFrame(CloseStatus.toFrame(StatusCode.NORMAL, "Normal"), Callback.NOOP);
|
||||
localEndpoint.onClosed(new CloseStatus(StatusCode.NORMAL, "Normal"), Callback.NOOP);
|
||||
|
||||
// Validate Events
|
||||
socket.events.assertEvents(
|
||||
@ -216,6 +216,7 @@ public class JettyWebSocketFrameHandlerTest
|
||||
localEndpoint.onFrame(new Frame(OpCode.CONTINUATION).setPayload(" the ").setFin(false), Callback.NOOP);
|
||||
localEndpoint.onFrame(new Frame(OpCode.CONTINUATION).setPayload("Pig").setFin(true), Callback.NOOP);
|
||||
localEndpoint.onFrame(CloseStatus.toFrame(StatusCode.NORMAL), Callback.NOOP);
|
||||
localEndpoint.onClosed(CloseStatus.NORMAL_STATUS, Callback.NOOP);
|
||||
|
||||
// Validate Events
|
||||
socket.events.assertEvents(
|
||||
@ -245,7 +246,7 @@ public class JettyWebSocketFrameHandlerTest
|
||||
localEndpoint.onFrame(new Frame(OpCode.BINARY).setPayload("Save").setFin(false), Callback.NOOP);
|
||||
localEndpoint.onFrame(new Frame(OpCode.CONTINUATION).setPayload(" the ").setFin(false), Callback.NOOP);
|
||||
localEndpoint.onFrame(new Frame(OpCode.CONTINUATION).setPayload("Pig").setFin(true), Callback.NOOP);
|
||||
localEndpoint.onFrame(CloseStatus.toFrame(StatusCode.NORMAL, "Normal"), Callback.NOOP);
|
||||
localEndpoint.onClosed(new CloseStatus(StatusCode.NORMAL, "Normal"), Callback.NOOP);
|
||||
|
||||
// Validate Events
|
||||
socket.events.assertEvents(
|
||||
@ -323,7 +324,7 @@ public class JettyWebSocketFrameHandlerTest
|
||||
localEndpoint.onFrame(new Frame(OpCode.CONTINUATION).setPayload(" the ").setFin(false), Callback.NOOP);
|
||||
localEndpoint.onFrame(new Frame(OpCode.PONG).setPayload("You there?"), Callback.NOOP);
|
||||
localEndpoint.onFrame(new Frame(OpCode.CONTINUATION).setPayload("Pig").setFin(true), Callback.NOOP);
|
||||
localEndpoint.onFrame(CloseStatus.toFrame(StatusCode.NORMAL, "Normal"), Callback.NOOP);
|
||||
localEndpoint.onClosed(new CloseStatus(StatusCode.NORMAL, "Normal"), Callback.NOOP);
|
||||
|
||||
// Validate Events
|
||||
socket.events.assertEvents(
|
||||
|
Loading…
x
Reference in New Issue
Block a user