TcpClient { public List<String> getRegisteredCallSiteKeys() throws IOException, ParseException { Map obj = new LinkedHashMap(); obj.put("call", "getRegisteredCallSiteKeys"); String stringResult = send(JSONValue.toJSONString(obj)); List<String> res = (List<String>) getReturn(stringResult); return res; } 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 testGetRegisteredCallSiteKeys() throws Exception { final String expected_answer = "{\"result\":\"ok\",\"calledMethod\":\"getRegisteredCallSiteKeys\",\"return\":[\"HelloWorld.tick:(HelloWorld)void\"]}" + END_OF_INSTRUCTION; final List<String> expectedResult = new ArrayList<String>() {{ add("HelloWorld.tick:(HelloWorld)void"); }}; final String sent_call = "getRegisteredCallSiteKeys"; SocketChannel socket = prepareRequestInjection(expected_answer); ArgumentCaptor<ByteBuffer> argument = forClass(ByteBuffer.class); TestableClient theClient = new TestableClient(socket); List<String> result = theClient.getRegisteredCallSiteKeys(); 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.get(0), result.get(0)); }