use of org.redisson.codec.FstCodec in project redisson by redisson.
the class RedissonRemoteServiceTest method testInvocationWithFstCodec.
@Test
public void testInvocationWithFstCodec() {
RedissonClient server = Redisson.create(createConfig().setCodec(new FstCodec()));
RedissonClient client = Redisson.create(createConfig().setCodec(new FstCodec()));
try {
server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
RemoteInterface service = client.getRemoteService().get(RemoteInterface.class);
assertThat(service.resultMethod(21L)).as("Should be compatible with FstCodec").isEqualTo(42L);
try {
assertThat(service.doSomethingWithSerializablePojo(new SerializablePojo("test")).getStringField()).isEqualTo("test");
} catch (Exception e) {
Assert.fail("Should be compatible with FstCodec");
}
try {
assertThat(service.doSomethingWithPojo(new Pojo("test")).getStringField()).isEqualTo("test");
Assert.fail("FstCodec should not be able to serialize a not serializable class");
} catch (Exception e) {
assertThat(e.getCause()).isInstanceOf(RuntimeException.class);
assertThat(e.getCause().getMessage()).contains("Pojo does not implement Serializable");
}
} finally {
client.shutdown();
server.shutdown();
}
}
Aggregations