@@ -0,0 +1,2015 @@
+/*%0A * Copyright (c) 2016 EMC Corporation. All Rights Reserved.%0A */%0Apackage com.emc.ia.sdk.support.http;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.net.InetSocketAddress;%0Aimport java.util.Collections;%0A%0Aimport org.apache.commons.io.IOUtils;%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport com.emc.ia.sdk.support.http.apache.ApacheHttpClient;%0Aimport com.emc.ia.sdk.support.io.ByteArrayInputOutputStream;%0Aimport com.emc.ia.sdk.support.test.TestCase;%0Aimport com.sun.net.httpserver.HttpServer;%0A%0A%0Apublic class WhenWorkingWithHttp extends TestCase %7B%0A%0A  private static final int PORT = 8000;%0A  private static final String PATH = %22/echo%22;%0A  private static final String URI = %22http://localhost:%22 + PORT + PATH;%0A%0A  private final HttpClient client = new ApacheHttpClient();%0A  private HttpServer server;%0A  private Thread serverThread;%0A%0A  @Before%0A  public void init() throws IOException %7B%0A    server = HttpServer.create(new InetSocketAddress(PORT), 0);%0A    server.createContext(PATH, httpExchange -%3E %7B%0A      ByteArrayInputOutputStream content = new ByteArrayInputOutputStream();%0A      long size = IOUtils.copy(httpExchange.getRequestBody(), content);%0A      httpExchange.sendResponseHeaders(200, size);%0A      try (InputStream input = content.getInputStream()) %7B%0A        IOUtils.copy(input, httpExchange.getResponseBody());%0A      %7D%0A      httpExchange.close();%0A    %7D);%0A    server.setExecutor(null);%0A    serverThread = new Thread(() -%3E server.start());%0A    serverThread.start();%0A  %7D%0A%0A  @After%0A  public void done() throws InterruptedException %7B%0A    client.close();%0A    server.stop(0);%0A    serverThread.join();%0A  %7D%0A%0A  @Test%0A  public void shouldHandleTextData() throws Exception %7B%0A    String expected = randomString(8);%0A    assertEquals(%22PUT%22,  expected, client.put(URI,  Collections.emptyList(), String.class, expected));%0A    assertEquals(%22POST%22, expected, client.post(URI, Collections.emptyList(), String.class, expected));%0A  %7D%0A%0A%7D%0A

Add end-to-end test for HTTP client