@Test
  public void testHTTPSViaRibbon() {

    Client trustSSLSockets = new Client.Default(TrustingSSLSocketFactory.get(), null);

    server1.get().useHttps(TrustingSSLSocketFactory.get("localhost"), false);
    server1.enqueue(new MockResponse().setBody("success!"));

    getConfigInstance().setProperty(serverListKey(), hostAndPort(server1.getUrl("")));

    TestInterface api =
        Feign.builder()
            .client(RibbonClient.builder().delegate(trustSSLSockets).build())
            .target(TestInterface.class, "https://" + client());
    api.post();
    assertEquals(1, server1.getRequestCount());
  }
  @Test
  public void ioExceptionRetry() throws IOException, InterruptedException {
    server1.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AT_START));
    server1.enqueue(new MockResponse().setBody("success!"));

    getConfigInstance().setProperty(serverListKey(), hostAndPort(server1.getUrl("")));

    TestInterface api =
        Feign.builder()
            .client(RibbonClient.create())
            .target(TestInterface.class, "http://" + client());

    api.post();

    assertEquals(2, server1.getRequestCount());
    // TODO: verify ribbon stats match
    // assertEquals(target.lb().getLoadBalancerStats().getSingleServerStat())
  }
  /*
         This test-case replicates a bug that occurs when using RibbonRequest with a query string.

         The querystrings would not be URL-encoded, leading to invalid HTTP-requests if the query string contained
         invalid characters (ex. space).
  */
  @Test
  public void urlEncodeQueryStringParameters() throws IOException, InterruptedException {
    String queryStringValue = "some string with space";
    String expectedQueryStringValue = "some+string+with+space";
    String expectedRequestLine = String.format("GET /?a=%s HTTP/1.1", expectedQueryStringValue);

    server1.enqueue(new MockResponse().setBody("success!"));

    getConfigInstance().setProperty(serverListKey(), hostAndPort(server1.getUrl("")));

    TestInterface api =
        Feign.builder()
            .client(RibbonClient.create())
            .target(TestInterface.class, "http://" + client());

    api.getWithQueryParameters(queryStringValue);

    final String recordedRequestLine = server1.takeRequest().getRequestLine();

    assertEquals(recordedRequestLine, expectedRequestLine);
  }
 @Test
 public void testCleanUrl() throws IOException {
   URI uri = RibbonClient.cleanUrl("http://myservice/questions/answer/123", "myservice");
   assertEquals("http:///questions/answer/123", uri.toString());
 }
 @Test
 public void testCleanUrlWithMatchingHostAndPart() throws IOException {
   URI uri = RibbonClient.cleanUrl("http://questions/questions/answer/123", "questions");
   assertEquals("http:///questions/answer/123", uri.toString());
 }