Refactored to made it easier to use by subclasses.

This commit is contained in:
Simone Bordet 2015-09-21 10:17:27 +02:00
parent 460673f04b
commit b78fee10f5
1 changed files with 14 additions and 3 deletions

View File

@ -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