### Question:
MockSocket { public static UniversalMockRecorder expectCall() { return StaticConnectionFactory.expectCall(); } protected  MockSocket(); static UniversalMockRecorder expectCall(); static void reset(); static List<RequestSocketData> recordedConnections(); static SocketData emptyResponse(); static SocketData data(byte[] data); static Matcher<RequestSocketData> data(Matcher<byte[]> dataMatcher); static Matcher<RequestSocketData> withData(InputStream data); static Matcher<RequestSocketData> address(Matcher<String> addressMatcher); static Matcher<SocketData> dataAre(InputStream data); static Matcher<SocketData> dataAre(SocketData data); static void useConnectionFactory(ConnectionFactory connectionFactory); static boolean isPrintDataAsString(); static void setPrintDataAsString(boolean printDataAsString); static String getDefaultEncoding(); static void setDefaultEncoding(String defaultEncoding);  }### Answer:
@Test public void testHttpClient() throws ClientProtocolException, IOException { expectCall().andReturn(new DefaultSocketData("HTTP/1.0 200 OK\n\nTest".getBytes())); HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(ADDRESS); HttpResponse response = httpclient.execute(httpget); assertEquals("Test", printStream(response.getEntity().getContent())); }
@Test public void testUrl() throws ClientProtocolException, IOException { expectCall().andReturn(new DefaultSocketData("HTTP/1.0 200 OK\n\nTest".getBytes())); URL url = new URL(ADDRESS); assertEquals("Test", printStream(url.openStream())); }