From b78fee10f5b18238892aa0255e6d290d9baecb51 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 21 Sep 2015 10:17:27 +0200 Subject: [PATCH] Refactored to made it easier to use by subclasses. --- .../eclipse/jetty/http/client/AbstractTest.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/AbstractTest.java b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/AbstractTest.java index 54959c706c3..e9d9920ddce 100644 --- a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/AbstractTest.java +++ b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/AbstractTest.java @@ -53,7 +53,7 @@ public abstract class AbstractTest @Rule public final TestTracker tracker = new TestTracker(); - private final Transport transport; + protected final Transport transport; protected Server server; protected ServerConnector connector; protected HttpClient client; @@ -64,6 +64,12 @@ public abstract class AbstractTest } public void start(Handler handler) throws Exception + { + startServer(handler); + startClient(); + } + + protected void startServer(Handler handler) throws Exception { QueuedThreadPool serverThreads = new QueuedThreadPool(); serverThreads.setName("server"); @@ -72,7 +78,10 @@ public abstract class AbstractTest server.addConnector(connector); server.setHandler(handler); server.start(); + } + protected void startClient() throws Exception + { QueuedThreadPool clientThreads = new QueuedThreadPool(); clientThreads.setName("client"); client = new HttpClient(provideClientTransport(transport, clientThreads), null); @@ -118,8 +127,10 @@ public abstract class AbstractTest @After public void stop() throws Exception { - client.stop(); - server.stop(); + if (client != null) + client.stop(); + if (server != null) + server.stop(); } protected enum Transport