public void before(final Description description) throws Exception {
        this.service = Executors.newFixedThreadPool(
                threadCount, 
                new ThreadFactoryBuilder().setDaemon(true).setNameFormat("TestHttpServer-%d").build());
        
        InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 0);
        if (hasSsl) {
            byte[] sampleTruststore1 = Base64.decode(TEST_TS1);
            byte[] sampleKeystore1 = Base64.decode(TEST_KS1);

            keystore = File.createTempFile("SecureAcceptAllGetTest", ".keystore");
            truststore = File.createTempFile("SecureAcceptAllGetTest", ".truststore");

            FileOutputStream keystoreFileOut = new FileOutputStream(keystore);
            try {
                keystoreFileOut.write(sampleKeystore1);
            } finally {
                keystoreFileOut.close();
            }

            FileOutputStream truststoreFileOut = new FileOutputStream(truststore);
            try {
                truststoreFileOut.write(sampleTruststore1);
            } finally {
                truststoreFileOut.close();
            }


            KeyStore ks = KeyStore.getInstance("JKS");
            ks.load(new FileInputStream(keystore), PASSWORD.toCharArray());
            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks, PASSWORD.toCharArray());

            KeyStore ts = KeyStore.getInstance("JKS");
            ts.load(new FileInputStream(truststore), PASSWORD.toCharArray());
            TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            tmf.init(ts);

            SSLContext sc = SSLContext.getInstance("TLS");
            sc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
            
            HttpsServer secureServer = HttpsServer.create(inetSocketAddress, 0);
            secureServer.setHttpsConfigurator(new HttpsConfigurator(sc) {
                public void configure (HttpsParameters params) {
                    SSLContext c = getSSLContext();
                    SSLParameters sslparams = c.getDefaultSSLParameters();
                    params.setSSLParameters(sslparams);
                }
            });
            server = secureServer;
        }
        else {
            server = HttpServer.create(inetSocketAddress, 0);
        }
        
        server.setExecutor(service);
        
        for (Entry<String, HttpHandler> handler : handlers.entrySet()) {
            server.createContext(handler.getKey(), handler.getValue());
        }
        
        server.start();
        localHttpServerPort = server.getAddress().getPort();
        
        System.out.println(description.getClassName() + " TestServer is started: " + getServerUrl());
    }
Rule for running an embedded HTTP server for basic testing.  The
server uses ephemeral ports to ensure there are no conflicts when
running concurrent unit tests

The server uses HttpServer classes available in the JVM to avoid
pulling in any extra dependencies.

Available endpoints are,

/                      Returns a 200
/status?code=${code}   Returns a request provide code
/noresponse            No response from the server

Optional query parameters
delay=${delay}         Inject a delay into the request

@author elandau
ribbon-loadbalancer/src/test/java/com/netflix/client/testutil/MockHttpServer.java