Refactored to made it easier to use by subclasses.
This commit is contained in:
parent
460673f04b
commit
b78fee10f5
|
@ -53,7 +53,7 @@ public abstract class AbstractTest
|
||||||
@Rule
|
@Rule
|
||||||
public final TestTracker tracker = new TestTracker();
|
public final TestTracker tracker = new TestTracker();
|
||||||
|
|
||||||
private final Transport transport;
|
protected final Transport transport;
|
||||||
protected Server server;
|
protected Server server;
|
||||||
protected ServerConnector connector;
|
protected ServerConnector connector;
|
||||||
protected HttpClient client;
|
protected HttpClient client;
|
||||||
|
@ -64,6 +64,12 @@ public abstract class AbstractTest
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(Handler handler) throws Exception
|
public void start(Handler handler) throws Exception
|
||||||
|
{
|
||||||
|
startServer(handler);
|
||||||
|
startClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startServer(Handler handler) throws Exception
|
||||||
{
|
{
|
||||||
QueuedThreadPool serverThreads = new QueuedThreadPool();
|
QueuedThreadPool serverThreads = new QueuedThreadPool();
|
||||||
serverThreads.setName("server");
|
serverThreads.setName("server");
|
||||||
|
@ -72,7 +78,10 @@ public abstract class AbstractTest
|
||||||
server.addConnector(connector);
|
server.addConnector(connector);
|
||||||
server.setHandler(handler);
|
server.setHandler(handler);
|
||||||
server.start();
|
server.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startClient() throws Exception
|
||||||
|
{
|
||||||
QueuedThreadPool clientThreads = new QueuedThreadPool();
|
QueuedThreadPool clientThreads = new QueuedThreadPool();
|
||||||
clientThreads.setName("client");
|
clientThreads.setName("client");
|
||||||
client = new HttpClient(provideClientTransport(transport, clientThreads), null);
|
client = new HttpClient(provideClientTransport(transport, clientThreads), null);
|
||||||
|
@ -118,7 +127,9 @@ public abstract class AbstractTest
|
||||||
@After
|
@After
|
||||||
public void stop() throws Exception
|
public void stop() throws Exception
|
||||||
{
|
{
|
||||||
|
if (client != null)
|
||||||
client.stop();
|
client.stop();
|
||||||
|
if (server != null)
|
||||||
server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue