From 96b5c05674e16d335db78d40e0983aad791cf163 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 2 Aug 2012 11:51:54 +1000 Subject: [PATCH] jetty-9 one connector passing most tests --- .../eclipse/jetty/embedded/LikeJettyXml.java | 18 ++++--- .../jetty/embedded/ManyConnectors.java | 10 ++-- .../eclipse/jetty/embedded/ManyContexts.java | 4 +- .../jetty/embedded/ManyServletContexts.java | 1 - .../org/eclipse/jetty/embedded/OneWebApp.java | 4 +- .../jetty/embedded/GzipHandlerTest.java | 9 ++-- .../jetty/io/AbstractAsyncConnection.java | 2 +- .../org/eclipse/jetty/io/ChannelEndPoint.java | 1 - .../eclipse/jetty/io/ssl/SslConnection.java | 8 ++-- .../jetty/io/AsyncByteArrayEndPointTest.java | 14 +++--- .../SelectChannelEndPointInterestsTest.java | 7 +++ .../io/SelectChannelEndPointSslTest.java | 17 +++---- .../jetty/io/SelectChannelEndPointTest.java | 19 +++++--- .../eclipse/jetty/io/SslConnectionTest.java | 14 +++++- .../eclipse/jetty/io/WriteFlusherTest.java | 2 +- .../org/eclipse/jetty/jmx/ObjectMBean.java | 3 -- .../eclipse/jetty/jmx/ObjectMBeanTest.java | 3 -- .../jetty/security/SpnegoLoginService.java | 1 + .../authentication/FormAuthenticator.java | 1 + .../jetty/security/DataConstraintsTest.java | 13 ++--- .../jetty/server/AbstractConnector.java | 30 ++++++------ .../jetty/server/AbstractNetConnector.java | 2 +- .../org/eclipse/jetty/server/HttpChannel.java | 3 +- .../jetty/server/HttpChannelState.java | 1 + .../jetty/server/HttpConfiguration.java | 3 -- .../eclipse/jetty/server/HttpConnection.java | 9 +++- .../eclipse/jetty/server/LocalConnector.java | 47 ++++++++++++++++-- .../jetty/server/SelectChannelConnector.java | 1 - .../jetty/server/ssl/SslConnector.java | 1 - .../server/ssl/SslSelectChannelConnector.java | 13 ----- .../jetty/server/ConnectorCloseTestBase.java | 5 +- .../jetty/server/HttpConnectionTest.java | 48 +++++++++++++------ .../eclipse/jetty/server/HttpWriterTest.java | 4 +- .../org/eclipse/jetty/server/RFC2616Test.java | 21 ++++---- .../org/eclipse/jetty/server/RequestTest.java | 19 +++++++- .../eclipse/jetty/server/ResponseTest.java | 18 +++++-- .../server/SelectChannelStatisticsTest.java | 7 +-- .../SlowClientWithPipelinedRequestTest.java | 1 - .../handler/ContextHandlerCollectionTest.java | 2 +- .../server/handler/ContextHandlerTest.java | 4 +- .../jetty/server/ssl/SSLCloseTest.java | 5 -- .../jetty/server/ssl/SSLEngineTest.java | 37 ++++++++++++-- .../SSLSelectChannelConnectorLoadTest.java | 1 - .../jetty/server/ssl/SslBytesServerTest.java | 4 -- .../jetty/server/ssl/SslUploadTest.java | 1 - .../eclipse/jetty/servlet/DefaultServlet.java | 10 ++-- .../eclipse/jetty/servlet/FilterHolder.java | 1 - .../eclipse/jetty/servlet/FilterMapping.java | 1 + .../eclipse/jetty/servlet/ServletHandler.java | 1 + .../eclipse/jetty/servlet/ServletHolder.java | 2 +- .../eclipse/jetty/servlet/ServletTester.java | 8 ---- .../AsyncContextDispatchWithQueryStrings.java | 7 +-- .../jetty/servlet/AsyncContextTest.java | 12 +++-- .../jetty/servlet/DefaultServletTest.java | 1 + .../eclipse/jetty/servlet/DispatcherTest.java | 1 - .../org/eclipse/jetty/servlet/HolderTest.java | 13 +++-- .../jetty/servlet/ResponseHeadersTest.java | 3 +- .../jetty/servlets/CrossOriginFilter.java | 1 + .../org/eclipse/jetty/servlets/DoSFilter.java | 2 - .../eclipse/jetty/servlets/GzipFilter.java | 2 +- .../jetty/servlets/IncludableGzipFilter.java | 2 +- .../jetty/servlets/MultiPartFilter.java | 1 + .../jetty/servlets/UserAgentFilter.java | 1 + .../jetty/servlets/AbstractDoSFilterTest.java | 1 + .../servlets/GzipFilterContentLengthTest.java | 1 + .../servlets/GzipWithPipeliningTest.java | 2 +- .../servlets/IncludableGzipFilterTest.java | 1 - .../jetty/servlets/MultipartFilterTest.java | 9 +--- .../jetty/servlets/PipelineHelper.java | 4 +- .../eclipse/jetty/servlets/PutFilterTest.java | 6 +-- .../eclipse/jetty/servlets/QoSFilterTest.java | 4 +- .../jetty/servlets/gzip/GzipTester.java | 7 ++- .../eclipse/jetty/util/annotation/Name.java | 2 +- .../jetty/util/ssl/SslContextFactory.java | 2 - .../jetty/util/ssl/SslContextFactoryTest.java | 10 ++-- .../webapp/StandardDescriptorProcessor.java | 10 ---- .../eclipse/jetty/webapp/WebAppContext.java | 2 - .../io/WebSocketClientSelectorManager.java | 2 +- .../io/WebSocketAsyncConnection.java | 7 +++ .../server/WebSocketServerFactory.java | 2 +- .../websocket/server/SimpleServletServer.java | 2 +- .../server/WebSocketLoadRFC6455Test.java | 10 ++-- .../server/WebSocketOverSSLTest.java | 3 +- .../examples/echo/ExampleEchoServer.java | 2 +- .../jetty/xml/XmlConfigurationTest.java | 15 +++--- .../continuation/test/ContinuationBase.java | 6 ++- .../jetty/continuation/ContinuationTest.java | 7 ++- .../continuation/FauxContinuationTest.java | 7 +-- .../src/main/java/com/acme/Dump.java | 2 - .../java/com/acme/WebSocketChatServlet.java | 5 +- .../java/org/eclipse/jetty/TestServer.java | 4 +- 91 files changed, 360 insertions(+), 282 deletions(-) diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java index 7a92cd30456..443a26dd3fd 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java @@ -30,7 +30,6 @@ import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.RequestLogHandler; import org.eclipse.jetty.server.handler.StatisticsHandler; -import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; @@ -42,7 +41,11 @@ public class LikeJettyXml String jetty_home = System.getProperty("jetty.home","../jetty-distribution/target/distribution"); System.setProperty("jetty.home",jetty_home); - Server server = new Server(); + // Setup Threadpool + QueuedThreadPool threadPool = new QueuedThreadPool(); + threadPool.setMaxThreads(500); + + Server server = new Server(threadPool); server.setDumpAfterStart(true); server.setDumpBeforeStop(true); @@ -53,22 +56,17 @@ public class LikeJettyXml server.addBean(mbContainer,true); mbContainer.addBean(new Log()); - // Setup Threadpool - QueuedThreadPool threadPool = new QueuedThreadPool(); - threadPool.setMaxThreads(500); - server.setThreadPool(threadPool); - // Setup Connectors - SelectChannelConnector connector = new SelectChannelConnector(); + SelectChannelConnector connector = new SelectChannelConnector(server); connector.setPort(8080); connector.setIdleTimeout(30000); - connector.setConfidentialPort(8443); + connector.getHttpConfig().setConfidentialPort(8443); // TODO connector.setStatsOn(false); server.setConnectors(new Connector[] { connector }); - SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector(); + SelectChannelConnector ssl_connector = new SelectChannelConnector(server,true); ssl_connector.setPort(8443); SslContextFactory cf = ssl_connector.getSslContextFactory(); cf.setKeyStorePath(jetty_home + "/etc/keystore"); diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java index 3e8a1172183..44898a59cd5 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java @@ -16,9 +16,7 @@ package org.eclipse.jetty.embedded; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.eclipse.jetty.util.thread.QueuedThreadPool; /* ------------------------------------------------------------ */ /** @@ -31,18 +29,16 @@ public class ManyConnectors { Server server = new Server(); - SelectChannelConnector connector0 = new SelectChannelConnector(); + SelectChannelConnector connector0 = new SelectChannelConnector(server); connector0.setPort(8080); connector0.setIdleTimeout(30000); - connector0.setRequestHeaderSize(8192); - SelectChannelConnector connector1 = new SelectChannelConnector(); + SelectChannelConnector connector1 = new SelectChannelConnector(server); connector1.setHost("127.0.0.1"); connector1.setPort(8888); - connector1.setExecutor(new QueuedThreadPool(20)); connector1.setName("admin"); - SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector(); + SelectChannelConnector ssl_connector = new SelectChannelConnector(server,true); String jetty_home = System.getProperty("jetty.home","../jetty-distribution/target/distribution"); System.setProperty("jetty.home",jetty_home); ssl_connector.setPort(8443); diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java index 5de4e6e1436..d2c64473174 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyContexts.java @@ -15,10 +15,10 @@ package org.eclipse.jetty.embedded; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Handler; +import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandlerCollection; -import org.eclipse.jetty.server.SelectChannelConnector; /* ------------------------------------------------------------ */ /** @@ -37,7 +37,7 @@ public class ManyContexts public static void main(String[] args) throws Exception { Server server = new Server(); - SelectChannelConnector connector = new SelectChannelConnector(); + SelectChannelConnector connector = new SelectChannelConnector(server); connector.setPort(8080); server.setConnectors(new Connector[] { connector }); diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyServletContexts.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyServletContexts.java index 8b6491b4d93..7f7aa60822b 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyServletContexts.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyServletContexts.java @@ -23,7 +23,6 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; -import org.eclipse.jetty.util.log.Log; public class ManyServletContexts { diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java index dd44605cd2c..63bfa4278da 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java @@ -14,8 +14,8 @@ package org.eclipse.jetty.embedded; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.SelectChannelConnector; +import org.eclipse.jetty.server.Server; import org.eclipse.jetty.webapp.WebAppContext; public class OneWebApp @@ -24,7 +24,7 @@ public class OneWebApp { Server server = new Server(); - SelectChannelConnector connector = new SelectChannelConnector(); + SelectChannelConnector connector = new SelectChannelConnector(server); connector.setPort(Integer.getInteger("jetty.port",8080).intValue()); server.setConnectors(new Connector[] { connector }); diff --git a/example-jetty-embedded/src/test/java/org/eclipse/jetty/embedded/GzipHandlerTest.java b/example-jetty-embedded/src/test/java/org/eclipse/jetty/embedded/GzipHandlerTest.java index 514441fcac2..333b5f460d0 100644 --- a/example-jetty-embedded/src/test/java/org/eclipse/jetty/embedded/GzipHandlerTest.java +++ b/example-jetty-embedded/src/test/java/org/eclipse/jetty/embedded/GzipHandlerTest.java @@ -27,13 +27,13 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.server.Handler; -import org.eclipse.jetty.server.LocalHttpConnector; +import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.handler.GzipHandler; -import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.util.IO; import org.junit.After; import org.junit.Before; @@ -56,14 +56,13 @@ public class GzipHandlerTest "et cursus magna. Donec orci enim, molestie a lobortis eu, imperdiet vitae neque."; private Server _server; - private LocalHttpConnector _connector; + private LocalConnector _connector; @Before public void init() throws Exception { _server = new Server(); - - _connector = new LocalHttpConnector(); + _connector = new LocalConnector(_server); _server.addConnector(_connector); Handler testHandler = new AbstractHandler() diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractAsyncConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractAsyncConnection.java index d50e60761ef..3fc4981137e 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractAsyncConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractAsyncConnection.java @@ -130,12 +130,12 @@ public abstract class AbstractAsyncConnection implements AsyncConnection public void onOpen() { LOG.debug("{} opened",this); - fillInterested(); } @Override public void onClose() { + LOG.debug("{} closed",this); } @Override diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java index 94a4c6f2db0..1aebec2784a 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ChannelEndPoint.java @@ -23,7 +23,6 @@ import java.nio.channels.ByteChannel; import java.nio.channels.ClosedChannelException; import java.nio.channels.GatheringByteChannel; import java.nio.channels.SocketChannel; -import java.util.concurrent.BrokenBarrierException; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.log.Log; diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java index ab7f45456bf..9edc472aa8f 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.concurrent.Executor; + import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLEngineResult; import javax.net.ssl.SSLEngineResult.HandshakeStatus; @@ -28,7 +29,6 @@ import org.eclipse.jetty.io.AbstractEndPoint; import org.eclipse.jetty.io.AsyncConnection; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.ByteBufferPool; -import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.ReadInterest; import org.eclipse.jetty.io.RuntimeIOException; @@ -45,7 +45,7 @@ import org.eclipse.jetty.util.log.Logger; * wants unencrypted data. *

* The connector uses an {@link AsyncEndPoint} (typically {@link SelectChannelEndPoint}) as - * it's source/sink of encrypted data. It then provides an endpoint via {@link #getSslEndPoint()} to + * it's source/sink of encrypted data. It then provides an endpoint via {@link #getDecryptedEndPoint()} to * expose a source/sink of unencrypted data to another connection (eg HttpConnection). *

* The design of this class is based on a clear separation between the passive methods, which do not block nor schedule any @@ -95,7 +95,7 @@ public class SslConnection extends AbstractAsyncConnection return _sslEngine; } - public AsyncEndPoint getSslEndPoint() + public AsyncEndPoint getDecryptedEndPoint() { return _decryptedEndPoint; } @@ -112,6 +112,8 @@ public class SslConnection extends AbstractAsyncConnection if (_sslEngine.getUseClientMode()) _decryptedEndPoint.write(null, new Callback.Empty<>(), BufferUtil.EMPTY_BUFFER); + + getDecryptedEndPoint().getAsyncConnection().onOpen(); } catch (SSLException x) { diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/AsyncByteArrayEndPointTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/AsyncByteArrayEndPointTest.java index 7a99925c715..23d9b6b7e60 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/AsyncByteArrayEndPointTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/AsyncByteArrayEndPointTest.java @@ -1,5 +1,12 @@ package org.eclipse.jetty.io; +import static junit.framework.Assert.assertEquals; +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.nio.ByteBuffer; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; @@ -13,13 +20,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import static junit.framework.Assert.assertEquals; -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - public class AsyncByteArrayEndPointTest { private ScheduledExecutorService _scheduler; diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointInterestsTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointInterestsTest.java index 94885e2798a..617b2ca26e8 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointInterestsTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointInterestsTest.java @@ -80,6 +80,13 @@ public class SelectChannelEndPointInterestsTest { return new AbstractAsyncConnection(endPoint, threadPool) { + @Override + public void onOpen() + { + super.onOpen(); + fillInterested(); + } + @Override public void onFillable() { diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java index 39030aca8cd..e718498da51 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java @@ -1,5 +1,11 @@ package org.eclipse.jetty.io; +import static org.hamcrest.Matchers.greaterThan; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -7,6 +13,7 @@ import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; import java.util.concurrent.TimeUnit; + import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLEngineResult; import javax.net.ssl.SSLEngineResult.HandshakeStatus; @@ -21,12 +28,6 @@ import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; -import static org.hamcrest.Matchers.greaterThan; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest { @@ -58,8 +59,8 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest engine.setUseClientMode(false); SslConnection sslConnection = new SslConnection(__byteBufferPool, _threadPool, endpoint, engine); - AsyncConnection appConnection = super.newConnection(channel,sslConnection.getSslEndPoint()); - sslConnection.getSslEndPoint().setAsyncConnection(appConnection); + AsyncConnection appConnection = super.newConnection(channel,sslConnection.getDecryptedEndPoint()); + sslConnection.getDecryptedEndPoint().setAsyncConnection(appConnection); _manager.connectionOpened(appConnection); return sslConnection; diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java index 67d0f6e6a3d..9580c17c068 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java @@ -16,6 +16,12 @@ package org.eclipse.jetty.io; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; @@ -42,12 +48,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class SelectChannelEndPointTest { protected CountDownLatch _lastEndPointLatch; @@ -123,6 +123,13 @@ public class SelectChannelEndPointTest { super(endp, _threadPool); } + + @Override + public void onOpen() + { + super.onOpen(); + fillInterested(); + } @Override public synchronized void onFillable() diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java index 234829fa00c..434fa5a7454 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java @@ -13,10 +13,12 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; + import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLSocket; import junit.framework.Assert; + import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.BufferUtil; @@ -54,8 +56,8 @@ public class SslConnectionTest engine.setUseClientMode(false); SslConnection sslConnection = new SslConnection(__byteBufferPool, _threadPool, endpoint, engine); - AsyncConnection appConnection = new TestConnection(sslConnection.getSslEndPoint()); - sslConnection.getSslEndPoint().setAsyncConnection(appConnection); + AsyncConnection appConnection = new TestConnection(sslConnection.getDecryptedEndPoint()); + sslConnection.getDecryptedEndPoint().setAsyncConnection(appConnection); connectionOpened(appConnection); return sslConnection; @@ -112,9 +114,17 @@ public class SslConnectionTest super(endp, _threadPool); } + @Override + public void onOpen() + { + super.onOpen(); + fillInterested(); + } + @Override public void onClose() { + super.onClose(); } @Override diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java index 1a4702f1136..be02fe918f7 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java @@ -1,8 +1,8 @@ package org.eclipse.jetty.io; import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; import java.io.IOException; import java.util.concurrent.ExecutionException; diff --git a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java index e9c4389ece8..470eca528b6 100644 --- a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java +++ b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java @@ -21,14 +21,11 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Collection; -import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.Locale; import java.util.Map; import java.util.MissingResourceException; -import java.util.ResourceBundle; import java.util.Set; import javax.management.Attribute; diff --git a/jetty-jmx/src/test/java/org/eclipse/jetty/jmx/ObjectMBeanTest.java b/jetty-jmx/src/test/java/org/eclipse/jetty/jmx/ObjectMBeanTest.java index bb61b779afa..c511a9e86dd 100644 --- a/jetty-jmx/src/test/java/org/eclipse/jetty/jmx/ObjectMBeanTest.java +++ b/jetty-jmx/src/test/java/org/eclipse/jetty/jmx/ObjectMBeanTest.java @@ -15,13 +15,10 @@ package org.eclipse.jetty.jmx; import static org.junit.Assert.assertTrue; -import javax.management.AttributeNotFoundException; import javax.management.MBeanAttributeInfo; -import javax.management.MBeanException; import javax.management.MBeanInfo; import javax.management.MBeanOperationInfo; import javax.management.MBeanParameterInfo; -import javax.management.ReflectionException; import junit.framework.Assert; diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoLoginService.java index 913e97d2b2f..77583395db0 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoLoginService.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/SpnegoLoginService.java @@ -17,6 +17,7 @@ package org.eclipse.jetty.security; import java.util.Properties; + import javax.security.auth.Subject; import org.eclipse.jetty.server.UserIdentity; diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java index faaf7380efe..26196b71199 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java @@ -16,6 +16,7 @@ package org.eclipse.jetty.security.authentication; import java.io.IOException; import java.util.Collections; import java.util.Enumeration; + import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletRequest; diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/DataConstraintsTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/DataConstraintsTest.java index 90f21b3ab9b..3757f584a71 100644 --- a/jetty-security/src/test/java/org/eclipse/jetty/security/DataConstraintsTest.java +++ b/jetty-security/src/test/java/org/eclipse/jetty/security/DataConstraintsTest.java @@ -13,8 +13,12 @@ package org.eclipse.jetty.security; +import static org.junit.Assert.assertThat; +import static org.junit.matchers.JUnitMatchers.containsString; + import java.io.IOException; import java.util.Arrays; + import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -23,6 +27,7 @@ import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.security.authentication.BasicAuthenticator; import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; @@ -35,9 +40,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertThat; -import static org.junit.matchers.JUnitMatchers.containsString; - /** * @version $Revision: 1441 $ $Date: 2010-04-02 12:28:17 +0200 (Fri, 02 Apr 2010) $ */ @@ -59,9 +61,8 @@ public class DataConstraintsTest _connector.getHttpConfig().setIntegralScheme("FTP"); _connector.getHttpConfig().setConfidentialPort(9999); _connector.getHttpConfig().setConfidentialScheme("SPDY"); - _connectorS = new LocalConnector(_server) + _connectorS = new LocalConnector(_server,new HttpConfiguration(null,false) { - @Override public void customize(Request request) throws IOException { @@ -81,7 +82,7 @@ public class DataConstraintsTest { return true; } - }; + },null,null,null,null,false,0); _server.setConnectors(new Connector[]{_connector,_connectorS}); ContextHandler _context = new ContextHandler(); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java index babd6a61443..293c50ff6a4 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java @@ -74,24 +74,21 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co this(server,null); } - public AbstractConnector( - @Name("server") Server server, - @Name("sslContextFactory") SslContextFactory sslContextFactory) + public AbstractConnector(Server server,SslContextFactory sslContextFactory) { - this(server,null,null,null,sslContextFactory, sslContextFactory!=null, 0); + this(server,null,null,null,null, sslContextFactory, sslContextFactory!=null, 0); } - public AbstractConnector( - @Name("server") Server server, - @Name("ssl") boolean ssl) + public AbstractConnector(Server server,boolean ssl) { - this(server,null,null,null,ssl?new SslContextFactory():null, ssl, 0); + this(server,null,null,null,null, ssl?new SslContextFactory():null, ssl, 0); } /* ------------------------------------------------------------ */ /** * @param server The server this connector will be added to. Must not be null. + * @param httpConfig TODO * @param executor An executor for this connector or null to use the servers executor * @param scheduler A scheduler for this connector or null to use the servers scheduler * @param pool A buffer pool for this connector or null to use a default {@link ByteBufferPool} @@ -101,12 +98,12 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co */ public AbstractConnector( Server server, + HttpConfiguration httpConfig, Executor executor, - ScheduledExecutorService scheduler, + ScheduledExecutorService scheduler, ByteBufferPool pool, SslContextFactory sslContextFactory, - boolean ssl, - int acceptors) + boolean ssl, int acceptors) { _server=server; _executor=executor!=null?executor:_server.getThreadPool(); @@ -123,6 +120,9 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co _ssl=ssl; _sslContextFactory=sslContextFactory!=null?sslContextFactory:(ssl?new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH):null); + // TODO make this pluggable + _httpConfig = httpConfig!=null?httpConfig:new HttpConfiguration(_sslContextFactory,ssl); + addBean(_server,false); addBean(_executor,executor==null); addBean(_scheduler,scheduler==null); @@ -135,9 +135,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co addBean(_sslContextFactory,false); setSoLingerTime(30000); } - - // TODO make this pluggable - _httpConfig = new HttpConfiguration(_sslContextFactory,ssl); + addBean(_httpConfig,httpConfig==null); if (acceptors<=0) acceptors=Math.max(1,(Runtime.getRuntime().availableProcessors()) / 4); @@ -190,8 +188,8 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co SSLEngine engine = _sslContextFactory.createSSLEngine(endp.getRemoteAddress()); SslConnection ssl_connection = new SslConnection(getByteBufferPool(), getExecutor(), endp, engine); - AsyncConnection http_connection = new HttpConnection(_httpConfig,this,ssl_connection.getSslEndPoint()); - ssl_connection.getSslEndPoint().setAsyncConnection(http_connection); + AsyncConnection http_connection = new HttpConnection(_httpConfig,this,ssl_connection.getDecryptedEndPoint()); + ssl_connection.getDecryptedEndPoint().setAsyncConnection(http_connection); return ssl_connection; } return new HttpConnection(_httpConfig,this,endp); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNetConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNetConnector.java index b7311c04d54..3271ffa052f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNetConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNetConnector.java @@ -33,7 +33,7 @@ public abstract class AbstractNetConnector extends AbstractConnector implements public AbstractNetConnector(Server server, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool, SslContextFactory sslContextFactory, boolean ssl, int acceptors) { - super(server,executor,scheduler,pool,sslContextFactory,ssl,acceptors); + super(server,null,executor,scheduler,pool,sslContextFactory,ssl, acceptors); } public AbstractNetConnector(Server server, SslContextFactory sslContextFactory) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java index e0a29505c9a..fb96d19957f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java @@ -19,6 +19,7 @@ import java.io.PrintWriter; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.util.concurrent.ScheduledExecutorService; + import javax.servlet.DispatcherType; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; @@ -380,6 +381,7 @@ public abstract class HttpChannel { try { + _state.completed(); if (_expect100Continue) { LOG.debug("100 continues not sent"); @@ -413,7 +415,6 @@ public abstract class HttpChannel } finally { - _state.completed(); _request.setHandled(true); completed(); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java index 2e04c2df191..a5fc93ec289 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; + import javax.servlet.AsyncContext; import javax.servlet.AsyncEvent; import javax.servlet.AsyncListener; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java index 9682551b6e6..075097af7ca 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConfiguration.java @@ -2,8 +2,6 @@ package org.eclipse.jetty.server; import java.io.IOException; import java.net.InetSocketAddress; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLSession; @@ -14,7 +12,6 @@ import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.server.ssl.SslCertificates; -import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.component.AggregateLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java index 29e1dfe296a..4685c2f4651 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java @@ -308,14 +308,21 @@ public class HttpConnection extends AbstractAsyncConnection { setCurrentConnection(null); } - } + /* ------------------------------------------------------------ */ + @Override + public void onOpen() + { + super.onOpen(); + fillInterested(); + } /* ------------------------------------------------------------ */ @Override public void onClose() { + super.onClose(); _channel.onClose(); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java index 761ac1ae43d..00134d664ed 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java @@ -17,15 +17,19 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.io.AsyncByteArrayEndPoint; import org.eclipse.jetty.io.AsyncConnection; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import org.eclipse.jetty.util.ssl.SslContextFactory; public class LocalConnector extends AbstractConnector { @@ -35,10 +39,29 @@ public class LocalConnector extends AbstractConnector public LocalConnector(Server server) { - super(server,null,null,null,null, false,-1); - setIdleTimeout(30000); + super(server,null,null,null,null, null,false, -1); } + public LocalConnector(Server server, boolean ssl) + { + super(server,ssl); + } + + public LocalConnector(Server server, HttpConfiguration httpConfig, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool, + SslContextFactory sslContextFactory, boolean ssl, int acceptors) + { + super(server,httpConfig,executor,scheduler,pool,sslContextFactory,ssl, acceptors); + } + + public LocalConnector(Server server, SslContextFactory sslContextFactory) + { + super(server,sslContextFactory); + } + + { + setIdleTimeout(30000); + } + @Override public Object getTransport() { @@ -48,6 +71,9 @@ public class LocalConnector extends AbstractConnector /** Sends requests and get responses based on thread activity. * Returns all the responses received once the thread activity has * returned to the level it was before the requests. + *

+ * This methods waits until the connection is closed or + * is idle for 1s before returning the responses. * @param requests the requests * @return the responses * @throws Exception if the requests fail @@ -61,7 +87,12 @@ public class LocalConnector extends AbstractConnector /** Sends requests and get responses based on thread activity. * Returns all the responses received once the thread activity has * returned to the level it was before the requests. + *

+ * This methods waits until the connection is closed or + * an idle period before returning the responses. * @param requests the requests + * @param idleFor The time the response stream must be idle for before returning + * @param units The units of idleFor * @return the responses * @throws Exception if the requests fail */ @@ -74,19 +105,27 @@ public class LocalConnector extends AbstractConnector /** Sends requests and get's responses based on thread activity. * Returns all the responses received once the thread activity has * returned to the level it was before the requests. + *

+ * This methods waits until the connection is closed or + * is idle for 1s before returning the responses. * @param requestsBuffer the requests * @return the responses * @throws Exception if the requests fail */ public ByteBuffer getResponses(ByteBuffer requestsBuffer) throws Exception { - return getResponses(requestsBuffer,100,TimeUnit.MILLISECONDS); + return getResponses(requestsBuffer,1000,TimeUnit.MILLISECONDS); } /** Sends requests and get's responses based on thread activity. * Returns all the responses received once the thread activity has * returned to the level it was before the requests. + *

+ * This methods waits until the connection is closed or + * an idle period before returning the responses. * @param requestsBuffer the requests + * @param idleFor The time the response stream must be idle for before returning + * @param units The units of idleFor * @return the responses * @throws Exception if the requests fail */ @@ -195,8 +234,8 @@ public class LocalConnector extends AbstractConnector public void waitUntilClosedOrIdleFor(long idleFor,TimeUnit units) { + Thread.yield(); int size=getOutput().remaining(); - while (isOpen()) { try diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/SelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/SelectChannelConnector.java index c24a0e66ced..c5f42b6fef5 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/SelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/SelectChannelConnector.java @@ -30,7 +30,6 @@ import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.SelectChannelEndPoint; import org.eclipse.jetty.io.SelectorManager; import org.eclipse.jetty.io.SelectorManager.ManagedSelector; -import org.eclipse.jetty.server.Connector.NetConnector; import org.eclipse.jetty.util.annotation.Name; import org.eclipse.jetty.util.ssl.SslContextFactory; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java index 8fb7044acf5..598590883c0 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslConnector.java @@ -21,7 +21,6 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.TrustManagerFactory; -import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.util.ssl.SslContextFactory; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java index d661434273c..28480c3d00c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java @@ -13,21 +13,8 @@ package org.eclipse.jetty.server.ssl; -import java.io.IOException; -import java.nio.channels.SocketChannel; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLSession; - -import org.eclipse.jetty.http.HttpScheme; -import org.eclipse.jetty.io.AsyncConnection; -import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.RuntimeIOException; -import org.eclipse.jetty.io.ssl.SslConnection; -import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.util.component.AggregateLifeCycle; import org.eclipse.jetty.util.ssl.SslContextFactory; /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorCloseTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorCloseTestBase.java index 89f54ef00b8..133f299ad7b 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorCloseTestBase.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorCloseTestBase.java @@ -1,16 +1,13 @@ //======================================================================== -//Copyright (c) Webtide LLC +//Copyright 2011-2012 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.apache.org/licenses/LICENSE-2.0.txt -// //You may elect to redistribute this code under either of these licenses. //======================================================================== diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java index cd222495547..0a74f7f9a7b 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java @@ -27,6 +27,7 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.io.PrintWriter; +import java.util.concurrent.TimeUnit; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -87,6 +88,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Transfer-Encoding: chunked\n"+ "Content-Type: text/plain\n"+ + "Connection: close\n"+ "\015\012"+ "5;\015\012"+ "12345\015\012"+ @@ -100,6 +102,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Transfer-Encoding: chunked\n"+ "Content-Type: text/plain\n"+ + "Connection: close\n"+ "\015\012"+ "5;\015\012"+ "ABCDE\015\012"+ @@ -124,6 +127,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Transfer-Encoding: chunked\n"+ "Content-Type: text/plain\n"+ + "Connection: close\n"+ "\015\012"+ "0\015\012\015\012"); @@ -137,10 +141,12 @@ public class HttpConnectionTest { String responsePOST=connector.getResponses("POST /R1 HTTP/1.1\015\012"+ "Host: localhost\015\012"+ + "Connection: close\015\012"+ "\015\012"); String responseHEAD=connector.getResponses("HEAD /R1 HTTP/1.1\015\012"+ "Host: localhost\015\012"+ + "Connection: close\015\012"+ "\015\012"); assertThat(responsePOST,startsWith(responseHEAD.substring(0,responseHEAD.length()-2))); @@ -148,6 +154,7 @@ public class HttpConnectionTest responsePOST=connector.getResponses("POST /R1 HTTP/1.1\015\012"+ "Host: localhost\015\012"+ + "Connection: close\015\012"+ "\015\012"); assertThat(responsePOST,startsWith(responseHEAD.substring(0,responseHEAD.length()-2))); @@ -162,16 +169,19 @@ public class HttpConnectionTest response=connector.getResponses("GET http://localhost:EXPECTED_NUMBER_FORMAT_EXCEPTION/ HTTP/1.1\n"+ "Host: localhost\n"+ + "Connection: close\015\012"+ "\015\012"); checkContains(response,0,"HTTP/1.1 400"); response=connector.getResponses("GET /bad/encoding%1 HTTP/1.1\n"+ "Host: localhost\n"+ + "Connection: close\n"+ "\015\012"); checkContains(response,0,"HTTP/1.1 400"); response=connector.getResponses("GET % HTTP/1.1\n"+ "Host: localhost\n"+ + "Connection: close\n"+ "\015\012"); checkContains(response,0,"HTTP/1.1 400"); } @@ -180,21 +190,22 @@ public class HttpConnectionTest public void testAutoFlush() throws Exception { String response=null; - int offset=0; + int offset=0; - offset=0; - response=connector.getResponses("GET /R1 HTTP/1.1\n"+ - "Host: localhost\n"+ - "Transfer-Encoding: chunked\n"+ - "Content-Type: text/plain\n"+ - "\015\012"+ - "5;\015\012"+ - "12345\015\012"+ - "0;\015\012\015\012"); - offset = checkContains(response,offset,"HTTP/1.1 200"); - checkNotContained(response,offset,"IgnoreMe"); - offset = checkContains(response,offset,"/R1"); - offset = checkContains(response,offset,"12345"); + offset=0; + response=connector.getResponses("GET /R1 HTTP/1.1\n"+ + "Host: localhost\n"+ + "Transfer-Encoding: chunked\n"+ + "Content-Type: text/plain\n"+ + "Connection: close\n"+ + "\015\012"+ + "5;\015\012"+ + "12345\015\012"+ + "0;\015\012\015\012"); + offset = checkContains(response,offset,"HTTP/1.1 200"); + checkNotContained(response,offset,"IgnoreMe"); + offset = checkContains(response,offset,"/R1"); + offset = checkContains(response,offset,"12345"); } @Test @@ -211,6 +222,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Transfer-Encoding: chunked\n"+ "Content-Type: text/plain; charset=utf-8\n"+ + "Connection: close\n"+ "\015\012"+ "5;\015\012"+ "12345\015\012"+ @@ -225,6 +237,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Transfer-Encoding: chunked\n"+ "Content-Type: text/plain; charset = iso-8859-1 ; other=value\n"+ + "Connection: close\n"+ "\015\012"+ "5;\015\012"+ "12345\015\012"+ @@ -239,6 +252,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Transfer-Encoding: chunked\n"+ "Content-Type: text/plain; charset=unknown\n"+ + "Connection: close\n"+ "\015\012"+ "5;\015\012"+ "12345\015\012"+ @@ -281,6 +295,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Content-Type: text/plain; charset=utf-8\n"+ "Content-Length: 10\n"+ + "Connection: close\n"+ "\n"+ "abcdefghij\n"; @@ -527,6 +542,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Transfer-Encoding: chunked\n"+ "Content-Type: text/plain; charset=utf-8\n"+ + "Connection: close\n"+ "\015\012"+ "5;\015\012"+ "12345\015\012"+ @@ -543,6 +559,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Transfer-Encoding: chunked\n"+ "Content-Type: text/plain; charset=utf-8\n"+ + "Connection: close\n"+ "\015\012"+ "5;\015\012"+ "12345\015\012"+ @@ -554,6 +571,7 @@ public class HttpConnectionTest "Host: localhost\n"+ "Transfer-Encoding: chunked\n"+ "Content-Type: text/plain; charset=utf-8\n"+ + "Connection: close\n"+ "\015\012"+ "5;\015\012"+ "12345\015\012"+ @@ -585,7 +603,7 @@ public class HttpConnectionTest response=connector.getResponses("CONNECT www.webtide.com:8080 HTTP/1.1\n"+ "Host: myproxy:8888\015\012"+ - "\015\012"); + "\015\012",200,TimeUnit.MILLISECONDS); checkContains(response,offset,"HTTP/1.1 200"); } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java index cb23dfdb82d..547d36cb8b0 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java @@ -12,6 +12,8 @@ package org.eclipse.jetty.server; //You may elect to redistribute this code under either of these licenses. //======================================================================== +import static org.junit.Assert.assertEquals; + import java.io.IOException; import java.nio.ByteBuffer; import java.util.concurrent.ScheduledExecutorService; @@ -24,8 +26,6 @@ import org.eclipse.jetty.util.Utf8StringBuilder; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; - public class HttpWriterTest { private HttpWriter _writer; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/RFC2616Test.java b/jetty-server/src/test/java/org/eclipse/jetty/server/RFC2616Test.java index 7a479da7eb4..38d2d028938 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/RFC2616Test.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/RFC2616Test.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue; import java.util.Date; import java.util.Enumeration; import java.util.List; +import java.util.concurrent.TimeUnit; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.server.handler.ContextHandler; @@ -360,7 +361,7 @@ public class RFC2616Test // Default Host offset=0; - response=connector.getResponses("GET http://VirtualHost:8888/path/R1 HTTP/1.1\n"+"Host: wronghost\n"+"\n"); + response=connector.getResponses("GET http://VirtualHost:8888/path/R1 HTTP/1.1\n"+"Host: wronghost\n"+"Connection: close\n"+"\n"); offset=checkContains(response,offset,"HTTP/1.1 200","Default host")+1; offset=checkContains(response,offset,"Virtual Dump","virtual host")+1; offset=checkContains(response,offset,"pathInfo=/path/R1","Default host")+1; @@ -374,14 +375,14 @@ public class RFC2616Test // Default Host offset=0; - response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: localhost\n"+"\n"); + response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: localhost\n"+"Connection: close\n"+"\n"); offset=checkContains(response,offset,"HTTP/1.1 200","Default host")+1; offset=checkContains(response,offset,"Dump HttpHandler","Default host")+1; offset=checkContains(response,offset,"pathInfo=/path/R1","Default host")+1; // Virtual Host offset=0; - response=connector.getResponses("GET /path/R2 HTTP/1.1\n"+"Host: VirtualHost\n"+"\n"); + response=connector.getResponses("GET /path/R2 HTTP/1.1\n"+"Host: VirtualHost\n"+"Connection: close\n"+"\n"); offset=checkContains(response,offset,"HTTP/1.1 200","Default host")+1; offset=checkContains(response,offset,"Virtual Dump","virtual host")+1; offset=checkContains(response,offset,"pathInfo=/path/R2","Default host")+1; @@ -395,14 +396,14 @@ public class RFC2616Test // Virtual Host offset=0; - response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: VirtualHost\n"+"\n"); + response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: VirtualHost\n"+"Connection: close\n"+"\n"); offset=checkContains(response,offset,"HTTP/1.1 200","2. virtual host field")+1; offset=checkContains(response,offset,"Virtual Dump","2. virtual host field")+1; offset=checkContains(response,offset,"pathInfo=/path/R1","2. virtual host field")+1; // Virtual Host case insensitive offset=0; - response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: ViRtUalhOst\n"+"\n"); + response=connector.getResponses("GET /path/R1 HTTP/1.1\n"+"Host: ViRtUalhOst\n"+"Connection: close\n"+"\n"); offset=checkContains(response,offset,"HTTP/1.1 200","2. virtual host field")+1; offset=checkContains(response,offset,"Virtual Dump","2. virtual host field")+1; offset=checkContains(response,offset,"pathInfo=/path/R1","2. virtual host field")+1; @@ -422,7 +423,7 @@ public class RFC2616Test int offset=0; offset=0; - response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host: localhost\n"+"\n"); + response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host: localhost\n"+"\n",250,TimeUnit.MILLISECONDS); offset=checkContains(response,offset,"HTTP/1.1 200 OK\015\012","8.1.2 default")+10; checkContains(response,offset,"Content-Length: ","8.1.2 default"); @@ -754,19 +755,19 @@ public class RFC2616Test // HTTP/1.0 OK with no host offset=0; - response=connector.getResponses("GET /R1 HTTP/1.0\n"+"\n"); + response=connector.getResponses("GET /R1 HTTP/1.0\n"+"Connection: close\n"+"\n"); offset=checkContains(response,offset,"HTTP/1.1 200","200")+1; offset=0; - response=connector.getResponses("GET /R1 HTTP/1.1\n"+"\n"); + response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Connection: close\n"+"\n"); offset=checkContains(response,offset,"HTTP/1.1 400","400")+1; offset=0; - response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host: localhost\n"+"\n"); + response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host: localhost\n"+"Connection: close\n"+"\n"); offset=checkContains(response,offset,"HTTP/1.1 200","200")+1; offset=0; - response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host:\n"+"\n"); + response=connector.getResponses("GET /R1 HTTP/1.1\n"+"Host:\n"+"Connection: close\n"+"\n"); offset=checkContains(response,offset,"HTTP/1.1 200","200")+1; } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java index a09aecb02c2..08f5dca2ffa 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java @@ -13,7 +13,13 @@ package org.eclipse.jetty.server; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.io.BufferedReader; import java.io.File; @@ -112,6 +118,7 @@ public class RequestTest String request="GET /?param=%ZZaaa HTTP/1.1\r\n"+ "Host: whatever\r\n"+ "Content-Type: text/html;charset=utf8\n"+ + "Connection: close\n"+ "\n"; String responses=_connector.getResponses(request); @@ -158,6 +165,7 @@ public class RequestTest "Host: whatever\r\n"+ "Content-Type: multipart/form-data; boundary=\"AaB03x\"\r\n"+ "Content-Length: "+multipart.getBytes().length+"\r\n"+ + "Connection: close\r\n"+ "\r\n"+ multipart; @@ -183,6 +191,7 @@ public class RequestTest String request="GET /?param=aaa%E7bbb HTTP/1.1\r\n"+ "Host: whatever\r\n"+ "Content-Type: text/html;charset=utf8\n"+ + "Connection: close\n"+ "\n"; String responses=_connector.getResponses(request); @@ -203,6 +212,7 @@ public class RequestTest String request="GET / HTTP/1.1\r\n"+ "Host: whatever.com:\r\n"+ "Content-Type: text/html;charset=utf8\n"+ + "Connection: close\n"+ "\n"; String responses=_connector.getResponses(request); @@ -245,6 +255,7 @@ public class RequestTest "GET / HTTP/1.1\n"+ "Host: whatever\n"+ "Content-Type: text/html; other=foo ; blah=\"charset=wrong;\" ; charset = \" x=z; \" ; more=values \n"+ + "Connection: close\n"+ "\n" ); @@ -638,6 +649,7 @@ public class RequestTest response=_connector.getResponses( "GET / HTTP/1.1\n"+ "Host: whatever\n"+ + "Connection: close\n"+ "\n" ); assertTrue(response.startsWith("HTTP/1.1 200 OK")); @@ -649,6 +661,7 @@ public class RequestTest "GET / HTTP/1.1\n"+ "Host: whatever\n"+ "Cookie: name=quoted=\\\"value\\\"\n" + + "Connection: close\n"+ "\n" ); assertTrue(response.startsWith("HTTP/1.1 200 OK")); @@ -661,6 +674,7 @@ public class RequestTest "GET / HTTP/1.1\n"+ "Host: whatever\n"+ "Cookie: name=value; other=\"quoted=;value\"\n" + + "Connection: close\n"+ "\n" ); assertTrue(response.startsWith("HTTP/1.1 200 OK")); @@ -682,6 +696,7 @@ public class RequestTest "Host: whatever\n"+ "Other: header\n"+ "Cookie: name=value; other=\"quoted=;value\"\n" + + "Connection: close\n"+ "\n" ); assertTrue(response.startsWith("HTTP/1.1 200 OK")); @@ -705,6 +720,7 @@ public class RequestTest "Host: whatever\n"+ "Other: header\n"+ "Cookie: name=value; other=\"othervalue\"\n" + + "Connection: close\n"+ "\n" ); assertTrue(response.startsWith("HTTP/1.1 200 OK")); @@ -756,6 +772,7 @@ public class RequestTest "Host: whatever\n"+ "Other: header\n"+ "Cookie: __utmz=14316.133020.1.1.utr=gna.de|ucn=(real)|utd=reral|utct=/games/hen-one,gnt-50-ba-keys:key,2072262.html\n"+ + "Connection: close\n"+ "\n" ); assertTrue(response.startsWith("HTTP/1.1 200 OK")); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java index ca28f232553..96ecd8a8ad1 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java @@ -13,6 +13,11 @@ package org.eclipse.jetty.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.io.InputStreamReader; import java.io.LineNumberReader; @@ -24,6 +29,7 @@ import java.util.Locale; import java.util.concurrent.Executor; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; + import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; @@ -45,11 +51,6 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - /** * */ @@ -81,6 +82,13 @@ public class ResponseTest } }) { + @Override + public void onOpen() + { + super.onOpen(); + fillInterested(); + } + @Override public void onFillable() { diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java index d2c7deac09b..874d908752e 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java @@ -13,6 +13,9 @@ package org.eclipse.jetty.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -20,6 +23,7 @@ import java.io.PrintWriter; import java.net.Socket; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; + import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -36,9 +40,6 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class SelectChannelStatisticsTest { private static final Logger LOG = Log.getLogger(SelectChannelStatisticsTest.class); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java index 034896d4199..57eb77d1e19 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java @@ -19,7 +19,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.nio.ByteBuffer; -import java.nio.channels.SocketChannel; import java.util.Arrays; import java.util.concurrent.atomic.AtomicInteger; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java index 64c25734d4e..7e6084755dd 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java @@ -144,7 +144,7 @@ public class ContextHandlerCollectionTest for(String host : requestHosts) { - connector.getResponses("GET / HTTP/1.1\n" + "Host: "+host+"\n\n"); + connector.getResponses("GET / HTTP/1.1\n" + "Host: "+host+"\nConnection:close\n\n"); if(succeed) assertTrue("'"+host+"' should have been handled.",handler.isHandled()); else diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java index f23a70d29a7..bcb2e89e32f 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java @@ -376,7 +376,7 @@ public class ContextHandlerTest { server.start(); - String response = connector.getResponses("GET / HTTP/1.1\n" + "Host: www.example.com.\n\n"); + String response = connector.getResponses("GET / HTTP/1.1\n" + "Host: www.example.com.\nConnection:close\n\n"); Assert.assertTrue(response.indexOf("Goodbye")>0); Assert.assertTrue(response.indexOf("dead")<0); @@ -398,7 +398,7 @@ public class ContextHandlerTest IsHandledHandler handler = (IsHandledHandler)context.getHandler(); for(String host : requestHosts) { - connector.getResponses("GET / HTTP/1.1\n" + "Host: "+host+"\n\n"); + connector.getResponses("GET / HTTP/1.1\n" + "Host: "+host+"\nConnection:close\n\n"); if(succeed) assertTrue("'"+host+"' should have been handled.",handler.isHandled()); else diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java index 560ef7710f6..772ef521bac 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java @@ -11,11 +11,6 @@ //You may elect to redistribute this code under either of these licenses. //======================================================================== -// JettyTest.java -- -// -// Junit test that shows the Jetty SSL bug. -// - package org.eclipse.jetty.server.ssl; import java.io.BufferedReader; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java index 5f5a974c05f..51cb7bfd3c6 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java @@ -45,14 +45,15 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.hamcrest.Matchers; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; /** @@ -82,14 +83,14 @@ public class SSLEngineTest private static final int BODY_SIZE=300; private Server server; - private SslSelectChannelConnector connector; + private SelectChannelConnector connector; @Before public void startServer() throws Exception { server=new Server(); - connector=new SslSelectChannelConnector(server); + connector=new SelectChannelConnector(server,true); String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath(); connector.setPort(0); @@ -110,6 +111,36 @@ public class SSLEngineTest server.join(); } + + @Test + public void testHelloWorld() throws Exception + { + server.setHandler(new HelloWorldHandler()); + server.start(); + + SSLContext ctx=SSLContext.getInstance("TLS"); + ctx.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom()); + + int port=connector.getLocalPort(); + + Socket client=ctx.getSocketFactory().createSocket("localhost",port); + OutputStream os=client.getOutputStream(); + + String request = + "GET / HTTP/1.1\r\n"+ + "Host: localhost:"+port+"\r\n"+ + "Connection: close\r\n"+ + "\r\n"; + + os.write(request.getBytes()); + os.flush(); + + String response = IO.toString(client.getInputStream()); + + assertThat(response,Matchers.containsString("200 OK")); + assertThat(response,Matchers.containsString(HELLO_WORLD)); + } + @Test public void testBigResponse() throws Exception { diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java index c3d148f4282..7a040825aa0 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLSelectChannelConnectorLoadTest.java @@ -40,7 +40,6 @@ import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; public class SSLSelectChannelConnectorLoadTest diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslBytesServerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslBytesServerTest.java index fcd57ef6be9..d1cd8189f9d 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslBytesServerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslBytesServerTest.java @@ -35,7 +35,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLSocket; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; @@ -43,12 +42,9 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.io.AsyncConnection; -import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.SelectChannelEndPoint; import org.eclipse.jetty.io.SelectorManager.ManagedSelector; -import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java index 239b5e7ddf8..a392be8aebe 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java @@ -23,7 +23,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.security.KeyStore; import java.util.Arrays; -import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java index 97d3b00dc3c..d70c098d1a6 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java @@ -34,16 +34,12 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.http.HttpContent; import org.eclipse.jetty.http.HttpFields; -import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.io.WriterOutputStream; -import org.eclipse.jetty.server.AbstractConnector; -import org.eclipse.jetty.server.HttpConnection; -import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Dispatcher; +import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.HttpOutput; import org.eclipse.jetty.server.InclusiveByteRange; import org.eclipse.jetty.server.ResourceCache; @@ -778,9 +774,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory } else { + // TODO sometimes we should be direct! Connector connector = HttpChannel.getCurrentHttpChannel().getConnector(); - // TODO either make this more targeted and/or configurable or just get rid of the choice - direct=!(connector instanceof SslConnector); + direct=false; content_length=content.getContentLength(); } diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterHolder.java index 81d6cba14a2..43d258b58d6 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterHolder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterHolder.java @@ -25,7 +25,6 @@ import javax.servlet.FilterConfig; import javax.servlet.FilterRegistration; import javax.servlet.ServletException; -import org.eclipse.jetty.servlet.Holder.Source; import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterMapping.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterMapping.java index 4d75f048a83..25955bdd769 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterMapping.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/FilterMapping.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.util.EnumSet; import javax.servlet.DispatcherType; + import org.eclipse.jetty.http.PathMap; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.util.TypeUtil; diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java index d86eeff0c2b..98509b280b1 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java @@ -26,6 +26,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentMap; + import javax.servlet.DispatcherType; import javax.servlet.Filter; import javax.servlet.FilterChain; diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java index 6d20a1d94e0..360e00cad08 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java @@ -28,9 +28,9 @@ import java.util.Stack; import javax.servlet.MultipartConfigElement; import javax.servlet.Servlet; import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRegistration; -import javax.servlet.ServletContext; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.ServletSecurityElement; diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletTester.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletTester.java index 871cb40363a..7c771b6aee5 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletTester.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletTester.java @@ -1,9 +1,7 @@ package org.eclipse.jetty.servlet; -import java.io.IOException; import java.net.InetAddress; import java.nio.ByteBuffer; -import java.nio.charset.Charset; import java.util.EnumSet; import java.util.Enumeration; import java.util.Map; @@ -12,17 +10,11 @@ import javax.servlet.DispatcherType; import javax.servlet.Filter; import javax.servlet.Servlet; -import org.eclipse.jetty.http.HttpFields; -import org.eclipse.jetty.http.HttpHeader; -import org.eclipse.jetty.http.HttpMethod; -import org.eclipse.jetty.http.HttpParser; -import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.util.Attributes; -import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.component.AggregateLifeCycle; import org.eclipse.jetty.util.resource.Resource; diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java index 5b95d3e9ea0..1a42860f578 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java @@ -12,7 +12,11 @@ package org.eclipse.jetty.servlet; //You may elect to redistribute this code under either of these licenses. //======================================================================== +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.IOException; + import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -31,9 +35,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - /** * This tests verifies that merging of queryStrings works when dispatching * Requests via {@link Continuation} multiple times. diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java index 688923c9aa5..3e5ccb8cbdd 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java @@ -12,9 +12,15 @@ package org.eclipse.jetty.servlet; //You may elect to redistribute this code under either of these licenses. //======================================================================== +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; + import javax.servlet.AsyncContext; import javax.servlet.DispatcherType; import javax.servlet.ServletException; @@ -24,6 +30,7 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; import junit.framework.Assert; + import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.LocalConnector; @@ -35,11 +42,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - /** * This tests the correct functioning of the AsyncContext * diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java index 87f001c4ee7..4c465fd1259 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java @@ -18,6 +18,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.EnumSet; + import javax.servlet.DispatcherType; import javax.servlet.Filter; import javax.servlet.FilterChain; diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java index c4e72573797..f8b406e6504 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; -import java.util.HashMap; import java.util.List; import javax.servlet.DispatcherType; diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/HolderTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/HolderTest.java index 9bcdfe38621..4ba8906cac9 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/HolderTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/HolderTest.java @@ -20,18 +20,17 @@ package org.eclipse.jetty.servlet; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.Collections; import java.util.Set; -import javax.servlet.Registration; import javax.servlet.ServletRegistration; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.Test; /** * @version $Rev$ $Date$ diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ResponseHeadersTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ResponseHeadersTest.java index 4d08d6710c2..356101fff15 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ResponseHeadersTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ResponseHeadersTest.java @@ -1,6 +1,7 @@ package org.eclipse.jetty.servlet; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.startsWith; import java.io.BufferedReader; import java.io.IOException; diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java index e69c8050517..c2cbcbb18f3 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java @@ -21,6 +21,7 @@ import java.util.Enumeration; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; + import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java index 61c43f3f4a7..45617455335 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java @@ -14,9 +14,7 @@ package org.eclipse.jetty.servlets; import java.io.IOException; -import java.io.Serializable; import java.util.HashSet; -import java.util.Map; import java.util.Queue; import java.util.StringTokenizer; import java.util.concurrent.ConcurrentHashMap; diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java index a9cd06940f1..a044bf7a2d1 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java @@ -33,8 +33,8 @@ import org.eclipse.jetty.continuation.Continuation; import org.eclipse.jetty.continuation.ContinuationListener; import org.eclipse.jetty.continuation.ContinuationSupport; import org.eclipse.jetty.http.HttpMethod; -import org.eclipse.jetty.http.gzip.CompressedResponseWrapper; import org.eclipse.jetty.http.gzip.AbstractCompressedStream; +import org.eclipse.jetty.http.gzip.CompressedResponseWrapper; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludableGzipFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludableGzipFilter.java index f6a308bb7ff..88f5b34391f 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludableGzipFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludableGzipFilter.java @@ -27,8 +27,8 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.http.gzip.CompressedResponseWrapper; import org.eclipse.jetty.http.gzip.AbstractCompressedStream; +import org.eclipse.jetty.http.gzip.CompressedResponseWrapper; import org.eclipse.jetty.io.UncheckedPrintWriter; /* ------------------------------------------------------------ */ diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java index 6c970ab0307..757d3f6ce7f 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; + import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/UserAgentFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/UserAgentFilter.java index c489c9c21de..d07b65f0388 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/UserAgentFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/UserAgentFilter.java @@ -18,6 +18,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; + import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java index 7e310c7b32e..d205e208db8 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java @@ -18,6 +18,7 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.net.Socket; import java.util.EnumSet; + import javax.servlet.DispatcherType; import javax.servlet.Filter; import javax.servlet.Servlet; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterContentLengthTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterContentLengthTest.java index 60307270b4a..f71f35ef307 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterContentLengthTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterContentLengthTest.java @@ -15,6 +15,7 @@ package org.eclipse.jetty.servlets; import java.io.File; import java.util.Arrays; import java.util.List; + import javax.servlet.Servlet; import org.eclipse.jetty.http.HttpStatus; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipWithPipeliningTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipWithPipeliningTest.java index 4274b4e1a8b..63f0a98977f 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipWithPipeliningTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipWithPipeliningTest.java @@ -28,9 +28,9 @@ import java.io.InputStream; import java.net.URI; import java.security.DigestOutputStream; import java.security.MessageDigest; -import java.util.EnumSet; import java.util.Arrays; import java.util.Collection; +import java.util.EnumSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludableGzipFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludableGzipFilterTest.java index 4090700035b..111789866bc 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludableGzipFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludableGzipFilterTest.java @@ -14,7 +14,6 @@ package org.eclipse.jetty.servlets; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java index 8e256de2b64..47350ad356b 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java @@ -14,17 +14,13 @@ package org.eclipse.jetty.servlets; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.io.OutputStream; -import java.net.Socket; -import java.net.URL; import java.util.EnumSet; -import java.util.Enumeration; import javax.servlet.DispatcherType; import javax.servlet.ServletException; @@ -32,9 +28,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.servlet.FilterHolder; -import org.eclipse.jetty.servlet.FilterMapping; import org.eclipse.jetty.http.HttpTester; +import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.ServletTester; import org.eclipse.jetty.util.IO; import org.junit.After; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PipelineHelper.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PipelineHelper.java index 3ea4641cf9b..9bf896a3c8b 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PipelineHelper.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PipelineHelper.java @@ -12,6 +12,8 @@ package org.eclipse.jetty.servlets; //You may elect to redistribute this code under either of these licenses. //======================================================================== +import static org.hamcrest.Matchers.not; + import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -27,8 +29,6 @@ import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.StdErrLog; import org.junit.Assert; -import static org.hamcrest.Matchers.not; - public class PipelineHelper { private static final Logger LOG = Log.getLogger(PipelineHelper.class); diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java index d784aa7aab0..faea85d6f46 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java @@ -21,16 +21,16 @@ import java.io.FileInputStream; import java.io.OutputStream; import java.net.Socket; import java.net.URL; -import java.util.EnumSet; -import javax.servlet.DispatcherType; import java.util.Arrays; +import java.util.EnumSet; import java.util.HashSet; import java.util.Set; +import javax.servlet.DispatcherType; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.http.HttpTester; +import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.ServletTester; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.IO; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/QoSFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/QoSFilterTest.java index fce5afed6e8..8f89f432086 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/QoSFilterTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/QoSFilterTest.java @@ -20,6 +20,7 @@ import java.net.URL; import java.util.EnumSet; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; + import javax.servlet.DispatcherType; import javax.servlet.Servlet; import javax.servlet.ServletException; @@ -28,10 +29,9 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.servlet.FilterHolder; -import org.eclipse.jetty.servlet.FilterMapping; -import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.servlet.ServletTester; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.log.Log; diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java index 07cba740fe3..1ea039bc34f 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java @@ -35,18 +35,17 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; import java.util.zip.Inflater; -import javax.servlet.DispatcherType; import java.util.zip.InflaterInputStream; +import javax.servlet.DispatcherType; import javax.servlet.Servlet; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.ServletHolder; -import org.eclipse.jetty.servlets.GzipFilter; -import org.eclipse.jetty.servlets.MultipartFilterTest.TestServletParameterMap; -import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.servlet.ServletTester; +import org.eclipse.jetty.servlets.GzipFilter; import org.eclipse.jetty.toolchain.test.IO; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.TestingDir; diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/annotation/Name.java b/jetty-util/src/main/java/org/eclipse/jetty/util/annotation/Name.java index 2f68a8df426..37e44086f03 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/annotation/Name.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/annotation/Name.java @@ -15,8 +15,8 @@ package org.eclipse.jetty.util.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; -import java.lang.annotation.Target; import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Documented diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java index 0cc96c6ba6d..714e255153c 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java @@ -23,8 +23,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.nio.channels.SocketChannel; import java.security.InvalidParameterException; import java.security.KeyStore; import java.security.SecureRandom; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java index 23eb4adc397..ad88b2536c1 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java @@ -12,6 +12,11 @@ package org.eclipse.jetty.util.ssl; //You may elect to redistribute this code under either of these licenses. //======================================================================== +import static junit.framework.Assert.assertTrue; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + import java.io.IOException; import java.io.InputStream; import java.security.KeyStore; @@ -24,11 +29,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import static junit.framework.Assert.assertTrue; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - public class SslContextFactoryTest { diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java index de4b172a4f8..04c70e9489c 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java @@ -14,11 +14,7 @@ package org.eclipse.jetty.webapp; import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; -import java.util.Collection; import java.util.EnumSet; import java.util.EventListener; import java.util.HashSet; @@ -30,11 +26,7 @@ import java.util.Set; import javax.servlet.DispatcherType; import javax.servlet.MultipartConfigElement; import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; import javax.servlet.SessionTrackingMode; -import javax.servlet.descriptor.JspConfigDescriptor; -import javax.servlet.descriptor.JspPropertyGroupDescriptor; -import javax.servlet.descriptor.TaglibDescriptor; import org.eclipse.jetty.security.ConstraintAware; import org.eclipse.jetty.security.ConstraintMapping; @@ -43,7 +35,6 @@ import org.eclipse.jetty.servlet.ErrorPageErrorHandler; import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.FilterMapping; import org.eclipse.jetty.servlet.Holder; -import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler.JspConfig; import org.eclipse.jetty.servlet.ServletContextHandler.JspPropertyGroup; import org.eclipse.jetty.servlet.ServletContextHandler.TagLib; @@ -53,7 +44,6 @@ import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.security.Constraint; import org.eclipse.jetty.xml.XmlParser; diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java index 764fb0eb838..18471757a90 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java @@ -19,7 +19,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.security.PermissionCollection; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.EventListener; import java.util.HashMap; @@ -45,7 +44,6 @@ import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.MultiException; -import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java index 79075100628..5feec1d8b9c 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java @@ -111,7 +111,7 @@ public class WebSocketClientSelectorManager extends SelectorManager } }; endPoint.setAsyncConnection(sslConnection); - AsyncEndPoint sslEndPoint = sslConnection.getSslEndPoint(); + AsyncEndPoint sslEndPoint = sslConnection.getDecryptedEndPoint(); sslEndPointRef.set(sslEndPoint); startHandshake(engine); diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketAsyncConnection.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketAsyncConnection.java index 48b5b2f1957..abaaae7eb14 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketAsyncConnection.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketAsyncConnection.java @@ -77,6 +77,13 @@ public abstract class WebSocketAsyncConnection extends AbstractAsyncConnection i this.writes = new AtomicLong(0); } + @Override + public void onOpen() + { + super.onOpen(); + fillInterested(); + } + @Override public void close() throws IOException { diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java index ab14da7428c..971798f4e85 100644 --- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java +++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java @@ -354,7 +354,7 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock // Create connection HttpConnection http = HttpConnection.getCurrentConnection(); AsyncEndPoint endp = http.getEndPoint(); - Executor executor = http.getConnector().findExecutor(); + Executor executor = http.getConnector().getExecutor(); ByteBufferPool bufferPool = http.getConnector().getByteBufferPool(); WebSocketServerAsyncConnection connection = new WebSocketServerAsyncConnection(endp,executor,scheduler,websocket.getPolicy(),bufferPool,this); // Tell jetty about the new connection diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/SimpleServletServer.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/SimpleServletServer.java index 6ab88b8b26b..b7abe00029f 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/SimpleServletServer.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/SimpleServletServer.java @@ -45,7 +45,7 @@ public class SimpleServletServer { // Configure Server server = new Server(); - connector = new SelectChannelConnector(); + connector = new SelectChannelConnector(server); server.addConnector(connector); ServletContextHandler context = new ServletContextHandler(); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketLoadRFC6455Test.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketLoadRFC6455Test.java index 789ab727c26..7b4f385f240 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketLoadRFC6455Test.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketLoadRFC6455Test.java @@ -158,14 +158,12 @@ public class WebSocketLoadRFC6455Test @BeforeClass public static void startServer() throws Exception { - _server = new Server(); - - _connector = new SelectChannelConnector(); - _server.addConnector(_connector); - QueuedThreadPool threadPool = new QueuedThreadPool(200); threadPool.setMaxStopTimeMs(1000); - _server.setThreadPool(threadPool); + _server = new Server(threadPool); + + _connector = new SelectChannelConnector(_server); + _server.addConnector(_connector); WebSocketHandler wsHandler = new WebSocketHandler.Simple(MyEchoSocket.class); wsHandler.setHandler(new DefaultHandler()); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketOverSSLTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketOverSSLTest.java index 25c54d2090a..3f09953a554 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketOverSSLTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketOverSSLTest.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; @@ -95,7 +96,7 @@ public class WebSocketOverSSLTest private void startServer(final Object websocket) throws Exception { _server = new Server(); - SslSelectChannelConnector connector = new SslSelectChannelConnector(); + SelectChannelConnector connector = new SelectChannelConnector(_server,true); _server.addConnector(connector); SslContextFactory cf = connector.getSslContextFactory(); cf.setKeyStorePath(MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath()); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/ExampleEchoServer.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/ExampleEchoServer.java index f9ee1c57465..e6d3857f52f 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/ExampleEchoServer.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/ExampleEchoServer.java @@ -89,7 +89,7 @@ public class ExampleEchoServer public ExampleEchoServer(int port) { server = new Server(); - connector = new SelectChannelConnector(); + connector = new SelectChannelConnector(server); connector.setPort(port); server.addConnector(connector); diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java index 0be5b1399e1..c0d7f7a25e6 100644 --- a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java +++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java @@ -13,6 +13,13 @@ package org.eclipse.jetty.xml; +import static junit.framework.Assert.assertEquals; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + import java.net.URL; import java.util.HashMap; import java.util.Map; @@ -20,14 +27,6 @@ import java.util.Map; import org.junit.Assert; import org.junit.Test; -import static junit.framework.Assert.assertEquals; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; - -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - public class XmlConfigurationTest { protected String _configure="org/eclipse/jetty/xml/configure.xml"; diff --git a/test-continuation/src/main/java/org/eclipse/jetty/continuation/test/ContinuationBase.java b/test-continuation/src/main/java/org/eclipse/jetty/continuation/test/ContinuationBase.java index 16366ea364b..7fc0dd883ad 100644 --- a/test-continuation/src/main/java/org/eclipse/jetty/continuation/test/ContinuationBase.java +++ b/test-continuation/src/main/java/org/eclipse/jetty/continuation/test/ContinuationBase.java @@ -76,6 +76,7 @@ public abstract class ContinuationBase protected void doSuspendResume() throws Exception { String response=process("suspend=200&resume=0",null); + System.err.println(response); assertContains("RESUMED",response); assertNotContains("history: onTimeout",response); assertContains("history: onComplete",response); @@ -243,7 +244,8 @@ public abstract class ContinuationBase Socket socket = new Socket("localhost",port); socket.setSoTimeout(10000); socket.getOutputStream().write(request.getBytes("UTF-8")); - + socket.getOutputStream().flush(); + response = toString(socket.getInputStream()); } catch(Exception e) @@ -490,11 +492,13 @@ public abstract class ContinuationBase private static ContinuationListener __listener = new ContinuationListener() { + @Override public void onComplete(Continuation continuation) { ((HttpServletResponse)continuation.getServletResponse()).addHeader("history","onComplete"); } + @Override public void onTimeout(Continuation continuation) { ((HttpServletResponse)continuation.getServletResponse()).addHeader("history","onTimeout"); diff --git a/test-continuation/src/test/java/org/eclipse/jetty/continuation/ContinuationTest.java b/test-continuation/src/test/java/org/eclipse/jetty/continuation/ContinuationTest.java index c33b97ed571..30720ce44d3 100644 --- a/test-continuation/src/test/java/org/eclipse/jetty/continuation/ContinuationTest.java +++ b/test-continuation/src/test/java/org/eclipse/jetty/continuation/ContinuationTest.java @@ -15,12 +15,11 @@ package org.eclipse.jetty.continuation; import java.io.IOException; import java.io.InputStream; -import java.util.EnumSet; import org.eclipse.jetty.continuation.test.ContinuationBase; import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHandler; @@ -42,7 +41,7 @@ public class ContinuationTest extends ContinuationBase @Before public void setUp() throws Exception { - _connector = new SelectChannelConnector(); + _connector = new SelectChannelConnector(_server); _server.setConnectors(new Connector[]{ _connector }); ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.NO_SECURITY|ServletContextHandler.NO_SESSIONS); _server.setHandler(servletContext); @@ -64,7 +63,7 @@ public class ContinuationTest extends ContinuationBase @Test public void testContinuation() throws Exception { - doNormal("AsyncContinuation"); + doNormal("HttpChannelState"); } @Test diff --git a/test-continuation/src/test/java/org/eclipse/jetty/continuation/FauxContinuationTest.java b/test-continuation/src/test/java/org/eclipse/jetty/continuation/FauxContinuationTest.java index d6f50fc4a41..9ac29986c72 100644 --- a/test-continuation/src/test/java/org/eclipse/jetty/continuation/FauxContinuationTest.java +++ b/test-continuation/src/test/java/org/eclipse/jetty/continuation/FauxContinuationTest.java @@ -15,14 +15,11 @@ package org.eclipse.jetty.continuation; import java.io.IOException; import java.io.InputStream; -import java.util.EnumSet; - -import javax.servlet.DispatcherType; import org.eclipse.jetty.continuation.test.ContinuationBase; import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHandler; @@ -39,7 +36,7 @@ public class FauxContinuationTest extends ContinuationBase protected void setUp() throws Exception { - _connector = new SelectChannelConnector(); + _connector = new SelectChannelConnector(_server); _server.setConnectors(new Connector[]{ _connector }); ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.NO_SECURITY|ServletContextHandler.NO_SESSIONS); _server.setHandler(servletContext); diff --git a/test-jetty-webapp/src/main/java/com/acme/Dump.java b/test-jetty-webapp/src/main/java/com/acme/Dump.java index fa393fedeab..4cbcfc3f4b5 100644 --- a/test-jetty-webapp/src/main/java/com/acme/Dump.java +++ b/test-jetty-webapp/src/main/java/com/acme/Dump.java @@ -24,7 +24,6 @@ import java.lang.reflect.Array; import java.lang.reflect.Field; import java.net.URL; import java.util.Collections; -import java.util.Collection; import java.util.Date; import java.util.Enumeration; import java.util.Locale; @@ -50,7 +49,6 @@ import org.eclipse.jetty.continuation.Continuation; import org.eclipse.jetty.continuation.ContinuationListener; import org.eclipse.jetty.continuation.ContinuationSupport; import org.eclipse.jetty.http.HttpHeader; -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; diff --git a/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java b/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java index 6aec62c6867..7de3df7d2aa 100644 --- a/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java +++ b/test-jetty-webapp/src/main/java/com/acme/WebSocketChatServlet.java @@ -13,18 +13,15 @@ package com.acme; //======================================================================== import java.io.IOException; +import java.sql.Connection; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; -import javax.servlet.RequestDispatcher; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -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.WebSocket; -import org.eclipse.jetty.websocket.WebSocketServlet; public class WebSocketChatServlet extends WebSocketServlet { diff --git a/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java b/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java index e34fc8f80dc..784c6227403 100644 --- a/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java +++ b/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java @@ -21,12 +21,12 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.jmx.MBeanContainer; import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.NCSARequestLog; import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandlerCollection; @@ -35,12 +35,12 @@ import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.HandlerWrapper; import org.eclipse.jetty.server.handler.RequestLogHandler; import org.eclipse.jetty.server.handler.ResourceHandler; -import org.eclipse.jetty.server.SelectChannelConnector; import org.eclipse.jetty.server.session.HashSessionManager; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.StdErrLog; +import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.webapp.WebAppContext; import org.junit.Ignore;