use of org.redisson.codec.SerializationCodec in project redisson by redisson.
the class RedissonRemoteServiceTest method testInvocationWithSerializationCodec.
@Test
public void testInvocationWithSerializationCodec() {
RedissonClient server = Redisson.create(createConfig().setCodec(new SerializationCodec()));
RedissonClient client = Redisson.create(createConfig().setCodec(new SerializationCodec()));
try {
server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
RemoteInterface service = client.getRemoteService().get(RemoteInterface.class);
try {
assertThat(service.resultMethod(21L)).isEqualTo(42L);
} catch (Exception e) {
Assert.fail("Should be compatible with SerializationCodec");
}
try {
assertThat(service.doSomethingWithSerializablePojo(new SerializablePojo("test")).getStringField()).isEqualTo("test");
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Should be compatible with SerializationCodec");
}
try {
assertThat(service.doSomethingWithPojo(new Pojo("test")).getStringField()).isEqualTo("test");
Assert.fail("SerializationCodec should not be able to serialize a not serializable class");
} catch (Exception e) {
e.printStackTrace();
assertThat(e.getCause()).isInstanceOf(NotSerializableException.class);
assertThat(e.getCause().getMessage()).contains("Pojo");
}
} finally {
client.shutdown();
server.shutdown();
}
}
use of org.redisson.codec.SerializationCodec in project redisson by redisson.
the class RedissonLocalCachedMapSerializationCodecTest method createConfig.
public static Config createConfig() {
Config config = RedissonLocalCachedMapTest.createConfig();
config.setCodec(new SerializationCodec());
return config;
}
use of org.redisson.codec.SerializationCodec in project redisson by redisson.
the class RedissonTest method testSer.
@Test(expected = RedisException.class)
public void testSer() {
Config config = new Config();
config.useSingleServer().setAddress(RedisRunner.getDefaultRedisServerBindAddressAndPort());
config.setCodec(new SerializationCodec());
RedissonClient r = Redisson.create(config);
r.getMap("test").put("1", new Dummy());
}
Aggregations