* @throws IOException
* @throws URISyntaxException
* @throws InterruptedException
*/
private void doSendReceive(final Packet outboundPacket) throws IOException, URISyntaxException, InterruptedException {
ByteArrayPacket inboundPacket = new ByteArrayPacket(new byte[outboundPacket.remaining()]);
// Do the send async.
sendExecutor.execute( new Runnable() {
public void run() {
try {
clientChannel.write(outboundPacket);
clientChannel.flush();
} catch (IOException e) {
}
}
});
while( inboundPacket.hasRemaining() ) {
Packet packet = serverChannel.read(1000*5);
assertNotNull(packet);
packet.read(inboundPacket);
}
outboundPacket.clear();
inboundPacket.clear();
assertEquals(outboundPacket.sliceAsBytes(), inboundPacket.sliceAsBytes());
}