Message { protected Message() { } protected  Message(); protected  Message(byte[] data); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testMessage() throws IOException { ByteBuffer buffer = ByteBuffer.allocate(8192); Message msg = messageFactory.createMessage("Some message"); msg.encode(buffer); buffer.flip(); Message msg1 = messageFactory.createMessage(buffer); assertEquals(msg.toString(), msg1.toString()); }