private final static int serverSecurePort = PortFactory.findFreePort();
@Test
public void canStartAndStopMultipleTimes() {
// start server
HttpProxy httpProxy = new HttpProxyBuilder().withHTTPPort(serverPort).withHTTPSPort(serverSecurePort).build();
// start client
ProxyClient proxyClient = new ProxyClient("localhost", serverPort);
for (int i = 0; i < 2; i++) {
// when
proxyClient.stop();
// then
assertFalse(httpProxy.isRunning());
httpProxy = new HttpProxyBuilder().withHTTPPort(serverPort).withHTTPSPort(serverSecurePort).build();
assertTrue(httpProxy.isRunning());
}
assertTrue(httpProxy.isRunning());
httpProxy.stop();
assertFalse(httpProxy.isRunning());
}