### Question:
HttpClient implements IHttpClient { public <T> T get(String url, Class<T> class1) throws IOException { String rs = get(url); if (rs == null || rs.length() == 0 || rs.trim().length() == 0) { return null; } else { return JsonUtil.parseJson(rs, class1); } } HttpClient(long connTimeout, long readTimeout);  HttpClient(); boolean check(String url); String post(String url, Object reqObj); T post(String url, Object request, Class<T> class1); T get(String url, Class<T> class1); void postAsyn(String url, Object reqObj, Callback callback); String get(String url);  }### Answer:
@Test public void getTest() throws IOException { ClientAndServer mockClient = new ClientAndServer(5000); try { mockClient.when(HttpRequest.request().withMethod("GET")) .respond(HttpResponse.response().withStatusCode(200).withBody("1")); HttpClient httpClient = new HttpClient(); assertEquals("1", httpClient.get("http: } finally { mockClient.stop(true); } }
@Test public void getErrorTest() throws IOException { ClientAndServer mockClient = new ClientAndServer(5000); try { mockClient.when(HttpRequest.request().withMethod("GET")) .respond(HttpResponse.response().withStatusCode(700).withBody("1")); HttpClient httpClient = new HttpClient(); boolean rs = false; try { assertEquals("1", httpClient.get("http: } catch (Exception e) { rs = true; } assertEquals(true, rs); } finally { mockClient.stop(true); } }
@Test public void getError1Test() throws IOException { ClientAndServer mockClient = new ClientAndServer(5000); try { mockClient.when(HttpRequest.request().withMethod("GET")) .respond(HttpResponse.response().withStatusCode(700).withBody("1")); HttpClient httpClient = new HttpClient(); boolean rs = false; try { assertEquals("1", httpClient.get("http: } catch (Exception e) { rs = true; } assertEquals(true, rs); } finally { mockClient.stop(true); } }