Merge branch 'jetty-9.4.x' of github.com:eclipse/jetty.project into jetty-9.4.x

This commit is contained in:
WalkerWatch 2017-09-06 17:12:11 -04:00
commit bd4eb6655b
32 changed files with 125 additions and 176 deletions

View File

@ -97,10 +97,6 @@ public class DelayedStartClientTest
QueuedThreadPool qtp = (QueuedThreadPool) executor;
threadNames.add(qtp.getName());
}
else
{
System.err.println("### Executor: " + executor);
}
}
for (ContainerLifeCycle child : container.getBeans(ContainerLifeCycle.class))

View File

@ -52,7 +52,6 @@ public class TimeDecoder implements Decoder.Text<Date>
@Override
public void init(EndpointConfig config)
{
System.out.println("#### INIT ####");
}
@Override

View File

@ -27,12 +27,13 @@ import java.util.Queue;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.jsr356.server.samples.echo.BasicEchoSocket;
import org.junit.Assert;
import org.junit.Rule;
@ -47,8 +48,7 @@ public class AltFilterTest
@Rule
public TestingDir testdir = new TestingDir();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@Test
public void testEcho() throws Exception

View File

@ -26,12 +26,13 @@ import java.util.Queue;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.jsr356.server.samples.beans.DateDecoder;
import org.eclipse.jetty.websocket.jsr356.server.samples.beans.TimeEncoder;
import org.eclipse.jetty.websocket.jsr356.server.samples.echo.ConfiguredEchoSocket;
@ -47,8 +48,7 @@ import org.junit.Test;
*/
public class AnnotatedServerEndpointTest
{
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private static WSServer server;

View File

@ -23,11 +23,12 @@ import java.util.Queue;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.jsr356.server.samples.echo.BasicEchoEndpoint;
import org.eclipse.jetty.websocket.jsr356.server.samples.echo.BasicEchoEndpointConfigContextListener;
import org.junit.Assert;
@ -43,8 +44,7 @@ public class BasicEndpointTest
@Rule
public TestingDir testdir = new TestingDir();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@Test
public void testEcho() throws Exception

View File

@ -380,10 +380,6 @@ public class DelayedStartClientOnServerTest
QueuedThreadPool qtp = (QueuedThreadPool) executor;
threadNames.add(qtp.getName());
}
else
{
System.err.println("### Executor: " + executor);
}
}
for (ContainerLifeCycle child : container.getBeans(ContainerLifeCycle.class))

View File

@ -25,11 +25,12 @@ import java.util.Queue;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.jsr356.server.samples.echo.LargeEchoConfiguredSocket;
import org.junit.Assert;
import org.junit.Ignore;
@ -45,8 +46,7 @@ public class LargeAnnotatedTest
@Rule
public TestingDir testdir = new TestingDir();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@Test
public void testEcho() throws Exception

View File

@ -25,11 +25,12 @@ import java.util.Queue;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.jsr356.server.samples.echo.LargeEchoDefaultSocket;
import org.junit.Assert;
import org.junit.Ignore;
@ -45,8 +46,7 @@ public class LargeContainerTest
@Rule
public TestingDir testdir = new TestingDir();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@Test
public void testEcho() throws Exception

View File

@ -23,11 +23,12 @@ import java.util.Queue;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.jsr356.server.samples.echo.EchoReturnEndpoint;
import org.junit.Assert;
import org.junit.Rule;
@ -38,8 +39,7 @@ public class OnMessageReturnTest
@Rule
public TestingDir testdir = new TestingDir();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@Test
public void testEchoReturn() throws Exception

View File

@ -29,16 +29,16 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -47,9 +47,9 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class SessionTest
{
private static interface Case
private interface Case
{
public void customize(WebAppContext context);
void customize(WebAppContext context);
}
@Parameters
@ -98,8 +98,7 @@ public class SessionTest
return cases;
}
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private final Case testcase;
private final static AtomicInteger ID = new AtomicInteger(0);

View File

@ -50,6 +50,8 @@ import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import javax.websocket.server.ServerEndpointConfig;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
@ -58,7 +60,6 @@ import org.eclipse.jetty.toolchain.test.IO;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.common.util.Sha1Sum;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
import org.junit.AfterClass;
@ -71,8 +72,7 @@ public class StreamTest
{
private static final Logger LOG = Log.getLogger(StreamTest.class);
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private static File outputDir;
private static Server server;

View File

@ -205,9 +205,15 @@ public class WebSocketPolicy
}
/**
* Get the maximum size of a binary message during parsing/generating.
* Get the maximum size of a binary message during parsing.
* <p>
* Binary messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
* This is a memory conservation option, memory over this limit will not be
* allocated by Jetty for handling binary messages. This applies to individual frames,
* whole message handling, and partial message handling.
* </p>
* <p>
* Binary messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
* </p>
*
* @return the maximum size of a binary message
*/
@ -227,9 +233,15 @@ public class WebSocketPolicy
}
/**
* Get the maximum size of a text message during parsing/generating.
* Get the maximum size of a text message during parsing.
* <p>
* Text messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
* This is a memory conservation option, memory over this limit will not be
* allocated by Jetty for handling text messages. This applies to individual frames,
* whole message handling, and partial message handling.
* </p>
* <p>
* Text messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
* </p>
*
* @return the maximum size of a text message.
*/
@ -279,7 +291,7 @@ public class WebSocketPolicy
/**
* The maximum size of a binary message buffer.
* <p>
* Used ONLY for stream based message writing.
* Used ONLY for stream based binary message writing.
*
* @param size
* the maximum size of the binary message buffer
@ -292,9 +304,15 @@ public class WebSocketPolicy
}
/**
* The maximum size of a binary message during parsing/generating.
* The maximum size of a binary message during parsing.
* <p>
* Binary messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
* This is a memory conservation option, memory over this limit will not be
* allocated by Jetty for handling binary messages. This applies to individual frames,
* whole message handling, and partial message handling.
* </p>
* <p>
* Binary messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
* </p>
*
* @param size
* the maximum allowed size of a binary message.
@ -309,7 +327,7 @@ public class WebSocketPolicy
/**
* The maximum size of a text message buffer.
* <p>
* Used ONLY for stream based message writing.
* Used ONLY for stream based text message writing.
*
* @param size
* the maximum size of the text message buffer
@ -322,9 +340,15 @@ public class WebSocketPolicy
}
/**
* The maximum size of a text message during parsing/generating.
* The maximum size of a text message during parsing.
* <p>
* Text messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
* This is a memory conservation option, memory over this limit will not be
* allocated by Jetty for handling text messages. This applies to individual frames,
* whole message handling, and partial message handling.
* </p>
* <p>
* Text messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}
* </p>
*
* @param size
* the maximum allowed size of a text message.

View File

@ -22,12 +22,13 @@ import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
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.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@ -41,8 +42,7 @@ public class BadNetworkTest
@Rule
public TestTracker tt = new TestTracker();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private BlockheadServer server;
private WebSocketClient client;

View File

@ -37,13 +37,14 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
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.common.AcceptHash;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.Assert;
@ -60,8 +61,7 @@ public class ClientConnectTest
@Rule
public TestTracker tt = new TestTracker();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private final int timeout = 500;
private BlockheadServer server;

View File

@ -29,12 +29,13 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.jetty.io.LeakTrackingByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
/**
* This is not a general purpose websocket client. It's only for testing the websocket server and is hardwired to a specific draft version of the protocol.
@ -96,7 +97,7 @@ public class TestClient
private static final Random __random = new Random();
private static LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("TestClient");
private static LeakTrackingByteBufferPool bufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool());
private final String _host;
private final int _port;
@ -253,7 +254,6 @@ public class TestClient
wsclient.stop();
}
bufferPool.assertNoLeaks();
}
private static void usage(String[] args)

View File

@ -264,7 +264,7 @@ public abstract class CompressExtension extends AbstractExtension
private static boolean supplyInput(Inflater inflater, ByteBuffer buf)
{
if (buf.remaining() <= 0)
if (buf == null || buf.remaining() <= 0)
{
if (LOG.isDebugEnabled())
{
@ -304,7 +304,7 @@ public abstract class CompressExtension extends AbstractExtension
private static boolean supplyInput(Deflater deflater, ByteBuffer buf)
{
if (buf.remaining() <= 0)
if (buf == null || buf.remaining() <= 0)
{
if (LOG.isDebugEnabled())
{
@ -457,6 +457,10 @@ public abstract class CompressExtension extends AbstractExtension
// the heap if the payload is a huge mapped file.
Frame frame = entry.frame;
ByteBuffer data = frame.getPayload();
if(data == null)
data = BufferUtil.EMPTY_BUFFER;
int remaining = data.remaining();
int outputLength = Math.max(256,data.remaining());
if (LOG.isDebugEnabled())

View File

@ -23,19 +23,18 @@ import static org.hamcrest.Matchers.is;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.eclipse.jetty.io.ByteBufferPool;
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.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
public class GeneratorParserRoundtripTest
{
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("GeneratorParserRoundtrip");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@Test
public void testParserAndGenerator() throws Exception

View File

@ -22,6 +22,8 @@ import static org.hamcrest.Matchers.is;
import java.nio.ByteBuffer;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
@ -29,17 +31,14 @@ 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.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.common.util.Hex;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
public class WebSocketFrameTest
{
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("WebSocketFrameTest");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private Generator strictGenerator;
private Generator laxGenerator;

View File

@ -23,8 +23,9 @@ import static org.hamcrest.Matchers.containsString;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.websocket.common.io.LocalWebSocketConnection;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.Assert;
import org.junit.Rule;
@ -36,8 +37,7 @@ public class WebSocketRemoteEndpointTest
@Rule
public TestName testname = new TestName();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("WebSocketRemoteEndpoint");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@Test
public void testTextBinaryText() throws IOException

View File

@ -21,6 +21,8 @@ package org.eclipse.jetty.websocket.common.events;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketException;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
@ -34,7 +36,6 @@ import org.eclipse.jetty.websocket.common.io.CloseableLocalWebSocketSession;
import org.eclipse.jetty.websocket.common.io.LocalWebSocketSession;
import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -53,8 +54,7 @@ public class EventDriverTest
@Rule
public TestName testname = new TestName();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private WebSocketContainerScope container;

View File

@ -18,8 +18,9 @@
package org.eclipse.jetty.websocket.common.extensions;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
@ -28,9 +29,8 @@ public abstract class AbstractExtensionTest
{
@Rule
public TestName testname = new TestName();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
protected ExtensionTool clientExtensions;
protected ExtensionTool serverExtensions;

View File

@ -23,6 +23,8 @@ import static org.hamcrest.Matchers.is;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
@ -31,17 +33,14 @@ import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.common.extensions.identity.IdentityExtension;
import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
public class ExtensionStackTest
{
private static final Logger LOG = Log.getLogger(ExtensionStackTest.class);
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@SuppressWarnings("unchecked")
private <T> T assertIsExtension(String msg, Object obj, Class<T> clazz)

View File

@ -27,6 +27,8 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
@ -40,16 +42,13 @@ 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.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
public class FragmentExtensionTest
{
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
/**
* Verify that incoming frames are passed thru without modification

View File

@ -32,6 +32,8 @@ import java.util.Random;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.io.RuntimeIOException;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.StringUtil;
@ -55,19 +57,16 @@ import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
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.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.common.test.OutgoingNetworkBytesCapture;
import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
public class DeflateFrameExtensionTest extends AbstractExtensionTest
{
private static final Logger LOG = Log.getLogger(DeflateFrameExtensionTest.class);
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private void assertIncoming(byte[] raw, String... expectedTextDatas)
{
@ -313,6 +312,7 @@ public class DeflateFrameExtensionTest extends AbstractExtensionTest
ext.setNextOutgoingFrames(capture);
ext.outgoingFrame(new TextFrame().setPayload("Hello"), null, BatchMode.OFF);
ext.outgoingFrame(new TextFrame(), null, BatchMode.OFF);
ext.outgoingFrame(new TextFrame().setPayload("There"), null, BatchMode.OFF);
capture.assertBytes(0, "c107f248cdc9c90700");

View File

@ -19,7 +19,7 @@
package org.eclipse.jetty.websocket.common.extensions.compress;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -27,6 +27,8 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.websocket.api.BatchMode;
@ -42,10 +44,8 @@ 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.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
/**
@ -55,8 +55,7 @@ import org.junit.Test;
*/
public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
{
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private void assertEndsWithTail(String hexStr, boolean expectedResult)
{

View File

@ -27,8 +27,9 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@ -39,8 +40,7 @@ public class MessageInputStreamTest
@Rule
public TestName testname = new TestName();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@Test(timeout=10000)
public void testBasicAppendRead() throws IOException

View File

@ -24,6 +24,8 @@ import static org.hamcrest.Matchers.is;
import java.util.Arrays;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -35,7 +37,6 @@ import org.eclipse.jetty.websocket.common.io.FramePipes;
import org.eclipse.jetty.websocket.common.io.LocalWebSocketSession;
import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -53,8 +54,7 @@ public class MessageOutputStreamTest
@Rule
public TestName testname = new TestName();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private WebSocketPolicy policy;
private TrackingSocket socket;

View File

@ -22,6 +22,8 @@ import static org.hamcrest.Matchers.is;
import java.util.Arrays;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -33,7 +35,6 @@ import org.eclipse.jetty.websocket.common.io.FramePipes;
import org.eclipse.jetty.websocket.common.io.LocalWebSocketSession;
import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -51,8 +52,7 @@ public class MessageWriterTest
@Rule
public TestName testname = new TestName();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private WebSocketPolicy policy;
private TrackingSocket socket;

View File

@ -1,61 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2017 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.test;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import org.eclipse.jetty.io.LeakTrackingByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
public class LeakTrackingBufferPoolRule extends LeakTrackingByteBufferPool implements TestRule
{
private final String id;
public LeakTrackingBufferPoolRule(String id)
{
super(new MappedByteBufferPool.Tagged());
this.id = id;
}
public void assertNoLeaks()
{
assertThat("Leaked Acquires Count for [" + id + "]",getLeakedAcquires(),is(0L));
assertThat("Leaked Releases Count for [" + id + "]",getLeakedReleases(),is(0L));
assertThat("Leaked Resource Count for [" + id + "]", getLeakedResources(),is(0L));
}
@Override
public Statement apply(final Statement statement, Description description)
{
return new Statement()
{
@Override
public void evaluate() throws Throwable
{
clearTracking();
statement.evaluate();
assertNoLeaks();
}
};
}
}

View File

@ -34,13 +34,12 @@ import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.BlockheadClient;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.server.examples.MyEchoServlet;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.Test;
/**
* Test simulating a client that talks too quickly.
@ -85,7 +84,7 @@ public class TooFastClientTest
// Add text frames
Generator generator = new Generator(WebSocketPolicy.newClientPolicy(),
new LeakTrackingBufferPoolRule("Generator"));
new MappedByteBufferPool());
String msg1 = "Echo 1";
String msg2 = "This is also an echooooo!";

View File

@ -19,20 +19,19 @@
package org.eclipse.jetty.websocket.server;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.toolchain.test.EventQueue;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.server.helper.CaptureSocket;
import org.eclipse.jetty.websocket.server.helper.SessionServlet;
import org.junit.AfterClass;
@ -47,9 +46,8 @@ public class WebSocketOverSSLTest
public static final int FUTURE_TIMEOUT_SEC = 30;
@Rule
public TestTracker tracker = new TestTracker();
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
private static SimpleServletServer server;

View File

@ -22,6 +22,8 @@ import java.net.URI;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.StacklessLogging;
@ -31,7 +33,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.test.Fuzzed;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.eclipse.jetty.websocket.common.test.RawFrameBuilder;
import org.eclipse.jetty.websocket.server.SimpleServletServer;
import org.junit.AfterClass;
@ -79,8 +80,7 @@ public abstract class AbstractABCase implements Fuzzed
protected Generator laxGenerator;
protected static SimpleServletServer server;
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
public ByteBufferPool bufferPool = new MappedByteBufferPool();
@Before
public void initGenerators()