423948 - Cleanup and consolidate testing utilities in WebSocket

+ Created websocket-common-tests.jar artifact
+ Consolidated duplicate code from other websocket-* modules
  into the websocket-common test artifact
This commit is contained in:
Joakim Erdfelt 2014-01-08 10:46:15 -07:00
parent 152dfaa293
commit 9df519c40f
127 changed files with 378 additions and 2283 deletions

View File

@ -36,6 +36,13 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>

View File

@ -34,6 +34,13 @@
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>

View File

@ -18,8 +18,7 @@
package org.eclipse.jetty.websocket.jsr356.server;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.*;
import java.net.URI;
import java.util.Collections;
@ -43,9 +42,9 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.util.QuoteUtil;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.jsr356.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.jsr356.server.blockhead.HttpResponse;
import org.eclipse.jetty.websocket.jsr356.server.blockhead.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.BlockheadClient;
import org.eclipse.jetty.websocket.common.test.HttpResponse;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
import org.junit.AfterClass;
import org.junit.Assert;

View File

@ -1,741 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.jsr356.server.blockhead;
import static org.hamcrest.Matchers.*;
import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
import org.eclipse.jetty.websocket.api.util.WSURI;
import org.eclipse.jetty.websocket.common.AcceptHash;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.ConnectionState;
import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.extensions.ExtensionStack;
import org.eclipse.jetty.websocket.common.extensions.WebSocketExtensionFactory;
import org.eclipse.jetty.websocket.common.io.IOState;
import org.eclipse.jetty.websocket.common.io.IOState.ConnectionStateListener;
import org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParser;
import org.junit.Assert;
/**
* A simple websocket client for performing unit tests with.
* <p>
* This client will use {@link HttpURLConnection} and {@link HttpsURLConnection} with standard blocking calls to perform websocket requests.
* <p>
* This client is <u>NOT</u> intended to be performant or follow the websocket spec religiously. In fact, being able to deviate from the websocket spec at will
* is desired for this client to operate properly for the unit testing within this module.
* <p>
* The BlockheadClient should never validate frames or bytes being sent for validity, against any sort of spec, or even sanity. It should, however be honest
* with regards to basic IO behavior, a write should work as expected, a read should work as expected, but <u>what</u> byte it sends or reads is not within its
* scope.
*/
public class BlockheadClient implements IncomingFrames, OutgoingFrames, ConnectionStateListener, Closeable
{
private static final String REQUEST_HASH_KEY = "dGhlIHNhbXBsZSBub25jZQ==";
private static final int BUFFER_SIZE = 8192;
private static final Logger LOG = Log.getLogger(BlockheadClient.class);
/** Set to true to disable timeouts (for debugging reasons) */
private boolean debug = false;
private final URI destHttpURI;
private final URI destWebsocketURI;
private final ByteBufferPool bufferPool;
private final Generator generator;
private final Parser parser;
private final IncomingFramesCapture incomingFrames;
private final WebSocketExtensionFactory extensionFactory;
private Socket socket;
private OutputStream out;
private InputStream in;
private int version = 13; // default to RFC-6455
private String protocols;
private List<String> extensions = new ArrayList<>();
private List<String> headers = new ArrayList<>();
private byte[] clientmask = new byte[]
{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF };
private int timeout = 1000;
private AtomicInteger parseCount;
private OutgoingFrames outgoing = this;
private boolean eof = false;
private ExtensionStack extensionStack;
private IOState ioState;
private CountDownLatch disconnectedLatch = new CountDownLatch(1);
private ByteBuffer remainingBuffer;
private String connectionValue = "Upgrade";
public BlockheadClient(URI destWebsocketURI) throws URISyntaxException
{
this(WebSocketPolicy.newClientPolicy(),destWebsocketURI);
}
public BlockheadClient(WebSocketPolicy policy, URI destWebsocketURI) throws URISyntaxException
{
Assert.assertThat("Websocket URI scheme",destWebsocketURI.getScheme(),anyOf(is("ws"),is("wss")));
this.destWebsocketURI = destWebsocketURI;
if (destWebsocketURI.getScheme().equals("wss"))
{
throw new RuntimeException("Sorry, BlockheadClient does not support SSL");
}
this.destHttpURI = WSURI.toHttp(destWebsocketURI);
LOG.debug("WebSocket URI: {}",destWebsocketURI);
LOG.debug(" HTTP URI: {}",destHttpURI);
this.bufferPool = new MappedByteBufferPool(8192);
this.generator = new Generator(policy,bufferPool);
this.parser = new Parser(policy,bufferPool);
this.parseCount = new AtomicInteger(0);
this.incomingFrames = new IncomingFramesCapture();
this.extensionFactory = new WebSocketExtensionFactory(policy,bufferPool);
this.ioState = new IOState();
this.ioState.addListener(this);
}
public void addExtensions(String xtension)
{
this.extensions.add(xtension);
}
public void addHeader(String header)
{
this.headers.add(header);
}
public boolean awaitDisconnect(long timeout, TimeUnit unit) throws InterruptedException
{
return disconnectedLatch.await(timeout,unit);
}
public void clearCaptured()
{
this.incomingFrames.clear();
}
public void clearExtensions()
{
extensions.clear();
}
public void close()
{
LOG.debug("close()");
close(-1,null);
}
public void close(int statusCode, String message)
{
CloseInfo close = new CloseInfo(statusCode,message);
ioState.onCloseLocal(close);
if (!ioState.isClosed())
{
WebSocketFrame frame = close.asFrame();
LOG.debug("Issuing: {}",frame);
try
{
write(frame);
}
catch (IOException e)
{
LOG.debug(e);
}
}
}
public void connect() throws IOException
{
InetAddress destAddr = InetAddress.getByName(destHttpURI.getHost());
int port = destHttpURI.getPort();
SocketAddress endpoint = new InetSocketAddress(destAddr,port);
socket = new Socket();
socket.setSoTimeout(timeout);
socket.connect(endpoint);
out = socket.getOutputStream();
in = socket.getInputStream();
}
public void disconnect()
{
LOG.debug("disconnect");
IO.close(in);
IO.close(out);
disconnectedLatch.countDown();
if (socket != null)
{
try
{
socket.close();
}
catch (IOException ignore)
{
/* ignore */
}
}
}
public void expectServerDisconnect()
{
if (eof)
{
return;
}
try
{
int len = in.read();
if (len == (-1))
{
// we are disconnected
eof = true;
return;
}
Assert.assertThat("Expecting no data and proper socket disconnect (issued from server)",len,is(-1));
}
catch (SocketTimeoutException e)
{
LOG.warn(e);
Assert.fail("Expected a server initiated disconnect, instead the read timed out");
}
catch (IOException e)
{
// acceptable path
}
}
public HttpResponse expectUpgradeResponse() throws IOException
{
HttpResponse response = readResponseHeader();
if (LOG.isDebugEnabled())
{
LOG.debug("Response Header: {}{}",'\n',response);
}
Assert.assertThat("Response Status Code",response.getStatusCode(),is(101));
Assert.assertThat("Response Status Reason",response.getStatusReason(),is("Switching Protocols"));
Assert.assertThat("Response Header[Upgrade]",response.getHeader("Upgrade"),is("WebSocket"));
Assert.assertThat("Response Header[Connection]",response.getHeader("Connection"),is("Upgrade"));
// Validate the Sec-WebSocket-Accept
String acceptKey = response.getHeader("Sec-WebSocket-Accept");
Assert.assertThat("Response Header[Sec-WebSocket-Accept Exists]",acceptKey,notNullValue());
String reqKey = REQUEST_HASH_KEY;
String expectedHash = AcceptHash.hashKey(reqKey);
Assert.assertThat("Valid Sec-WebSocket-Accept Hash?",acceptKey,is(expectedHash));
// collect extensions configured in response header
List<ExtensionConfig> configs = getExtensionConfigs(response);
extensionStack = new ExtensionStack(this.extensionFactory);
extensionStack.negotiate(configs);
// Start with default routing
extensionStack.setNextIncoming(this); // the websocket layer
extensionStack.setNextOutgoing(outgoing); // the network layer
// Configure Parser / Generator
extensionStack.configure(parser);
extensionStack.configure(generator);
// Start Stack
try
{
extensionStack.start();
}
catch (Exception e)
{
throw new IOException("Unable to start Extension Stack");
}
// configure parser
parser.setIncomingFramesHandler(extensionStack);
ioState.onOpened();
LOG.debug("outgoing = {}",outgoing);
LOG.debug("incoming = {}",extensionStack);
return response;
}
public void flush() throws IOException
{
out.flush();
}
public String getConnectionValue()
{
return connectionValue;
}
private List<ExtensionConfig> getExtensionConfigs(HttpResponse response)
{
List<ExtensionConfig> configs = new ArrayList<>();
String econf = response.getHeader("Sec-WebSocket-Extensions");
if (econf != null)
{
LOG.debug("Found Extension Response: {}",econf);
ExtensionConfig config = ExtensionConfig.parse(econf);
configs.add(config);
}
return configs;
}
public List<String> getExtensions()
{
return extensions;
}
public URI getHttpURI()
{
return destHttpURI;
}
public IOState getIOState()
{
return ioState;
}
public String getProtocols()
{
return protocols;
}
public String getRequestHost()
{
if (destHttpURI.getPort() > 0)
{
return String.format("%s:%d",destHttpURI.getHost(),destHttpURI.getPort());
}
else
{
return destHttpURI.getHost();
}
}
public String getRequestPath()
{
StringBuilder path = new StringBuilder();
path.append(destHttpURI.getPath());
if (StringUtil.isNotBlank(destHttpURI.getQuery()))
{
path.append('?').append(destHttpURI.getQuery());
}
return path.toString();
}
public String getRequestWebSocketKey()
{
return REQUEST_HASH_KEY;
}
public String getRequestWebSocketOrigin()
{
return destWebsocketURI.toASCIIString();
}
public int getVersion()
{
return version;
}
public URI getWebsocketURI()
{
return destWebsocketURI;
}
/**
* Errors received (after extensions)
*/
@Override
public void incomingError(Throwable e)
{
incomingFrames.incomingError(e);
}
/**
* Frames received (after extensions)
*/
@Override
public void incomingFrame(Frame frame)
{
LOG.debug("incoming({})",frame);
int count = parseCount.incrementAndGet();
if ((count % 10) == 0)
{
LOG.info("Client parsed {} frames",count);
}
if (frame.getOpCode() == OpCode.CLOSE)
{
CloseInfo close = new CloseInfo(frame);
ioState.onCloseRemote(close);
}
WebSocketFrame copy = WebSocketFrame.copy(frame);
incomingFrames.incomingFrame(copy);
}
public boolean isConnected()
{
return (socket != null) && (socket.isConnected());
}
@Override
public void onConnectionStateChange(ConnectionState state)
{
switch (state)
{
case CLOSED:
// Per Spec, client should not initiate disconnect on its own
// this.disconnect();
break;
case CLOSING:
if (ioState.wasRemoteCloseInitiated())
{
CloseInfo close = ioState.getCloseInfo();
close(close.getStatusCode(),close.getReason());
}
break;
default:
/* do nothing */
break;
}
}
@Override
public void outgoingFrame(Frame frame, WriteCallback callback)
{
ByteBuffer headerBuf = generator.generateHeaderBytes(frame);
if (LOG.isDebugEnabled())
{
LOG.debug("writing out: {}",BufferUtil.toDetailString(headerBuf));
}
try
{
BufferUtil.writeTo(headerBuf,out);
BufferUtil.writeTo(frame.getPayload(),out);
out.flush();
if (callback != null)
{
callback.writeSuccess();
}
}
catch (IOException e)
{
if (callback != null)
{
callback.writeFailed(e);
}
}
finally
{
bufferPool.release(headerBuf);
}
if (frame.getOpCode() == OpCode.CLOSE)
{
disconnect();
}
}
public int read(ByteBuffer buf) throws IOException
{
if (eof)
{
throw new EOFException("Hit EOF");
}
if ((remainingBuffer != null) && (remainingBuffer.remaining() > 0))
{
return BufferUtil.put(remainingBuffer,buf);
}
int len = -1;
int b;
while ((in.available() > 0) && (buf.remaining() > 0))
{
b = in.read();
if (b == (-1))
{
eof = true;
break;
}
buf.put((byte)b);
len++;
}
return len;
}
public IncomingFramesCapture readFrames(int expectedCount, TimeUnit timeoutUnit, int timeoutDuration) throws IOException, TimeoutException
{
LOG.debug("Read: waiting for {} frame(s) from server",expectedCount);
ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false);
BufferUtil.clearToFill(buf);
try
{
long msDur = TimeUnit.MILLISECONDS.convert(timeoutDuration,timeoutUnit);
long now = System.currentTimeMillis();
long expireOn = now + msDur;
LOG.debug("Now: {} - expireOn: {} ({} ms)",now,expireOn,msDur);
long iter = 0;
int len = 0;
while (incomingFrames.size() < expectedCount)
{
BufferUtil.clearToFill(buf);
len = read(buf);
if (len > 0)
{
BufferUtil.flipToFlush(buf,0);
if (LOG.isDebugEnabled())
{
LOG.debug("Read {} bytes: {}",len,BufferUtil.toDetailString(buf));
}
parser.parse(buf);
}
else
{
if (LOG.isDebugEnabled())
{
iter++;
if ((iter % 10000000) == 0)
{
LOG.debug("10,000,000 reads of zero length");
iter = 0;
}
}
}
if (!debug && (System.currentTimeMillis() > expireOn))
{
incomingFrames.dump();
throw new TimeoutException(String.format("Timeout reading all %d expected frames. (managed to only read %d frame(s))",expectedCount,
incomingFrames.size()));
}
}
}
finally
{
bufferPool.release(buf);
}
return incomingFrames;
}
public HttpResponse readResponseHeader() throws IOException
{
HttpResponse response = new HttpResponse();
HttpResponseHeaderParser parser = new HttpResponseHeaderParser(response);
ByteBuffer buf = BufferUtil.allocate(512);
do
{
BufferUtil.flipToFill(buf);
read(buf);
BufferUtil.flipToFlush(buf,0);
}
while (parser.parse(buf) == null);
remainingBuffer = response.getRemainingBuffer();
return response;
}
public void sendStandardRequest() throws IOException
{
StringBuilder req = new StringBuilder();
req.append("GET ").append(getRequestPath()).append(" HTTP/1.1\r\n");
req.append("Host: ").append(getRequestHost()).append("\r\n");
req.append("Upgrade: websocket\r\n");
req.append("Connection: ").append(connectionValue).append("\r\n");
for (String header : headers)
{
req.append(header);
}
req.append("Sec-WebSocket-Key: ").append(getRequestWebSocketKey()).append("\r\n");
req.append("Sec-WebSocket-Origin: ").append(getRequestWebSocketOrigin()).append("\r\n");
if (StringUtil.isNotBlank(protocols))
{
req.append("Sec-WebSocket-Protocol: ").append(protocols).append("\r\n");
}
for (String xtension : extensions)
{
req.append("Sec-WebSocket-Extensions: ").append(xtension).append("\r\n");
}
req.append("Sec-WebSocket-Version: ").append(version).append("\r\n");
req.append("\r\n");
writeRaw(req.toString());
}
public void setConnectionValue(String connectionValue)
{
this.connectionValue = connectionValue;
}
public void setDebug(boolean flag)
{
this.debug = flag;
}
public void setProtocols(String protocols)
{
this.protocols = protocols;
}
public void setTimeout(TimeUnit unit, int duration)
{
this.timeout = (int)TimeUnit.MILLISECONDS.convert(duration,unit);
}
public void setVersion(int version)
{
this.version = version;
}
public void skipTo(String string) throws IOException
{
int state = 0;
while (true)
{
int b = in.read();
if (b < 0)
{
throw new EOFException();
}
if (b == string.charAt(state))
{
state++;
if (state == string.length())
{
break;
}
}
else
{
state = 0;
}
}
}
public void sleep(TimeUnit unit, int duration) throws InterruptedException
{
LOG.info("Sleeping for {} {}",duration,unit);
unit.sleep(duration);
LOG.info("Waking up from sleep");
}
public void write(WebSocketFrame frame) throws IOException
{
if (!ioState.isOpen())
{
return;
}
LOG.debug("write(Frame->{}) to {}",frame,outgoing);
if (LOG.isDebugEnabled())
{
frame.setMask(new byte[]
{ 0x00, 0x00, 0x00, 0x00 });
}
else
{
frame.setMask(clientmask);
}
extensionStack.outgoingFrame(frame,null);
}
public void writeRaw(ByteBuffer buf) throws IOException
{
LOG.debug("write(ByteBuffer) {}",BufferUtil.toDetailString(buf));
BufferUtil.writeTo(buf,out);
}
public void writeRaw(ByteBuffer buf, int numBytes) throws IOException
{
int len = Math.min(numBytes,buf.remaining());
byte arr[] = new byte[len];
buf.get(arr,0,len);
out.write(arr);
}
public void writeRaw(String str) throws IOException
{
LOG.debug("write((String)[{}]){}{})",str.length(),'\n',str);
out.write(StringUtil.getBytes(str,StringUtil.__ISO_8859_1));
}
public void writeRawSlowly(ByteBuffer buf, int segmentSize) throws IOException
{
while (buf.remaining() > 0)
{
writeRaw(buf,segmentSize);
flush();
}
}
}

View File

@ -1,72 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.jsr356.server.blockhead;
import static org.hamcrest.Matchers.is;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
/**
* Gotta test some basic constructors of the BlockheadClient.
*/
@RunWith(value = Parameterized.class)
public class BlockheadClientConstructionTest
{
@Parameters
public static Collection<Object[]> data()
{
List<Object[]> data = new ArrayList<>();
// @formatter:off
data.add(new Object[] { "ws://localhost/", "http://localhost/" });
data.add(new Object[] { "ws://localhost:8080/", "http://localhost:8080/" });
data.add(new Object[] { "ws://webtide.com/", "http://webtide.com/" });
data.add(new Object[] { "ws://www.webtide.com/sockets/chat", "http://www.webtide.com/sockets/chat" });
// @formatter:on
return data;
}
private URI expectedWsUri;
private URI expectedHttpUri;
public BlockheadClientConstructionTest(String wsuri, String httpuri)
{
this.expectedWsUri = URI.create(wsuri);
this.expectedHttpUri = URI.create(httpuri);
}
@SuppressWarnings("resource")
@Test
public void testURIs() throws URISyntaxException
{
BlockheadClient client = new BlockheadClient(expectedWsUri);
Assert.assertThat("Websocket URI",client.getWebsocketURI(),is(expectedWsUri));
Assert.assertThat("Websocket URI",client.getHttpURI(),is(expectedHttpUri));
}
}

View File

@ -1,94 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.jsr356.server.blockhead;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.TreeMap;
import org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParseListener;
public class HttpResponse implements HttpResponseHeaderParseListener
{
private int statusCode;
private String statusReason;
private Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
private ByteBuffer remainingBuffer;
@Override
public void addHeader(String name, String value)
{
headers.put(name,value);
}
public String getExtensionsHeader()
{
return getHeader("Sec-WebSocket-Extensions");
}
public String getHeader(String name)
{
return headers.get(name);
}
public ByteBuffer getRemainingBuffer()
{
return remainingBuffer;
}
public int getStatusCode()
{
return statusCode;
}
public String getStatusReason()
{
return statusReason;
}
@Override
public void setRemainingBuffer(ByteBuffer copy)
{
this.remainingBuffer = copy;
}
@Override
public void setStatusCode(int code)
{
this.statusCode = code;
}
@Override
public void setStatusReason(String reason)
{
this.statusReason = reason;
}
@Override
public String toString()
{
StringBuilder str = new StringBuilder();
str.append("HTTP/1.1 ").append(statusCode).append(' ').append(statusReason);
for (Map.Entry<String, String> entry : headers.entrySet())
{
str.append('\n').append(entry.getKey()).append(": ").append(entry.getValue());
}
return str.toString();
}
}

View File

@ -1,148 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.jsr356.server.blockhead;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import java.util.Queue;
import org.eclipse.jetty.toolchain.test.EventQueue;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.WebSocketException;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.junit.Assert;
public class IncomingFramesCapture implements IncomingFrames
{
private static final Logger LOG = Log.getLogger(IncomingFramesCapture.class);
private EventQueue<WebSocketFrame> frames = new EventQueue<>();
private EventQueue<Throwable> errors = new EventQueue<>();
public void assertErrorCount(int expectedCount)
{
Assert.assertThat("Captured error count",errors.size(),is(expectedCount));
}
public void assertFrameCount(int expectedCount)
{
Assert.assertThat("Captured frame count",frames.size(),is(expectedCount));
}
public void assertHasErrors(Class<? extends WebSocketException> errorType, int expectedCount)
{
Assert.assertThat(errorType.getSimpleName(),getErrorCount(errorType),is(expectedCount));
}
public void assertHasFrame(byte op)
{
Assert.assertThat(OpCode.name(op),getFrameCount(op),greaterThanOrEqualTo(1));
}
public void assertHasFrame(byte op, int expectedCount)
{
Assert.assertThat(OpCode.name(op),getFrameCount(op),is(expectedCount));
}
public void assertHasNoFrames()
{
Assert.assertThat("Has no frames",frames.size(),is(0));
}
public void assertNoErrors()
{
Assert.assertThat("Has no errors",errors.size(),is(0));
}
public void clear()
{
frames.clear();
}
public void dump()
{
System.err.printf("Captured %d incoming frames%n",frames.size());
int i = 0;
for (Frame frame : frames)
{
System.err.printf("[%3d] %s%n",i++,frame);
System.err.printf(" payload: %s%n",BufferUtil.toDetailString(frame.getPayload()));
}
}
public int getErrorCount(Class<? extends Throwable> errorType)
{
int count = 0;
for (Throwable error : errors)
{
if (errorType.isInstance(error))
{
count++;
}
}
return count;
}
public Queue<Throwable> getErrors()
{
return errors;
}
public int getFrameCount(byte op)
{
int count = 0;
for (WebSocketFrame frame : frames)
{
if (frame.getOpCode() == op)
{
count++;
}
}
return count;
}
public Queue<WebSocketFrame> getFrames()
{
return frames;
}
@Override
public void incomingError(Throwable e)
{
LOG.debug(e);
errors.add(e);
}
@Override
public void incomingFrame(Frame frame)
{
WebSocketFrame copy = WebSocketFrame.copy(frame);
frames.add(copy);
}
public int size()
{
return frames.size();
}
}

View File

@ -30,7 +30,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint(value = "/echo/beans/date", decoders = { DateDecoder.class }, encoders = { DateEncoder.class })
public class DateTextSocket

View File

@ -29,7 +29,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/binary/bytebuffer")
public class ByteBufferSocket

View File

@ -27,7 +27,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/partial/textsession")
public class PartialTextSessionSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/partial/text")
public class PartialTextSocket

View File

@ -29,7 +29,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/booleanobject/params/{a}")
public class BooleanObjectTextParamSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/booleanobject")
public class BooleanObjectTextSocket

View File

@ -29,7 +29,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/boolean/params/{a}")
public class BooleanTextParamSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/boolean")
public class BooleanTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/byteobject")
public class ByteObjectTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/byte")
public class ByteTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/char")
public class CharTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/characterobject")
public class CharacterObjectTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/doubleobject")
public class DoubleObjectTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/double")
public class DoubleTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/floatobject")
public class FloatObjectTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/float")
public class FloatTextSocket

View File

@ -29,7 +29,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/integer/params/{a}")
public class IntParamTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/integer")
public class IntTextSocket

View File

@ -29,7 +29,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/integerobject/params/{a}")
public class IntegerObjectParamTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/integerobject")
public class IntegerObjectTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/longobject")
public class LongObjectTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/long")
public class LongTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/shortobject")
public class ShortObjectTextSocket

View File

@ -28,7 +28,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/primitives/short")
public class ShortTextSocket

View File

@ -30,7 +30,7 @@ import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/streaming/inputstream")
public class InputStreamSocket

View File

@ -31,7 +31,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/streaming/readerparam/{param}")
public class ReaderParamSocket

View File

@ -29,7 +29,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/streaming/reader")
public class ReaderSocket

View File

@ -30,7 +30,7 @@ import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.jsr356.server.StackUtil;
import org.eclipse.jetty.websocket.common.util.StackUtil;
@ServerEndpoint("/echo/streaming/readerparam2/{param}")
public class StringReturnReaderParamSocket

View File

@ -30,6 +30,13 @@
<artifactId>websocket-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>

View File

@ -25,8 +25,8 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;

View File

@ -37,9 +37,9 @@ import org.eclipse.jetty.toolchain.test.OS;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.UpgradeException;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.AcceptHash;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.client.internal;
package org.eclipse.jetty.websocket.client;
import static org.hamcrest.Matchers.is;

View File

@ -18,11 +18,11 @@
package org.eclipse.jetty.websocket.client;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@ -31,10 +31,10 @@ import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
import org.junit.Assert;
public class ServerReadThread extends Thread
@ -91,7 +91,7 @@ public class ServerReadThread extends Thread
conn.getParser().parse(buf);
}
LinkedList<WebSocketFrame> frames = conn.getIncomingFrames().getFrames();
Queue<WebSocketFrame> frames = conn.getIncomingFrames().getFrames();
WebSocketFrame frame;
while ((frame = frames.poll()) != null)
{

View File

@ -25,8 +25,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
public class ServerWriteThread extends Thread
{

View File

@ -26,9 +26,9 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;

View File

@ -28,8 +28,8 @@ import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.toolchain.test.annotation.Slow;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;

View File

@ -28,9 +28,9 @@ import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.toolchain.test.annotation.Slow;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.client.masks.ZeroMasker;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;

View File

@ -27,8 +27,8 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;

View File

@ -27,8 +27,8 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
import org.junit.Assert;
import org.junit.Test;

View File

@ -35,10 +35,10 @@ import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.io.FutureWriteCallback;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;

View File

@ -1,143 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.client.blockhead;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import java.util.LinkedList;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.WebSocketException;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.junit.Assert;
public class IncomingFramesCapture implements IncomingFrames
{
private static final Logger LOG = Log.getLogger(IncomingFramesCapture.class);
private LinkedList<WebSocketFrame> frames = new LinkedList<>();
private LinkedList<Throwable> errors = new LinkedList<>();
public void assertErrorCount(int expectedCount)
{
Assert.assertThat("Captured error count",errors.size(),is(expectedCount));
}
public void assertFrameCount(int expectedCount)
{
Assert.assertThat("Captured frame count",frames.size(),is(expectedCount));
}
public void assertHasErrors(Class<? extends WebSocketException> errorType, int expectedCount)
{
Assert.assertThat(errorType.getSimpleName(),getErrorCount(errorType),is(expectedCount));
}
public void assertHasFrame(byte op)
{
Assert.assertThat(OpCode.name(op),getFrameCount(op),greaterThanOrEqualTo(1));
}
public void assertHasFrame(byte op, int expectedCount)
{
Assert.assertThat(OpCode.name(op),getFrameCount(op),is(expectedCount));
}
public void assertHasNoFrames()
{
Assert.assertThat("Has no frames",frames.size(),is(0));
}
public void assertNoErrors()
{
Assert.assertThat("Has no errors",errors.size(),is(0));
}
public void dump()
{
System.err.printf("Captured %d incoming frames%n",frames.size());
for (int i = 0; i < frames.size(); i++)
{
Frame frame = frames.get(i);
System.err.printf("[%3d] %s%n",i,frame);
System.err.printf(" %s%n",BufferUtil.toDetailString(frame.getPayload()));
}
}
public int getErrorCount(Class<? extends WebSocketException> errorType)
{
int count = 0;
for (Throwable error : errors)
{
if (errorType.isInstance(error))
{
count++;
}
}
return count;
}
public LinkedList<Throwable> getErrors()
{
return errors;
}
public int getFrameCount(byte op)
{
int count = 0;
for (WebSocketFrame frame : frames)
{
if (frame.getOpCode() == op)
{
count++;
}
}
return count;
}
public LinkedList<WebSocketFrame> getFrames()
{
return frames;
}
@Override
public void incomingError(Throwable e)
{
LOG.debug(e);
errors.add(e);
}
@Override
public void incomingFrame(Frame frame)
{
WebSocketFrame copy = WebSocketFrame.copy(frame);
Assert.assertThat("frame.masking must be set",frame.isMasked(),is(true));
frames.add(copy);
}
public int size()
{
return frames.size();
}
}

View File

@ -64,6 +64,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>artifact-jars</id>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,31 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses(
{ AcceptHashTest.class, ClosePayloadParserTest.class, GeneratorTest.class, ParserTest.class, PingPayloadParserTest.class, RFC6455ExamplesGeneratorTest.class,
RFC6455ExamplesParserTest.class, TextPayloadParserTest.class, WebSocketFrameTest.class })
public class AllTests
{
/* allow junit annotations to do the heavy lifting */
}

View File

@ -26,6 +26,9 @@ import java.nio.charset.StandardCharsets;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.eclipse.jetty.websocket.common.util.MaskedByteBuffer;
import org.junit.Assert;
import org.junit.Test;
@ -57,7 +60,7 @@ public class ClosePayloadParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.CLOSE,1);
CloseInfo close = new CloseInfo(capture.getFrames().get(0));
CloseInfo close = new CloseInfo(capture.getFrames().poll());
Assert.assertThat("CloseFrame.statusCode",close.getStatusCode(),is(StatusCode.NORMAL));
Assert.assertThat("CloseFrame.data",close.getReason(),is(expectedReason));
}

View File

@ -28,6 +28,7 @@ import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.junit.Assert;
import org.junit.Test;
@ -69,7 +70,7 @@ public class GeneratorParserRoundtripTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
TextFrame txt = (TextFrame)capture.getFrames().get(0);
TextFrame txt = (TextFrame)capture.getFrames().poll();
Assert.assertThat("Text parsed",txt.getPayloadAsUTF8(),is(message));
}
@ -115,7 +116,7 @@ public class GeneratorParserRoundtripTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
TextFrame txt = (TextFrame)capture.getFrames().get(0);
TextFrame txt = (TextFrame)capture.getFrames().poll();
Assert.assertTrue("Text.isMasked",txt.isMasked());
Assert.assertThat("Text parsed",txt.getPayloadAsUTF8(),is(message));
}

View File

@ -34,6 +34,10 @@ import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.eclipse.jetty.websocket.common.frames.CloseFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitGenerator;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.eclipse.jetty.websocket.common.util.Hex;
import org.junit.Assert;
import org.junit.Test;
@ -300,7 +304,7 @@ public class GeneratorTest
parser.parse(completeBuffer);
// Assert validity of frame
WebSocketFrame actual = capture.getFrames().get(0);
WebSocketFrame actual = capture.getFrames().poll();
Assert.assertThat("Frame.opcode",actual.getOpCode(),is(OpCode.BINARY));
Assert.assertThat("Frame.payloadLength",actual.getPayloadLength(),is(payload.length));

View File

@ -1,154 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import java.util.LinkedList;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.WebSocketException;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.junit.Assert;
public class IncomingFramesCapture implements IncomingFrames
{
private static final Logger LOG = Log.getLogger(IncomingFramesCapture.class);
private LinkedList<WebSocketFrame> frames = new LinkedList<>();
private LinkedList<Throwable> errors = new LinkedList<>();
public void assertErrorCount(int expectedCount)
{
Assert.assertThat("Captured error count",errors.size(),is(expectedCount));
}
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));
}
public void assertHasErrors(Class<? extends WebSocketException> errorType, int expectedCount)
{
Assert.assertThat(errorType.getSimpleName(),getErrorCount(errorType),is(expectedCount));
}
public void assertHasFrame(byte op)
{
Assert.assertThat(OpCode.name(op),getFrameCount(op),greaterThanOrEqualTo(1));
}
public void assertHasFrame(byte op, int expectedCount)
{
String msg = String.format("%s frame count",OpCode.name(op));
Assert.assertThat(msg,getFrameCount(op),is(expectedCount));
}
public void assertHasNoFrames()
{
Assert.assertThat("Frame count",frames.size(),is(0));
}
public void assertNoErrors()
{
Assert.assertThat("Error count",errors.size(),is(0));
}
public void dump()
{
System.err.printf("Captured %d incoming frames%n",frames.size());
for (int i = 0; i < frames.size(); i++)
{
Frame frame = frames.get(i);
System.err.printf("[%3d] %s%n",i,frame);
System.err.printf(" %s%n",BufferUtil.toDetailString(frame.getPayload()));
}
}
public int getErrorCount(Class<? extends WebSocketException> errorType)
{
int count = 0;
for (Throwable error : errors)
{
if (errorType.isInstance(error))
{
count++;
}
}
return count;
}
public LinkedList<Throwable> getErrors()
{
return errors;
}
public int getFrameCount(byte op)
{
int count = 0;
for (WebSocketFrame frame : frames)
{
if (frame.getOpCode() == op)
{
count++;
}
}
return count;
}
public LinkedList<WebSocketFrame> getFrames()
{
return frames;
}
@Override
public void incomingError(Throwable e)
{
LOG.debug(e);
errors.add(e);
}
@Override
public void incomingFrame(Frame frame)
{
frames.add(WebSocketFrame.copy(frame));
}
public int size()
{
return frames.size();
}
}

View File

@ -34,6 +34,10 @@ import org.eclipse.jetty.websocket.common.frames.DataFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.PongFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitGenerator;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.eclipse.jetty.websocket.common.util.Hex;
import org.junit.Assert;
import org.junit.Test;
@ -238,7 +242,7 @@ public class ParserTest
capture.assertNoErrors();
Assert.assertThat("Frame Count",capture.getFrames().size(),is(2));
WebSocketFrame frame = capture.getFrames().pop();
WebSocketFrame frame = capture.getFrames().poll();
Assert.assertThat("Frame[0].opcode",frame.getOpCode(),is(OpCode.TEXT));
ByteBuffer actualPayload = frame.getPayload();
Assert.assertThat("Frame[0].payload.length",actualPayload.remaining(),is(payload.length));

View File

@ -26,6 +26,8 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
import org.junit.Test;
@ -48,7 +50,7 @@ public class PingPayloadParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.PING,1);
PingFrame ping = (PingFrame)capture.getFrames().get(0);
PingFrame ping = (PingFrame)capture.getFrames().poll();
String actual = BufferUtil.toUTF8String(ping.getPayload());
Assert.assertThat("PingFrame.payload",actual,is("Hello"));

View File

@ -26,6 +26,8 @@ import org.eclipse.jetty.websocket.common.frames.ContinuationFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.PongFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.UnitGenerator;
import org.junit.Test;
public class RFC6455ExamplesGeneratorTest

View File

@ -26,6 +26,8 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
import org.junit.Test;
@ -67,10 +69,10 @@ public class RFC6455ExamplesParserTest
capture.assertHasFrame(OpCode.TEXT,1);
capture.assertHasFrame(OpCode.CONTINUATION,1);
WebSocketFrame txt = capture.getFrames().get(0);
WebSocketFrame txt = capture.getFrames().poll();
String actual = BufferUtil.toUTF8String(txt.getPayload());
Assert.assertThat("TextFrame[0].data",actual,is("Hel"));
txt = capture.getFrames().get(1);
txt = capture.getFrames().poll();
actual = BufferUtil.toUTF8String(txt.getPayload());
Assert.assertThat("TextFrame[1].data",actual,is("lo"));
}
@ -94,7 +96,7 @@ public class RFC6455ExamplesParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.PONG,1);
WebSocketFrame pong = capture.getFrames().get(0);
WebSocketFrame pong = capture.getFrames().poll();
String actual = BufferUtil.toUTF8String(pong.getPayload());
Assert.assertThat("PongFrame.payload",actual,is("Hello"));
}
@ -118,7 +120,7 @@ public class RFC6455ExamplesParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
WebSocketFrame txt = capture.getFrames().get(0);
WebSocketFrame txt = capture.getFrames().poll();
String actual = BufferUtil.toUTF8String(txt.getPayload());
Assert.assertThat("TextFrame.payload",actual,is("Hello"));
}
@ -149,7 +151,7 @@ public class RFC6455ExamplesParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY,1);
Frame bin = capture.getFrames().get(0);
Frame bin = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength",bin.getPayloadLength(),is(dataSize));
@ -188,7 +190,7 @@ public class RFC6455ExamplesParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY,1);
Frame bin = capture.getFrames().get(0);
Frame bin = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength",bin.getPayloadLength(),is(dataSize));
ByteBuffer data = bin.getPayload();
@ -219,7 +221,7 @@ public class RFC6455ExamplesParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.PING,1);
WebSocketFrame ping = capture.getFrames().get(0);
WebSocketFrame ping = capture.getFrames().poll();
String actual = BufferUtil.toUTF8String(ping.getPayload());
Assert.assertThat("PingFrame.payload",actual,is("Hello"));
}
@ -243,7 +245,7 @@ public class RFC6455ExamplesParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
WebSocketFrame txt = capture.getFrames().get(0);
WebSocketFrame txt = capture.getFrames().poll();
String actual = BufferUtil.toUTF8String(txt.getPayload());
Assert.assertThat("TextFrame.payload",actual,is("Hello"));
}

View File

@ -31,6 +31,9 @@ import org.eclipse.jetty.websocket.api.MessageTooLargeException;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.eclipse.jetty.websocket.common.util.MaskedByteBuffer;
import org.junit.Assert;
import org.junit.Test;
@ -65,7 +68,7 @@ public class TextPayloadParserTest
capture.assertHasErrors(MessageTooLargeException.class,1);
capture.assertHasNoFrames();
MessageTooLargeException err = (MessageTooLargeException)capture.getErrors().get(0);
MessageTooLargeException err = (MessageTooLargeException)capture.getErrors().poll();
Assert.assertThat("Error.closeCode",err.getStatusCode(),is(StatusCode.MESSAGE_TOO_LARGE));
}
@ -101,7 +104,7 @@ public class TextPayloadParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
WebSocketFrame txt = capture.getFrames().get(0);
WebSocketFrame txt = capture.getFrames().poll();
Assert.assertThat("TextFrame.data",txt.getPayloadAsUTF8(),is(expectedText));
}
@ -136,7 +139,7 @@ public class TextPayloadParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
WebSocketFrame txt = capture.getFrames().get(0);
WebSocketFrame txt = capture.getFrames().poll();
Assert.assertThat("TextFrame.data",txt.getPayloadAsUTF8(),is(expectedText));
}
@ -174,9 +177,9 @@ public class TextPayloadParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
capture.assertHasFrame(OpCode.CONTINUATION,1);
WebSocketFrame txt = capture.getFrames().get(0);
WebSocketFrame txt = capture.getFrames().poll();
Assert.assertThat("TextFrame[0].data",txt.getPayloadAsUTF8(),is(part1));
txt = capture.getFrames().get(1);
txt = capture.getFrames().poll();
Assert.assertThat("TextFrame[1].data",txt.getPayloadAsUTF8(),is(part2));
}
@ -201,7 +204,7 @@ public class TextPayloadParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
WebSocketFrame txt = capture.getFrames().get(0);
WebSocketFrame txt = capture.getFrames().poll();
Assert.assertThat("TextFrame.data",txt.getPayloadAsUTF8(),is(expectedText));
}
@ -227,7 +230,7 @@ public class TextPayloadParserTest
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
WebSocketFrame txt = capture.getFrames().get(0);
WebSocketFrame txt = capture.getFrames().poll();
Assert.assertThat("TextFrame.data",txt.getPayloadAsUTF8(),is(expectedText));
}
}

View File

@ -31,6 +31,7 @@ import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.frames.CloseFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.util.Hex;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

View File

@ -24,6 +24,7 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import org.eclipse.jetty.websocket.common.io.LocalWebSocketConnection;
import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;

View File

@ -1,30 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.common.ab;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses(
{ TestABCase1_1.class, TestABCase1_2.class, TestABCase2.class, TestABCase3.class, TestABCase4.class, TestABCase7_3.class })
public class AllTests
{
/* nothing to do here, its all done in the annotations */
}

View File

@ -27,14 +27,14 @@ import java.util.Arrays;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitGenerator;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
import org.junit.Test;
@ -312,7 +312,7 @@ public class TestABCase1_1
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("TextFrame.payload",length,pActual.getPayloadData().length);
}
@ -346,7 +346,7 @@ public class TestABCase1_1
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("TextFrame.payload",length,pActual.getPayloadData().length);
}
@ -380,7 +380,7 @@ public class TestABCase1_1
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("TextFrame.payload",length,pActual.getPayloadData().length);
}
@ -414,7 +414,7 @@ public class TestABCase1_1
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length));
// .assertEquals("TextFrame.payload",length,pActual.getPayloadData().length);
}
@ -450,7 +450,7 @@ public class TestABCase1_1
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("TextFrame.payload",length,pActual.getPayloadData().length);
}
@ -487,7 +487,7 @@ public class TestABCase1_1
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("TextFrame.payload",length,pActual.getPayloadData().length);
}
@ -511,7 +511,7 @@ public class TestABCase1_1
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(0));
}
}

View File

@ -26,14 +26,14 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitGenerator;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
import org.junit.Test;
@ -331,7 +331,7 @@ public class TestABCase1_2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("BinaryFrame.payload",length,pActual.getPayloadData().length);
}
@ -365,7 +365,7 @@ public class TestABCase1_2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("BinaryFrame.payload",length,pActual.getPayloadData().length);
}
@ -399,7 +399,7 @@ public class TestABCase1_2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength",pActual.getPayloadLength(),is(length));
// .assertEquals("BinaryFrame.payload",length,pActual.getPayloadData().length);
}
@ -433,7 +433,7 @@ public class TestABCase1_2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("BinaryFrame.payload",length,pActual.getPayloadData().length);
}
@ -468,7 +468,7 @@ public class TestABCase1_2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("BinaryFrame.payload",length,pActual.getPayloadData().length);
}
@ -505,7 +505,7 @@ public class TestABCase1_2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength",pActual.getPayloadLength(),is(length));
// Assert.assertEquals("BinaryFrame.payload",length,pActual.getPayloadData().length);
}
@ -529,7 +529,7 @@ public class TestABCase1_2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength",pActual.getPayloadLength(),is(0));
// Assert.assertNull("BinaryFrame.payload",pActual.getPayloadData());
}

View File

@ -29,15 +29,15 @@ import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketException;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitGenerator;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
import org.junit.Test;
@ -193,7 +193,7 @@ public class TestABCase2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.PING,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("PingFrame.payloadLength",pActual.getPayloadLength(),is(bytes.length));
Assert.assertEquals("PingFrame.payload",bytes.length,pActual.getPayloadLength());
}
@ -223,7 +223,7 @@ public class TestABCase2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.PING,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("PingFrame.payloadLength",pActual.getPayloadLength(),is(bytes.length));
Assert.assertEquals("PingFrame.payload",bytes.length,pActual.getPayloadLength());
}
@ -246,7 +246,7 @@ public class TestABCase2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.PING,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("PingFrame.payloadLength",pActual.getPayloadLength(),is(0));
Assert.assertEquals("PingFrame.payload",0,pActual.getPayloadLength());
}
@ -277,7 +277,7 @@ public class TestABCase2
capture.assertNoErrors();
capture.assertHasFrame(OpCode.PING,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("PingFrame.payloadLength",pActual.getPayloadLength(),is(message.length()));
Assert.assertEquals("PingFrame.payload",message.length(),pActual.getPayloadLength());
}

View File

@ -25,10 +25,10 @@ import java.util.List;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.websocket.api.ProtocolException;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.PongFrame;
import org.eclipse.jetty.websocket.common.test.UnitGenerator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@ -24,9 +24,9 @@ import org.eclipse.jetty.util.log.StacklessLogging;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketException;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
import org.junit.Test;
@ -55,7 +55,7 @@ public class TestABCase4
Assert.assertEquals( "error on undefined opcode", 1, capture.getErrorCount(WebSocketException.class)) ;
Throwable known = capture.getErrors().get(0);
Throwable known = capture.getErrors().poll();
Assert.assertTrue("undefined option should be in message",known.getMessage().contains("Unknown opcode: 11"));
}
@ -81,7 +81,7 @@ public class TestABCase4
Assert.assertEquals( "error on undefined opcode", 1, capture.getErrorCount(WebSocketException.class)) ;
Throwable known = capture.getErrors().get(0);
Throwable known = capture.getErrors().poll();
Assert.assertTrue("undefined option should be in message",known.getMessage().contains("Unknown opcode: 12"));
}
@ -108,7 +108,7 @@ public class TestABCase4
Assert.assertEquals( "error on undefined opcode", 1, capture.getErrorCount(WebSocketException.class)) ;
Throwable known = capture.getErrors().get(0);
Throwable known = capture.getErrors().poll();
Assert.assertTrue("undefined option should be in message",known.getMessage().contains("Unknown opcode: 3"));
}
@ -134,7 +134,7 @@ public class TestABCase4
Assert.assertEquals( "error on undefined opcode", 1, capture.getErrorCount(WebSocketException.class)) ;
Throwable known = capture.getErrors().get(0);
Throwable known = capture.getErrors().poll();
Assert.assertTrue("undefined option should be in message",known.getMessage().contains("Unknown opcode: 4"));
}

View File

@ -30,15 +30,15 @@ import org.eclipse.jetty.websocket.api.ProtocolException;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.Hex;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.frames.CloseFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitGenerator;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.eclipse.jetty.websocket.common.util.Hex;
import org.junit.Assert;
import org.junit.Test;
@ -81,7 +81,7 @@ public class TestABCase7_3
capture.assertNoErrors();
capture.assertHasFrame(OpCode.CLOSE,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("CloseFrame.payloadLength",pActual.getPayloadLength(),is(0));
}
@ -108,7 +108,7 @@ public class TestABCase7_3
Assert.assertEquals("error on invalid close payload",1,capture.getErrorCount(ProtocolException.class));
ProtocolException known = (ProtocolException)capture.getErrors().get(0);
ProtocolException known = (ProtocolException)capture.getErrors().poll();
Assert.assertThat("Payload.message",known.getMessage(),containsString("Invalid close frame payload length"));
}
@ -148,7 +148,7 @@ public class TestABCase7_3
capture.assertNoErrors();
capture.assertHasFrame(OpCode.CLOSE,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("CloseFrame.payloadLength",pActual.getPayloadLength(),is(2));
}
@ -205,7 +205,7 @@ public class TestABCase7_3
capture.assertNoErrors();
capture.assertHasFrame(OpCode.CLOSE,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("CloseFrame.payloadLength",pActual.getPayloadLength(),is(messageBytes.length + 2));
}
@ -274,7 +274,7 @@ public class TestABCase7_3
capture.assertNoErrors();
capture.assertHasFrame(OpCode.CLOSE,1);
Frame pActual = capture.getFrames().get(0);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("CloseFrame.payloadLength",pActual.getPayloadLength(),is(125));
}
@ -342,7 +342,7 @@ public class TestABCase7_3
Assert.assertEquals("error on invalid close payload",1,capture.getErrorCount(ProtocolException.class));
ProtocolException known = (ProtocolException)capture.getErrors().get(0);
ProtocolException known = (ProtocolException)capture.getErrors().poll();
Assert.assertThat("Payload.message",known.getMessage(),containsString("Invalid control frame payload length"));
}

View File

@ -1,33 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.common.extensions;
import org.eclipse.jetty.websocket.common.extensions.compress.DeflateFrameExtensionTest;
import org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtensionTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses(
{ ExtensionStackTest.class, PerMessageDeflateExtensionTest.class, FragmentExtensionTest.class,
IdentityExtensionTest.class, DeflateFrameExtensionTest.class })
public class AllTests
{
/* nothing to do here, its all done in the annotations */
}

View File

@ -30,12 +30,12 @@ import org.eclipse.jetty.websocket.api.extensions.Extension;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
public class ExtensionTool
@ -104,7 +104,7 @@ public class ExtensionTool
for (int i = 0; i < expectedCount; i++)
{
WebSocketFrame actual = capture.getFrames().pop();
WebSocketFrame actual = capture.getFrames().poll();
String prefix = String.format("frame[%d]",i);
Assert.assertThat(prefix + ".opcode",actual.getOpCode(),is(expectedFrames[i].getOpCode()));

View File

@ -32,15 +32,15 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.OutgoingFramesCapture;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.extensions.fragment.FragmentExtension;
import org.eclipse.jetty.websocket.common.frames.ContinuationFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.Assert;
import org.junit.Test;
@ -80,12 +80,11 @@ public class FragmentExtensionTest
capture.assertHasFrame(OpCode.TEXT,len);
String prefix;
for (int i = 0; i < len; i++)
int i = 0;
for (WebSocketFrame actual : capture.getFrames())
{
prefix = "Frame[" + i + "]";
WebSocketFrame actual = capture.getFrames().get(i);
Assert.assertThat(prefix + ".opcode",actual.getOpCode(),is(OpCode.TEXT));
Assert.assertThat(prefix + ".fin",actual.isFin(),is(true));
Assert.assertThat(prefix + ".rsv1",actual.isRsv1(),is(false));
@ -95,6 +94,7 @@ public class FragmentExtensionTest
ByteBuffer expected = BufferUtil.toBuffer(quote.get(i),StandardCharsets.UTF_8);
Assert.assertThat(prefix + ".payloadLength",actual.getPayloadLength(),is(expected.remaining()));
ByteBufferAssert.assertEquals(prefix + ".payload",expected,actual.getPayload().slice());
i++;
}
}
@ -120,7 +120,7 @@ public class FragmentExtensionTest
capture.assertFrameCount(1);
capture.assertHasFrame(OpCode.PING,1);
WebSocketFrame actual = capture.getFrames().getFirst();
WebSocketFrame actual = capture.getFrames().poll();
Assert.assertThat("Frame.opcode",actual.getOpCode(),is(OpCode.PING));
Assert.assertThat("Frame.fin",actual.isFin(),is(true));

View File

@ -27,13 +27,13 @@ import java.nio.charset.StandardCharsets;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.extensions.Extension;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.OutgoingFramesCapture;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.extensions.identity.IdentityExtension;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.Assert;
import org.junit.Test;
@ -55,7 +55,7 @@ public class IdentityExtensionTest
capture.assertFrameCount(1);
capture.assertHasFrame(OpCode.TEXT,1);
WebSocketFrame actual = capture.getFrames().getFirst();
WebSocketFrame actual = capture.getFrames().poll();
Assert.assertThat("Frame.opcode",actual.getOpCode(),is(OpCode.TEXT));
Assert.assertThat("Frame.fin",actual.isFin(),is(true));

View File

@ -24,7 +24,7 @@ import java.util.List;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
import org.eclipse.jetty.websocket.common.Hex;
import org.eclipse.jetty.websocket.common.util.Hex;
public class CapturedHexPayloads implements OutgoingFrames
{

View File

@ -36,17 +36,17 @@ import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.OutgoingNetworkBytesCapture;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.extensions.AbstractExtensionTest;
import org.eclipse.jetty.websocket.common.extensions.ExtensionTool.Tester;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.OutgoingNetworkBytesCapture;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
import org.junit.Test;
@ -79,9 +79,9 @@ public class DeflateFrameExtensionTest extends AbstractExtensionTest
capture.assertFrameCount(len);
capture.assertHasFrame(OpCode.TEXT,len);
for (int i = 0; i < len; i++)
int i=0;
for (WebSocketFrame actual: capture.getFrames())
{
WebSocketFrame actual = capture.getFrames().get(i);
String prefix = "Frame[" + i + "]";
Assert.assertThat(prefix + ".opcode",actual.getOpCode(),is(OpCode.TEXT));
Assert.assertThat(prefix + ".fin",actual.isFin(),is(true));
@ -92,6 +92,7 @@ public class DeflateFrameExtensionTest extends AbstractExtensionTest
ByteBuffer expected = BufferUtil.toBuffer(expectedTextDatas[i],StandardCharsets.UTF_8);
Assert.assertThat(prefix + ".payloadLength",actual.getPayloadLength(),is(expected.remaining()));
ByteBufferAssert.assertEquals(prefix + ".payload",expected,actual.getPayload().slice());
i++;
}
}

View File

@ -22,7 +22,7 @@ import java.nio.ByteBuffer;
import java.util.zip.Deflater;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.websocket.common.Hex;
import org.eclipse.jetty.websocket.common.util.Hex;
import org.junit.Ignore;
import org.junit.Test;

View File

@ -31,16 +31,16 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.OutgoingFramesCapture;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.extensions.AbstractExtensionTest;
import org.eclipse.jetty.websocket.common.extensions.ExtensionTool.Tester;
import org.eclipse.jetty.websocket.common.frames.ContinuationFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.Assert;
import org.junit.Test;
@ -223,7 +223,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
capture.assertFrameCount(1);
capture.assertHasFrame(OpCode.PING,1);
WebSocketFrame actual = capture.getFrames().getFirst();
WebSocketFrame actual = capture.getFrames().poll();
Assert.assertThat("Frame.opcode",actual.getOpCode(),is(OpCode.PING));
Assert.assertThat("Frame.fin",actual.isFin(),is(true));
@ -273,12 +273,11 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
capture.assertHasFrame(OpCode.TEXT,len);
String prefix;
for (int i = 0; i < len; i++)
int i = 0;
for (WebSocketFrame actual : capture.getFrames())
{
prefix = "Frame[" + i + "]";
WebSocketFrame actual = capture.getFrames().get(i);
Assert.assertThat(prefix + ".opcode",actual.getOpCode(),is(OpCode.TEXT));
Assert.assertThat(prefix + ".fin",actual.isFin(),is(true));
Assert.assertThat(prefix + ".rsv1",actual.isRsv1(),is(false));
@ -288,6 +287,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
ByteBuffer expected = BufferUtil.toBuffer(quote.get(i),StandardCharsets.UTF_8);
Assert.assertThat(prefix + ".payloadLength",actual.getPayloadLength(),is(expected.remaining()));
ByteBufferAssert.assertEquals(prefix + ".payload",expected,actual.getPayload().slice());
i++;
}
}

View File

@ -20,10 +20,10 @@ package org.eclipse.jetty.websocket.common.io;
import java.net.URI;
import org.eclipse.jetty.websocket.common.OutgoingFramesCapture;
import org.eclipse.jetty.websocket.common.SessionListener;
import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.events.EventDriver;
import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.rules.TestName;
public class LocalWebSocketSession extends WebSocketSession

View File

@ -27,11 +27,11 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.Hex;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.UnitGenerator;
import org.eclipse.jetty.websocket.common.util.Hex;
import org.junit.Assert;
import org.junit.Test;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.server.blockhead;
package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.*;
@ -67,7 +67,6 @@ import org.eclipse.jetty.websocket.common.extensions.WebSocketExtensionFactory;
import org.eclipse.jetty.websocket.common.io.IOState;
import org.eclipse.jetty.websocket.common.io.IOState.ConnectionStateListener;
import org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParser;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
import org.junit.Assert;
/**

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.server.blockhead;
package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.is;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.client.blockhead;
package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.*;

View File

@ -16,38 +16,45 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.nio.ByteBuffer;
import org.eclipse.jetty.util.BufferUtil;
import org.junit.Assert;
public class ByteBufferAssert
{
public static void assertEquals(String message, byte[] expected, byte[] actual)
{
Assert.assertThat(message + " byte[].length",actual.length,is(expected.length));
assertThat(message + " byte[].length",actual.length,is(expected.length));
int len = expected.length;
for (int i = 0; i < len; i++)
{
Assert.assertThat(message + " byte[" + i + "]",actual[i],is(expected[i]));
assertThat(message + " byte[" + i + "]",actual[i],is(expected[i]));
}
}
public static void assertEquals(String message, ByteBuffer expectedBuffer, ByteBuffer actualBuffer)
{
byte expectedBytes[] = BufferUtil.toArray(expectedBuffer);
byte actualBytes[] = BufferUtil.toArray(actualBuffer);
assertEquals(message,expectedBytes,actualBytes);
if (expectedBuffer == null)
{
assertThat(message,actualBuffer,nullValue());
}
else
{
byte expectedBytes[] = BufferUtil.toArray(expectedBuffer);
byte actualBytes[] = BufferUtil.toArray(actualBuffer);
assertEquals(message,expectedBytes,actualBytes);
}
}
public static void assertEquals(String message, String expectedString, ByteBuffer actualBuffer)
{
String actualString = BufferUtil.toString(actualBuffer);
Assert.assertThat(message,actualString,is(expectedString));
assertThat(message,actualString,is(expectedString));
}
public static void assertSize(String message, int expectedSize, ByteBuffer buffer)
@ -56,6 +63,6 @@ public class ByteBufferAssert
{
return;
}
Assert.assertThat(message + " buffer.remaining",buffer.remaining(),is(expectedSize));
assertThat(message + " buffer.remaining",buffer.remaining(),is(expectedSize));
}
}

View File

@ -16,20 +16,17 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.server;
package org.eclipse.jetty.websocket.common.test;
import java.net.URI;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.Generator;
/**
* Convenience Generator.
*/
public class UnitGenerator extends Generator
public interface Fuzzed
{
public UnitGenerator()
{
super(WebSocketPolicy.newServerPolicy(),new MappedByteBufferPool());
}
URI getServerURI();
Generator getLaxGenerator();
String getTestMethodName();
}

View File

@ -16,10 +16,9 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.server.ab;
package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;
import java.io.IOException;
import java.net.SocketException;
@ -40,9 +39,6 @@ import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.io.IOState;
import org.eclipse.jetty.websocket.server.ByteBufferAssert;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
import org.junit.Assert;
/**
@ -87,7 +83,7 @@ public class Fuzzer
private SendMode sendMode = SendMode.BULK;
private int slowSendSegmentSize = 5;
public Fuzzer(AbstractABCase testcase) throws Exception
public Fuzzer(Fuzzed testcase) throws Exception
{
WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();
@ -97,9 +93,9 @@ public class Fuzzer
policy.setMaxBinaryMessageSize(bigMessageSize);
policy.setIdleTimeout(5000);
this.client = new BlockheadClient(policy,testcase.getServer().getServerUri());
this.client = new BlockheadClient(policy,testcase.getServerURI());
this.generator = testcase.getLaxGenerator();
this.testname = testcase.testname.getMethodName();
this.testname = testcase.getTestMethodName();
}
public ByteBuffer asNetworkBuffer(List<WebSocketFrame> send)

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.server.blockhead;
package org.eclipse.jetty.websocket.common.test;
import java.nio.ByteBuffer;
import java.util.Map;

View File

@ -16,10 +16,9 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.server.helper;
package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;
import java.util.Queue;
@ -47,6 +46,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());
int i = 0;
for (Frame frame : frames)
{
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));
}
@ -62,17 +74,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 clear()
@ -138,6 +151,8 @@ public class IncomingFramesCapture implements IncomingFrames
public void incomingFrame(Frame frame)
{
WebSocketFrame copy = WebSocketFrame.copy(frame);
// TODO: might need to make this optional (depending on use by client vs server tests)
// Assert.assertThat("frame.masking must be set",frame.isMasked(),is(true));
frames.add(copy);
}

View File

@ -16,10 +16,9 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;
import java.util.LinkedList;
@ -27,6 +26,8 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.junit.Assert;
public class OutgoingFramesCapture implements OutgoingFrames

View File

@ -16,10 +16,9 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.*;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@ -31,6 +30,7 @@ import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
import org.eclipse.jetty.websocket.common.Generator;
import org.junit.Assert;
/**

View File

@ -16,9 +16,9 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;
import java.nio.ByteBuffer;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
package org.eclipse.jetty.websocket.common.test;
import java.nio.ByteBuffer;
import java.util.List;
@ -27,6 +27,8 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
/**
* Convenience Generator.

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
package org.eclipse.jetty.websocket.common.test;
import java.nio.ByteBuffer;
@ -24,6 +24,7 @@ import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.Parser;
public class UnitParser extends Parser
{

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
package org.eclipse.jetty.websocket.common.util;
import java.nio.ByteBuffer;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.common;
package org.eclipse.jetty.websocket.common.util;
import java.nio.ByteBuffer;

View File

@ -16,7 +16,7 @@
// ========================================================================
//
package org.eclipse.jetty.websocket.jsr356.server;
package org.eclipse.jetty.websocket.common.util;
import java.io.IOException;
import java.io.PrintWriter;

View File

@ -17,16 +17,17 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>tests-jar</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>artifact-jars</id>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
@ -68,6 +69,13 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>

View File

@ -35,9 +35,9 @@ import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.common.test.BlockheadClient;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.server.examples.echo.BigEchoSocket;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
import org.junit.AfterClass;
import org.junit.Assert;

View File

@ -1,85 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.server;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import java.nio.ByteBuffer;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.server.helper.Hex;
import org.junit.Assert;
public class ByteBufferAssert
{
public static void assertEquals(String message, byte[] expected, byte[] actual)
{
if (expected.length <= 200)
{
// Simple comparison (useful for clear error messages)
String actualHex = Hex.asHex(actual);
String expectedHex = Hex.asHex(expected);
Assert.assertThat(message + " bytes", actualHex, is(expectedHex));
}
else
{
// Big byte buffers are checked byte for byte
Assert.assertThat(message + " byte[].length",actual.length,is(expected.length));
int len = expected.length;
for (int i = 0; i < len; i++)
{
Assert.assertThat(message + " byte[" + i + "]",actual[i],is(expected[i]));
}
}
}
public static void assertEquals(String message, byte[] expectedBytes, ByteBuffer actualBuffer)
{
byte actualBytes[] = BufferUtil.toArray(actualBuffer);
assertEquals(message,expectedBytes,actualBytes);
}
public static void assertEquals(String message, ByteBuffer expectedBuffer, ByteBuffer actualBuffer)
{
if (expectedBuffer == null)
{
Assert.assertThat(message,actualBuffer,nullValue());
return;
}
byte expectedBytes[] = BufferUtil.toArray(expectedBuffer);
byte actualBytes[] = BufferUtil.toArray(actualBuffer);
assertEquals(message,expectedBytes,actualBytes);
}
public static void assertEquals(String message, String expectedString, ByteBuffer actualBuffer)
{
String actualString = BufferUtil.toString(actualBuffer);
Assert.assertThat(message,expectedString,is(actualString));
}
public static void assertSize(String message, int expectedSize, ByteBuffer buffer)
{
if ((expectedSize == 0) && (buffer == null))
{
return;
}
Assert.assertThat(message + " buffer.remaining",buffer.remaining(),is(expectedSize));
}
}

View File

@ -18,17 +18,16 @@
package org.eclipse.jetty.websocket.server;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.blockhead.HttpResponse;
import org.eclipse.jetty.websocket.common.test.BlockheadClient;
import org.eclipse.jetty.websocket.common.test.HttpResponse;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.server.examples.MyEchoServlet;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;

View File

@ -18,15 +18,15 @@
package org.eclipse.jetty.websocket.server;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.common.test.BlockheadClient;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.server.examples.MyEchoServlet;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;

View File

@ -18,17 +18,16 @@
package org.eclipse.jetty.websocket.server;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.blockhead.HttpResponse;
import org.eclipse.jetty.websocket.common.test.BlockheadClient;
import org.eclipse.jetty.websocket.common.test.HttpResponse;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.server.helper.EchoServlet;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;

Some files were not shown because too many files have changed in this diff Show More