out.write(contents);
out.write(0);
out.flush();
// wait to receive message at handler
final Request req = new Request();
handler.takeRequest(req);
// verify correctness
Assert.assertEquals("server content length unequal", contents.length, req.getContent().length);
Assert.assertTrue("server contents do not match", Arrays.equals(contents, req.getContent()));
// echo message back to client
final Response rsp = new Response();
rsp.setPayload(contents);
Assert.assertTrue(Arrays.equals(contents, rsp.getPayload()));