### Question:
CoapTcpMessaging extends CoapMessaging { @Override public void ping(InetSocketAddress destination, Callback<CoapPacket> callback) { CoapPacket pingRequest = new CoapPacket(Code.C702_PING, null, destination); makeRequest(pingRequest, callback, TransportContext.NULL); } CoapTcpMessaging(CoapTransport coapTransport, CoapTcpCSMStorage csmStorage, boolean useBlockWiseTransfer, int maxMessageSize); @Override void ping(InetSocketAddress destination, Callback<CoapPacket> callback); @Override void makeRequest(CoapPacket packet, Callback<CoapPacket> callback, TransportContext transContext); @Override void sendResponse(CoapPacket request, CoapPacket response, TransportContext transContext); @Override void onConnected(InetSocketAddress remoteAddress); @Override void onDisconnected(InetSocketAddress remoteAddress); @Override void makePrioritisedRequest(CoapPacket packet, Callback<CoapPacket> callback, TransportContext transContext);  }### Answer:
@Test public void should_send_ping_message() throws Exception { tcpMessaging.ping(LOCAL_1_5683, mock(Callback.class)); assertSent(new CoapPacket(Code.C702_PING, null, LOCAL_1_5683)); }
@Test public void should_handle_pong() throws Exception { FutureCallbackAdapter<CoapPacket> resp = new FutureCallbackAdapter<>(); tcpMessaging.ping(LOCAL_1_5683, resp); receive(newCoapPacket(LOCAL_1_5683).code(Code.C703_PONG)); assertEquals(Code.C703_PONG, resp.get().getCode()); }