From 7b58c584b9b1fa7232fb1537bbf8d4ff5e999b7b Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 27 Aug 2012 08:38:27 +0200 Subject: [PATCH] Jetty9 - Fixed tests: now creating a connector requires an instance of Server, otherwise throws an NPE. --- .../org/eclipse/jetty/spdy/AbstractTest.java | 16 +++++++++++----- .../org/eclipse/jetty/spdy/IdleTimeoutTest.java | 9 ++++++--- .../eclipse/jetty/spdy/SSLEngineLeakTest.java | 3 ++- .../org/eclipse/jetty/spdy/SSLSynReplyTest.java | 3 ++- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java index fbfa850278d..39768d73b12 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/AbstractTest.java @@ -61,11 +61,10 @@ public abstract class AbstractTest protected InetSocketAddress startServer(short version, ServerSessionFrameListener listener) throws Exception { - QueuedThreadPool pool = new QueuedThreadPool(); - pool.setName(pool.getName()+"-server"); - server = new Server(pool); + if (server == null) + server = newServer(); if (connector == null) - connector = newSPDYServerConnector(listener); + connector = newSPDYServerConnector(server, listener); if (listener == null) listener = connector.getServerSessionFrameListener(); connector.setDefaultConnectionFactory(new ServerSPDYConnectionFactory(version, connector.getByteBufferPool(), connector.getExecutor(), connector.getScheduler(), listener)); @@ -75,7 +74,14 @@ public abstract class AbstractTest return new InetSocketAddress("localhost", connector.getLocalPort()); } - protected SPDYServerConnector newSPDYServerConnector(ServerSessionFrameListener listener) + protected Server newServer() + { + QueuedThreadPool pool = new QueuedThreadPool(); + pool.setName(pool.getName()+"-server"); + return new Server(pool); + } + + protected SPDYServerConnector newSPDYServerConnector(Server server, ServerSessionFrameListener listener) { return new SPDYServerConnector(server, listener); } diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java index ed3907c6140..d4ae67a34db 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java @@ -44,7 +44,8 @@ public class IdleTimeoutTest extends AbstractTest @Test public void testServerEnforcingIdleTimeout() throws Exception { - connector = newSPDYServerConnector(new ServerSessionFrameListener.Adapter() + server = newServer(); + connector = newSPDYServerConnector(server, new ServerSessionFrameListener.Adapter() { @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) @@ -73,7 +74,8 @@ public class IdleTimeoutTest extends AbstractTest @Test public void testServerEnforcingIdleTimeoutWithUnrespondedStream() throws Exception { - connector = newSPDYServerConnector(null); + server = newServer(); + connector = newSPDYServerConnector(server, null); connector.setIdleTimeout(idleTimeout); final CountDownLatch latch = new CountDownLatch(1); @@ -95,7 +97,8 @@ public class IdleTimeoutTest extends AbstractTest @Test public void testServerNotEnforcingIdleTimeoutWithPendingStream() throws Exception { - connector = newSPDYServerConnector(new ServerSessionFrameListener.Adapter() + server = newServer(); + connector = newSPDYServerConnector(server, new ServerSessionFrameListener.Adapter() { @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLEngineLeakTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLEngineLeakTest.java index ee50d092aa2..c6641fe2db1 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLEngineLeakTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLEngineLeakTest.java @@ -24,6 +24,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.npn.NextProtoNego; +import org.eclipse.jetty.server.Server; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; import org.eclipse.jetty.util.ssl.SslContextFactory; @@ -33,7 +34,7 @@ import org.junit.Test; public class SSLEngineLeakTest extends AbstractTest { @Override - protected SPDYServerConnector newSPDYServerConnector(ServerSessionFrameListener listener) + protected SPDYServerConnector newSPDYServerConnector(Server server, ServerSessionFrameListener listener) { SslContextFactory sslContextFactory = newSslContextFactory(); return new SPDYServerConnector(server, sslContextFactory, listener); diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLSynReplyTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLSynReplyTest.java index 44e49e7a521..5aad237ff46 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLSynReplyTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SSLSynReplyTest.java @@ -22,6 +22,7 @@ package org.eclipse.jetty.spdy; import java.util.concurrent.Executor; import org.eclipse.jetty.npn.NextProtoNego; +import org.eclipse.jetty.server.Server; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.Before; @@ -29,7 +30,7 @@ import org.junit.Before; public class SSLSynReplyTest extends SynReplyTest { @Override - protected SPDYServerConnector newSPDYServerConnector(ServerSessionFrameListener listener) + protected SPDYServerConnector newSPDYServerConnector(Server server, ServerSessionFrameListener listener) { SslContextFactory sslContextFactory = newSslContextFactory(); return new SPDYServerConnector(server, sslContextFactory, listener);