/** @author jamesdbloom */
public class ProxyCommandLineIntegrationTest extends AbstractClientSecureProxyIntegrationTest {

  private static final int SERVER_HTTP_PORT = PortFactory.findFreePort();
  private static final int SERVER_HTTPS_PORT = PortFactory.findFreePort();
  private static final int PROXY_HTTP_PORT = PortFactory.findFreePort();
  private static final int PROXY_HTTPS_PORT = PortFactory.findFreePort();
  private static TestServer testServer = new TestServer();

  @BeforeClass
  public static void setupFixture() throws Exception {
    // start server
    testServer.startServer(SERVER_HTTP_PORT, SERVER_HTTPS_PORT);

    // start proxy
    Main.reset();
    Main.main("-proxyPort", "" + PROXY_HTTP_PORT, "-proxySecurePort", "" + PROXY_HTTPS_PORT);
    TimeUnit.MILLISECONDS.sleep(500);
  }

  @AfterClass
  public static void stopFixture() throws Exception {
    // stop server
    testServer.stop();

    // stop proxy
    new MockServerRunner()
        .stop("127.0.0.1", SystemProperties.serverStopPort(PROXY_HTTP_PORT, PROXY_HTTPS_PORT), 5);
    TimeUnit.MILLISECONDS.sleep(500);
  }

  @Override
  public int getProxyPort() {
    return PROXY_HTTP_PORT;
  }

  @Override
  public int getServerPort() {
    return SERVER_HTTP_PORT;
  }

  @Override
  public int getServerSecurePort() {
    return SERVER_HTTPS_PORT;
  }
}
 @BeforeClass
 public static void startJetty() throws Exception {
   port = PortFactory.findFreePort();
   server = new Server();
   SslSocketConnector sslSocketConnector = new SslSocketConnector();
   sslSocketConnector.setKeystore("src/test/resources/keystore");
   sslSocketConnector.setKeyPassword("password");
   sslSocketConnector.setPort(port);
   server.setConnectors(new Connector[] {sslSocketConnector});
   server.addHandler(
       new AbstractHandler() {
         public void handle(
             String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
             throws IOException, ServletException {
           response.setStatus(Response.Status.OK.getStatusCode());
           Request base_request =
               request instanceof Request
                   ? (Request) request
                   : HttpConnection.getCurrentConnection().getRequest();
           base_request.setHandled(true);
         }
       });
   server.start();
 }
 @BeforeClass
 public static void before() throws Exception {
   mockServerPort = PortFactory.findFreePort();
   mockServer = ClientAndServer.startClientAndServer(mockServerPort);
 }