@ -1,5 +1,7 @@
package org.redisson ;
package org.redisson ;
import com.fasterxml.jackson.databind.JsonMappingException ;
import com.lambdaworks.redis.RedisException ;
import io.netty.util.concurrent.Future ;
import io.netty.util.concurrent.Future ;
import java.io.Serializable ;
import java.io.Serializable ;
@ -12,6 +14,7 @@ import java.util.concurrent.ExecutionException;
import org.junit.Assert ;
import org.junit.Assert ;
import org.junit.Test ;
import org.junit.Test ;
import org.redisson.codec.JsonJacksonCodec ;
import org.redisson.core.Predicate ;
import org.redisson.core.Predicate ;
import org.redisson.core.RMap ;
import org.redisson.core.RMap ;
@ -456,4 +459,39 @@ public class RedissonMapTest extends BaseTest {
Assert . assertEquals ( 0 , map . fastRemove ( ) ) ;
Assert . assertEquals ( 0 , map . fastRemove ( ) ) ;
Assert . assertEquals ( 1 , map . size ( ) ) ;
Assert . assertEquals ( 1 , map . size ( ) ) ;
}
}
@Test ( timeout = 5000 )
public void testDeserializationErrorReturnsErrorImmediately ( ) throws Exception {
redisson . getConfig ( ) . setCodec ( new JsonJacksonCodec ( ) ) ;
RMap < String , SimpleObjectWithoutDefaultConstructor > map = redisson . getMap ( "deserializationFailure" ) ;
SimpleObjectWithoutDefaultConstructor object = new SimpleObjectWithoutDefaultConstructor ( "test-val" ) ;
Assert . assertEquals ( "test-val" , object . getTestField ( ) ) ;
map . put ( "test-key" , object ) ;
try {
map . get ( "test-key" ) ;
Assert . fail ( "Expected exception from map.get() call" ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
}
public static class SimpleObjectWithoutDefaultConstructor {
private String testField ;
SimpleObjectWithoutDefaultConstructor ( String testField ) {
this . testField = testField ;
}
public String getTestField ( ) {
return testField ;
}
public void setTestField ( String testField ) {
this . testField = testField ;
}
}
}
}