TcpClient { public String getNumberOfRegisteredCallSites() throws IOException { Map obj = new LinkedHashMap(); obj.put("call", "getNumberOfRegisteredCallSites"); String stringResult = send(JSONValue.toJSONString(obj)); return (String) getReturn(stringResult); } TcpClient(String hostname, int port);  TcpClient();  TcpClient(SocketChannel socketChannel); void disconnect(); List<String> getRegisteredCallSiteKeys(); String getNumberOfRegisteredCallSites(); String getCallSiteType(String target); boolean changeCallSiteTarget(String methodType, String oldTarget, String newTarget); boolean applyBeforeAspect(String callSitesKey, String aspectClass, String aspectMethod); boolean applyAfterAspect(String callSitesKey, String aspectClass, String aspectMethod);  }
@Test public void testGetNumberOfRegisteredCallSites() throws Exception { final String expected_answer = "{\"result\":\"ok\",\"return\":\"1\",\"calledMethod\":\"getNumberOfRegisteredCallSites\"}" + END_OF_INSTRUCTION; final String expectedResult = "1"; final String sent_call = "getNumberOfRegisteredCallSites"; SocketChannel socket = prepareRequestInjection(expected_answer); ArgumentCaptor<ByteBuffer> argument = forClass(ByteBuffer.class); TestableClient theClient = new TestableClient(socket); String result = theClient.getNumberOfRegisteredCallSites(); theClient.disconnect(); verify(socket).write(argument.capture()); String sent_message = getAnswerFromBuffer(argument.getValue()); JSONObject objIn = (JSONObject) JSONValue.parse(sent_message); assertEquals(sent_call, objIn.get("call")); assertEquals(expectedResult, result); }