Search in sources :

Example 1 with FstCodec

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();
    }
}
Also used : RedissonClient(org.redisson.api.RedissonClient) FstCodec(org.redisson.codec.FstCodec) RemoteServiceTimeoutException(org.redisson.remote.RemoteServiceTimeoutException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) ExecutionException(java.util.concurrent.ExecutionException) RemoteServiceAckTimeoutException(org.redisson.remote.RemoteServiceAckTimeoutException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 NotSerializableException (java.io.NotSerializableException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1 RedissonClient (org.redisson.api.RedissonClient)1 FstCodec (org.redisson.codec.FstCodec)1 RemoteServiceAckTimeoutException (org.redisson.remote.RemoteServiceAckTimeoutException)1 RemoteServiceTimeoutException (org.redisson.remote.RemoteServiceTimeoutException)1