### Question:
UrlHttpClient implements HttpClient { @Override public HttpResponse execute(final HttpRequest request) throws IOException { final URL url = request.getUri().toURL(); final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); final CurlBuilder curlBuilder = config.isCurlLogging() ? new CurlBuilder(request.getUri().toURL()) : null; configureConnection(request, connection); applyHeadersAndMethod(request, connection, curlBuilder); writeContentToConnection(request, connection, curlBuilder); if (curlBuilder != null) { if (curlBuilder.isValid()) { printToLog(curlBuilder.build()); } else { printToLog("Failed to create curl, content too long"); } } return createHttpResponse(request, connection); } UrlHttpClient(ClientConfiguration config); @Override HttpResponse execute(final HttpRequest request); @Override void shutdown();  }### Answer:
@Test public void testCurlBuilderWithHeaders() throws URISyntaxException, IOException { conf.setCurlLogging(true); final Map<String, String> headers = new HashMap<String, String>(); headers.put("key1", "value1"); headers.put("key2", "value2"); final HashSet<String> expectedCurlHeaders = new HashSet<String>(); for (final Map.Entry<String, String> entry : headers.entrySet()) { expectedCurlHeaders.add("\"" + entry.getKey() + ":" + entry.getValue() + "\""); } final HttpRequest request = new HttpRequest("POST", new URI("https: headers, null ); try { client.execute(request); } catch (final UnknownHostException exception) { return; } assertTrue("Expected UnknownHostException. UnknownHostException not thrown while executing the request.", true); }
@Test public void testCurlBuilderWithData() throws URISyntaxException, IOException { conf.setCurlLogging(true); final String dataString = "content"; final byte[] data = dataString.getBytes("UTF-8"); final Map<String, String> headers = new HashMap<String, String>(); headers.put(HttpHeader.CONTENT_LENGTH, String.valueOf(data.length)); final InputStream stream = new ByteArrayInputStream(data); final HttpRequest request = new HttpRequest("POST", new URI("https: headers, stream); try { client.execute(request); } catch (final UnknownHostException exception) { return; } assertTrue("Expected UnknownHostException. UnknownHostException not thrown while executing the request.", true); }
@Test public void testOverflowInCurl() throws URISyntaxException, IOException { conf.setCurlLogging(true); final long tooManyBytes = Integer.MAX_VALUE + 1L; final InputStream stream = new ByteArrayInputStream("content".getBytes("UTF-8")); final Map<String, String> headers = new HashMap<String, String>(); headers.put(HttpHeader.CONTENT_LENGTH, String.valueOf(tooManyBytes)); final HttpRequest request = new HttpRequest("POST", new URI("https: headers, stream); request.setStreaming(true); try { client.execute(request); } catch (final UnknownHostException exception) { return; } assertTrue("Expected UnknownHostException. UnknownHostException not thrown while executing the request.", true); }