@Test
@SuppressWarnings ({"unchecked", "rawtypes"})
public void testMessageEncoding() throws IOException {
for (Message message : testMessages) {
MessageCodec codec = codecLookup.find(message.getClass());
ByteBuf encoded;
Message decoded;
try {
encoded = codec.encodeToServer(message);
decoded = codec.decodeFromClient(encoded);
} catch (Throwable t) {
t.printStackTrace();
fail("Failed (C -> S) for: " + message.getClass().getName() + ", " + message);
return;
}
assertEquals("Failed (C -> S) for: " + message.getClass().getName(), message, decoded);
try {
encoded = codec.encodeToClient(message);
decoded = codec.decodeFromServer(encoded);
} catch (Throwable t) {
t.printStackTrace();
fail("Failed (S -> C) for: " + message.getClass().getName() + ", " + message);
return;
}