@Test
  public void testInsecureConnection_plainHttpFailover()
      throws IOException, InterruptedException, GeneralSecurityException, URISyntaxException {
    FailoverHttpClient insecureHttpClient =
        new FailoverHttpClient(true /*insecure*/, false, logger);
    try (TestWebServer server = new TestWebServer(false, 3)) {
      String httpsUrl = server.getEndpoint().replace("http://", "https://");
      try (Response response = insecureHttpClient.get(new URL(httpsUrl), request)) {

        Assert.assertEquals(200, response.getStatusCode());
        Assert.assertArrayEquals(
            "Hello World!".getBytes(StandardCharsets.UTF_8),
            ByteStreams.toByteArray(response.getBody()));

        String expectedLog1 =
            "Cannot verify server at " + httpsUrl + ". Attempting again with no TLS verification.";
        String expectedLog2 =
            "Failed to connect to " + httpsUrl + " over HTTPS. Attempting again with HTTP.";
        Mockito.verify(logger).accept(LogEvent.warn(expectedLog1));
        Mockito.verify(logger).accept(LogEvent.warn(expectedLog2));
      }
    }
  }
Tests for {@link FailoverHttpClient} using an actual local server.
jib-core/src/test/java/com/google/cloud/tools/jib/http/WithServerFailoverHttpClientTest.java