@Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {

      String m = (String) e.getMessage();
      assertEquals(data[counter], m);

      if (channel.getParent() != null) {
        channel.write(m);
      }

      counter++;
    }
    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
      ChannelBuffer m = (ChannelBuffer) e.getMessage();
      byte[] actual = new byte[m.readableBytes()];
      m.getBytes(0, actual);

      int lastIdx = counter;
      for (int i = 0; i < actual.length; i++) {
        assertEquals(data[i + lastIdx], actual[i]);
      }

      if (channel.getParent() != null) {
        channel.write(m);
      }

      counter += actual.length;
    }