diff --git a/pom.xml b/pom.xml index ac14e9f25..0e21a78f6 100644 --- a/pom.xml +++ b/pom.xml @@ -94,13 +94,6 @@ - - org.codehaus.jackson - jackson-mapper-asl - 1.8.8 - true - - com.fasterxml.jackson.core jackson-core diff --git a/src/main/asciidoc/reference/redis.adoc b/src/main/asciidoc/reference/redis.adoc index 154084ebf..11cb7b472 100644 --- a/src/main/asciidoc/reference/redis.adoc +++ b/src/main/asciidoc/reference/redis.adoc @@ -288,7 +288,7 @@ public void useCallback() { [[redis:serializer]] == Serializers -From the framework perspective, the data stored in Redis is just bytes. While Redis itself supports various types, for the most part these refer to the way the data is stored rather than what it represents. It is up to the user to decide whether the information gets translated into Strings or any other objects. The conversion between the user (custom) types and raw data (and vice-versa) is handled in Spring Data Redis through the `RedisSerializer` interface (package `org.springframework.data.redis.serializer`) which as the name implies, takes care of the serialization process. Multiple implementations are available out of the box, two of which have been already mentioned before in this documentation: the `StringRedisSerializer` and the `JdkSerializationRedisSerializer`. However one can use `OxmSerializer` for Object/XML mapping through Spring 3 http://docs.spring.io/spring/docs/current/spring-framework-reference/html/oxm.html[OXM] support or either `JacksonJsonRedisSerializer`, `Jackson2JsonRedisSerializer` or `GenericJackson2JsonRedisSerializer` for storing data in http://en.wikipedia.org/wiki/JSON[JSON] format. Do note that the storage format is not limited only to values - it can be used for keys, values or hashes without any restrictions.[[redis:serializer]] +From the framework perspective, the data stored in Redis is just bytes. While Redis itself supports various types, for the most part these refer to the way the data is stored rather than what it represents. It is up to the user to decide whether the information gets translated into Strings or any other objects. The conversion between the user (custom) types and raw data (and vice-versa) is handled in Spring Data Redis through the `RedisSerializer` interface (package `org.springframework.data.redis.serializer`) which as the name implies, takes care of the serialization process. Multiple implementations are available out of the box, two of which have been already mentioned before in this documentation: the `StringRedisSerializer` and the `JdkSerializationRedisSerializer`. However one can use `OxmSerializer` for Object/XML mapping through Spring 3 http://docs.spring.io/spring/docs/current/spring-framework-reference/html/oxm.html[OXM] support or either `Jackson2JsonRedisSerializer` or `GenericJackson2JsonRedisSerializer` for storing data in http://en.wikipedia.org/wiki/JSON[JSON] format. Do note that the storage format is not limited only to values - it can be used for keys, values or hashes without any restrictions.[[redis:serializer]] [[redis.hashmappers.root]] == Hash mapping diff --git a/src/main/java/org/springframework/data/redis/cache/RedisCache.java b/src/main/java/org/springframework/data/redis/cache/RedisCache.java index 0a5bce9ab..b507a2bdb 100644 --- a/src/main/java/org/springframework/data/redis/cache/RedisCache.java +++ b/src/main/java/org/springframework/data/redis/cache/RedisCache.java @@ -33,7 +33,6 @@ import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.RedisOperations; import org.springframework.data.redis.serializer.GenericToStringSerializer; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; @@ -98,7 +97,6 @@ public class RedisCache extends AbstractValueAdaptingCache { if (redisOperations.getValueSerializer() instanceof StringRedisSerializer || redisOperations.getValueSerializer() instanceof GenericToStringSerializer - || redisOperations.getValueSerializer() instanceof JacksonJsonRedisSerializer || redisOperations.getValueSerializer() instanceof Jackson2JsonRedisSerializer) { throw new IllegalArgumentException(String.format( "Redis does not allow keys with null value ¯\\_(ツ)_/¯. " @@ -116,7 +114,6 @@ public class RedisCache extends AbstractValueAdaptingCache { * @param key * @param type * @return - * @see DATAREDIS-243 */ public T get(Object key, Class type) { diff --git a/src/main/java/org/springframework/data/redis/hash/JacksonHashMapper.java b/src/main/java/org/springframework/data/redis/hash/JacksonHashMapper.java deleted file mode 100644 index 43294c875..000000000 --- a/src/main/java/org/springframework/data/redis/hash/JacksonHashMapper.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2011-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.hash; - -import java.util.Map; - -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; -import org.codehaus.jackson.map.type.TypeFactory; -import org.codehaus.jackson.type.JavaType; - -/** - * {@link HashMapper} based on Jackson library. Supports nested properties (rich objects). - * - * @author Costin Leau - * @author Thomas Darimont - * @author Christoph Strobl - * @deprecated since 1.7. Will be removed in subsequent version. - */ -@Deprecated -public class JacksonHashMapper implements HashMapper { - - private final ObjectMapper mapper; - private final JavaType userType; - private final JavaType mapType = TypeFactory.defaultInstance() - .constructMapType(Map.class, String.class, Object.class); - - /** - * Creates new {@link JacksonHashMapper}. - * - * @param type - */ - public JacksonHashMapper(Class type) { - - this(type, new ObjectMapper()); - mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL); - } - - public JacksonHashMapper(Class type, ObjectMapper mapper) { - - this.mapper = mapper; - this.userType = TypeFactory.defaultInstance().constructType(type); - } - - @SuppressWarnings("unchecked") - public T fromHash(Map hash) { - return (T) mapper.convertValue(hash, userType); - } - - public Map toHash(T object) { - return mapper.convertValue(object, mapType); - } -} diff --git a/src/main/java/org/springframework/data/redis/serializer/JacksonJsonRedisSerializer.java b/src/main/java/org/springframework/data/redis/serializer/JacksonJsonRedisSerializer.java deleted file mode 100644 index 1953f9c7d..000000000 --- a/src/main/java/org/springframework/data/redis/serializer/JacksonJsonRedisSerializer.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2011-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.serializer; - -import java.nio.charset.Charset; - -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.type.TypeFactory; -import org.codehaus.jackson.type.JavaType; -import org.springframework.util.Assert; - -/** - * {@link RedisSerializer} that can read and write JSON using Jackson's - * {@link ObjectMapper}. - *

- * This converter can be used to bind to typed beans, or untyped {@link java.util.HashMap HashMap} instances. - * Note:Null objects are serialized as empty arrays and vice versa. - * - * @author Costin Leau - * @author Thomas Darimont - * @author Christoph Strobl - * @deprecated ince 1.7. Will be removed in subsequent version. - */ -@Deprecated -public class JacksonJsonRedisSerializer implements RedisSerializer { - - public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); - - private final JavaType javaType; - - private ObjectMapper objectMapper = new ObjectMapper(); - - /** - * Creates a new {@link JacksonJsonRedisSerializer} for the given target {@link Class}. - * - * @param type - */ - public JacksonJsonRedisSerializer(Class type) { - this.javaType = getJavaType(type); - } - - /** - * Creates a new {@link JacksonJsonRedisSerializer} for the given target {@link JavaType}. - * - * @param javaType - */ - public JacksonJsonRedisSerializer(JavaType javaType) { - this.javaType = javaType; - } - - @SuppressWarnings("unchecked") - public T deserialize(byte[] bytes) throws SerializationException { - if (SerializationUtils.isEmpty(bytes)) { - return null; - } - try { - return (T) this.objectMapper.readValue(bytes, 0, bytes.length, javaType); - } catch (Exception ex) { - throw new SerializationException("Could not read JSON: " + ex.getMessage(), ex); - } - } - - public byte[] serialize(Object t) throws SerializationException { - if (t == null) { - return SerializationUtils.EMPTY_ARRAY; - } - try { - return this.objectMapper.writeValueAsBytes(t); - } catch (Exception ex) { - throw new SerializationException("Could not write JSON: " + ex.getMessage(), ex); - } - } - - /** - * Sets the {@code ObjectMapper} for this view. If not set, a default {@link ObjectMapper#ObjectMapper() ObjectMapper} - * is used. - *

- * Setting a custom-configured {@code ObjectMapper} is one way to take further control of the JSON serialization - * process. For example, an extended {@link org.codehaus.jackson.map.SerializerFactory} can be configured that - * provides custom serializers for specific types. The other option for refining the serialization process is to use - * Jackson's provided annotations on the types to be serialized, in which case a custom-configured ObjectMapper is - * unnecessary. - */ - public void setObjectMapper(ObjectMapper objectMapper) { - Assert.notNull(objectMapper, "'objectMapper' must not be null"); - this.objectMapper = objectMapper; - } - - /** - * Returns the Jackson {@link JavaType} for the specific class. - *

- * Default implementation returns {@link TypeFactory#type(java.lang.reflect.Type)}, but this can be overridden in - * subclasses, to allow for custom generic collection handling. For instance: - * - *

-	 * protected JavaType getJavaType(Class<?> clazz) {
-	 * 	if (List.class.isAssignableFrom(clazz)) {
-	 * 		return TypeFactory.collectionType(ArrayList.class, MyBean.class);
-	 * 	} else {
-	 * 		return super.getJavaType(clazz);
-	 * 	}
-	 * }
-	 * 
- * - * @param clazz the class to return the java type for - * @return the java type - */ - protected JavaType getJavaType(Class clazz) { - return TypeFactory.defaultInstance().constructType(clazz); - } -} diff --git a/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java b/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java index bb392f8c0..b8e0b3eb7 100644 --- a/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java +++ b/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java @@ -30,7 +30,6 @@ import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.GenericToStringSerializer; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.oxm.xstream.XStreamMarshaller; @@ -102,12 +101,6 @@ abstract public class AbstractOperationsTestParams { xstreamPersonTemplate.setValueSerializer(serializer); xstreamPersonTemplate.afterPropertiesSet(); - JacksonJsonRedisSerializer jacksonJsonSerializer = new JacksonJsonRedisSerializer(Person.class); - RedisTemplate jsonPersonTemplate = new RedisTemplate(); - jsonPersonTemplate.setConnectionFactory(jedisConnectionFactory); - jsonPersonTemplate.setValueSerializer(jacksonJsonSerializer); - jsonPersonTemplate.afterPropertiesSet(); - Jackson2JsonRedisSerializer jackson2JsonSerializer = new Jackson2JsonRedisSerializer(Person.class); RedisTemplate jackson2JsonPersonTemplate = new RedisTemplate(); jackson2JsonPersonTemplate.setConnectionFactory(jedisConnectionFactory); @@ -128,7 +121,6 @@ abstract public class AbstractOperationsTestParams { { personTemplate, stringFactory, personFactory }, // { xstreamStringTemplate, stringFactory, stringFactory }, // { xstreamPersonTemplate, stringFactory, personFactory }, // - { jsonPersonTemplate, stringFactory, personFactory }, // { jackson2JsonPersonTemplate, stringFactory, personFactory }, // { genericJackson2JsonPersonTemplate, stringFactory, personFactory } }); } diff --git a/src/test/java/org/springframework/data/redis/core/script/AbstractDefaultScriptExecutorTests.java b/src/test/java/org/springframework/data/redis/core/script/AbstractDefaultScriptExecutorTests.java index b4b657e90..06cd52c4f 100644 --- a/src/test/java/org/springframework/data/redis/core/script/AbstractDefaultScriptExecutorTests.java +++ b/src/test/java/org/springframework/data/redis/core/script/AbstractDefaultScriptExecutorTests.java @@ -34,7 +34,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.SessionCallback; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.GenericToStringSerializer; -import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.test.util.MinimumRedisVersionRule; import org.springframework.scripting.support.StaticScriptSource; @@ -172,7 +172,7 @@ public abstract class AbstractDefaultScriptExecutorTests { @SuppressWarnings("unchecked") @Test public void testExecuteCustomResultSerializer() { - JacksonJsonRedisSerializer personSerializer = new JacksonJsonRedisSerializer(Person.class); + Jackson2JsonRedisSerializer personSerializer = new Jackson2JsonRedisSerializer(Person.class); this.template = new RedisTemplate(); template.setKeySerializer(new StringRedisSerializer()); template.setValueSerializer(personSerializer); diff --git a/src/test/java/org/springframework/data/redis/mapping/JacksonHashMapperTest.java b/src/test/java/org/springframework/data/redis/mapping/JacksonHashMapperTest.java deleted file mode 100644 index 50ac5f3a0..000000000 --- a/src/test/java/org/springframework/data/redis/mapping/JacksonHashMapperTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2011-2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.mapping; - -import org.springframework.data.redis.hash.JacksonHashMapper; - -/** - * @author Costin Leau - * @author Christoph Strobl - */ -public class JacksonHashMapperTest extends AbstractHashMapperTest { - - protected JacksonHashMapper mapperFor(Class t) { - return new JacksonHashMapper(t); - } - -} diff --git a/src/test/java/org/springframework/data/redis/serializer/SimpleRedisSerializerTests.java b/src/test/java/org/springframework/data/redis/serializer/SimpleRedisSerializerTests.java index 7a96ec627..028502878 100644 --- a/src/test/java/org/springframework/data/redis/serializer/SimpleRedisSerializerTests.java +++ b/src/test/java/org/springframework/data/redis/serializer/SimpleRedisSerializerTests.java @@ -32,6 +32,7 @@ import org.springframework.oxm.xstream.XStreamMarshaller; /** * @author Jennifer Hickey * @author Mark Paluch + * @author Christoph Strobl */ public class SimpleRedisSerializerTests { @@ -169,7 +170,7 @@ public class SimpleRedisSerializerTests { @Test public void testJsonSerializer() throws Exception { - JacksonJsonRedisSerializer serializer = new JacksonJsonRedisSerializer(Person.class); + Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer(Person.class); String value = UUID.randomUUID().toString(); Person p1 = new Person(value, value, 1, new Address(value, 2)); assertEquals(p1, serializer.deserialize(serializer.serialize(p1))); diff --git a/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java b/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java index cbe626d2b..875d05252 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java +++ b/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 the original author or authors. + * Copyright 2011-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,6 @@ import org.springframework.data.redis.connection.lettuce.LettuceTestClientResour import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.oxm.xstream.XStreamMarshaller; @@ -40,6 +39,7 @@ import org.springframework.oxm.xstream.XStreamMarshaller; * @author Costin Leau * @author Thomas Darimont * @author Mark Paluch + * @author Christoph Strobl */ public abstract class CollectionTestParams { @@ -52,7 +52,6 @@ public abstract class CollectionTestParams { throw new RuntimeException("Cannot init XStream", ex); } OxmSerializer serializer = new OxmSerializer(xstream, xstream); - JacksonJsonRedisSerializer jsonSerializer = new JacksonJsonRedisSerializer(Person.class); Jackson2JsonRedisSerializer jackson2JsonSerializer = new Jackson2JsonRedisSerializer(Person.class); StringRedisSerializer stringSerializer = new StringRedisSerializer(); @@ -85,12 +84,6 @@ public abstract class CollectionTestParams { xstreamPersonTemplate.setValueSerializer(serializer); xstreamPersonTemplate.afterPropertiesSet(); - // json - RedisTemplate jsonPersonTemplate = new RedisTemplate(); - jsonPersonTemplate.setConnectionFactory(jedisConnFactory); - jsonPersonTemplate.setValueSerializer(jsonSerializer); - jsonPersonTemplate.afterPropertiesSet(); - // jackson2 RedisTemplate jackson2JsonPersonTemplate = new RedisTemplate(); jackson2JsonPersonTemplate.setConnectionFactory(jedisConnFactory); @@ -125,11 +118,6 @@ public abstract class CollectionTestParams { xstreamPersonTemplateLtc.setConnectionFactory(lettuceConnFactory); xstreamPersonTemplateLtc.afterPropertiesSet(); - RedisTemplate jsonPersonTemplateLtc = new RedisTemplate(); - jsonPersonTemplateLtc.setValueSerializer(jsonSerializer); - jsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory); - jsonPersonTemplateLtc.afterPropertiesSet(); - RedisTemplate jackson2JsonPersonTemplateLtc = new RedisTemplate(); jackson2JsonPersonTemplateLtc.setValueSerializer(jackson2JsonSerializer); jackson2JsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory); @@ -144,14 +132,14 @@ public abstract class CollectionTestParams { return Arrays .asList(new Object[][] { { stringFactory, stringTemplate }, { doubleAsStringObjectFactory, stringTemplate }, { personFactory, personTemplate }, { stringFactory, xstreamStringTemplate }, - { personFactory, xstreamPersonTemplate }, { personFactory, jsonPersonTemplate }, + { personFactory, xstreamPersonTemplate }, { personFactory, jackson2JsonPersonTemplate }, { rawFactory, rawTemplate }, // lettuce { stringFactory, stringTemplateLtc }, { personFactory, personTemplateLtc }, { doubleAsStringObjectFactory, stringTemplateLtc }, { personFactory, personTemplateLtc }, { stringFactory, xstreamStringTemplateLtc }, { personFactory, xstreamPersonTemplateLtc }, - { personFactory, jsonPersonTemplateLtc }, { personFactory, jackson2JsonPersonTemplateLtc }, + { personFactory, jackson2JsonPersonTemplateLtc }, { rawFactory, rawTemplateLtc } }); } } diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java index 790e99ede..5240b45e1 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java @@ -34,7 +34,6 @@ import org.springframework.data.redis.connection.lettuce.LettuceTestClientResour import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.oxm.xstream.XStreamMarshaller; @@ -73,8 +72,6 @@ public class RedisMapTests extends AbstractRedisMapTests { throw new RuntimeException("Cannot init XStream", ex); } OxmSerializer serializer = new OxmSerializer(xstream, xstream); - JacksonJsonRedisSerializer jsonSerializer = new JacksonJsonRedisSerializer(Person.class); - JacksonJsonRedisSerializer jsonStringSerializer = new JacksonJsonRedisSerializer(String.class); Jackson2JsonRedisSerializer jackson2JsonSerializer = new Jackson2JsonRedisSerializer(Person.class); Jackson2JsonRedisSerializer jackson2JsonStringSerializer = new Jackson2JsonRedisSerializer( String.class); @@ -106,13 +103,6 @@ public class RedisMapTests extends AbstractRedisMapTests { xstreamGenericTemplate.setDefaultSerializer(serializer); xstreamGenericTemplate.afterPropertiesSet(); - RedisTemplate jsonPersonTemplate = new RedisTemplate(); - jsonPersonTemplate.setConnectionFactory(jedisConnFactory); - jsonPersonTemplate.setDefaultSerializer(jsonSerializer); - jsonPersonTemplate.setHashKeySerializer(jsonSerializer); - jsonPersonTemplate.setHashValueSerializer(jsonStringSerializer); - jsonPersonTemplate.afterPropertiesSet(); - RedisTemplate jackson2JsonPersonTemplate = new RedisTemplate(); jackson2JsonPersonTemplate.setConnectionFactory(jedisConnFactory); jackson2JsonPersonTemplate.setDefaultSerializer(jackson2JsonSerializer); @@ -142,13 +132,6 @@ public class RedisMapTests extends AbstractRedisMapTests { xGenericTemplateLettuce.setDefaultSerializer(serializer); xGenericTemplateLettuce.afterPropertiesSet(); - RedisTemplate jsonPersonTemplateLettuce = new RedisTemplate(); - jsonPersonTemplateLettuce.setConnectionFactory(lettuceConnFactory); - jsonPersonTemplateLettuce.setDefaultSerializer(jsonSerializer); - jsonPersonTemplateLettuce.setHashKeySerializer(jsonSerializer); - jsonPersonTemplateLettuce.setHashValueSerializer(jsonStringSerializer); - jsonPersonTemplateLettuce.afterPropertiesSet(); - RedisTemplate jackson2JsonPersonTemplateLettuce = new RedisTemplate(); jackson2JsonPersonTemplateLettuce.setConnectionFactory(lettuceConnFactory); jackson2JsonPersonTemplateLettuce.setDefaultSerializer(jackson2JsonSerializer); @@ -169,14 +152,12 @@ public class RedisMapTests extends AbstractRedisMapTests { return Arrays.asList(new Object[][] { { stringFactory, stringFactory, genericTemplate }, { personFactory, personFactory, genericTemplate }, { stringFactory, personFactory, genericTemplate }, { personFactory, stringFactory, genericTemplate }, { personFactory, stringFactory, xstreamGenericTemplate }, - { personFactory, stringFactory, jsonPersonTemplate }, { personFactory, stringFactory, jackson2JsonPersonTemplate }, { rawFactory, rawFactory, rawTemplate }, { stringFactory, stringFactory, genericTemplateLettuce }, { personFactory, personFactory, genericTemplateLettuce }, { stringFactory, personFactory, genericTemplateLettuce }, { personFactory, stringFactory, genericTemplateLettuce }, { personFactory, stringFactory, xGenericTemplateLettuce }, - { personFactory, stringFactory, jsonPersonTemplateLettuce }, { personFactory, stringFactory, jackson2JsonPersonTemplateLettuce }, { stringFactory, doubleFactory, stringTemplateLtc }, { stringFactory, longFactory, stringTemplateLtc }, { rawFactory, rawFactory, rawTemplateLtc } }); diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesTests.java index 3baf73df2..1171c6ba0 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesTests.java @@ -44,7 +44,6 @@ import org.springframework.data.redis.connection.lettuce.LettuceTestClientResour import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.oxm.xstream.XStreamMarshaller; @@ -239,8 +238,6 @@ public class RedisPropertiesTests extends RedisMapTests { throw new RuntimeException("Cannot init XStream", ex); } OxmSerializer serializer = new OxmSerializer(xstream, xstream); - JacksonJsonRedisSerializer jsonSerializer = new JacksonJsonRedisSerializer(Person.class); - JacksonJsonRedisSerializer jsonStringSerializer = new JacksonJsonRedisSerializer(String.class); Jackson2JsonRedisSerializer jackson2JsonSerializer = new Jackson2JsonRedisSerializer(Person.class); Jackson2JsonRedisSerializer jackson2JsonStringSerializer = new Jackson2JsonRedisSerializer( String.class); @@ -265,13 +262,6 @@ public class RedisPropertiesTests extends RedisMapTests { xstreamGenericTemplate.setDefaultSerializer(serializer); xstreamGenericTemplate.afterPropertiesSet(); - RedisTemplate jsonPersonTemplate = new RedisTemplate(); - jsonPersonTemplate.setConnectionFactory(jedisConnFactory); - jsonPersonTemplate.setDefaultSerializer(jsonSerializer); - jsonPersonTemplate.setHashKeySerializer(jsonSerializer); - jsonPersonTemplate.setHashValueSerializer(jsonStringSerializer); - jsonPersonTemplate.afterPropertiesSet(); - RedisTemplate jackson2JsonPersonTemplate = new RedisTemplate(); jackson2JsonPersonTemplate.setConnectionFactory(jedisConnFactory); jackson2JsonPersonTemplate.setDefaultSerializer(jackson2JsonSerializer); @@ -292,13 +282,6 @@ public class RedisPropertiesTests extends RedisMapTests { xGenericTemplateLtc.setDefaultSerializer(serializer); xGenericTemplateLtc.afterPropertiesSet(); - RedisTemplate jsonPersonTemplateLtc = new RedisTemplate(); - jsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory); - jsonPersonTemplateLtc.setDefaultSerializer(jsonSerializer); - jsonPersonTemplateLtc.setHashKeySerializer(jsonSerializer); - jsonPersonTemplateLtc.setHashValueSerializer(jsonStringSerializer); - jsonPersonTemplateLtc.afterPropertiesSet(); - RedisTemplate jackson2JsonPersonTemplateLtc = new RedisTemplate(); jackson2JsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory); jackson2JsonPersonTemplateLtc.setDefaultSerializer(jackson2JsonSerializer); @@ -309,13 +292,12 @@ public class RedisPropertiesTests extends RedisMapTests { return Arrays.asList(new Object[][] { { stringFactory, stringFactory, genericTemplate }, { stringFactory, stringFactory, genericTemplate }, { stringFactory, stringFactory, genericTemplate }, { stringFactory, stringFactory, genericTemplate }, { stringFactory, stringFactory, xstreamGenericTemplate }, - { stringFactory, stringFactory, jsonPersonTemplate }, { stringFactory, stringFactory, jackson2JsonPersonTemplate }, { stringFactory, stringFactory, genericTemplateLtc }, { stringFactory, stringFactory, genericTemplateLtc }, { stringFactory, stringFactory, genericTemplateLtc }, { stringFactory, stringFactory, genericTemplateLtc }, { stringFactory, doubleFactory, genericTemplateLtc }, { stringFactory, longFactory, genericTemplateLtc }, - { stringFactory, stringFactory, xGenericTemplateLtc }, { stringFactory, stringFactory, jsonPersonTemplateLtc }, + { stringFactory, stringFactory, xGenericTemplateLtc }, { stringFactory, stringFactory, jackson2JsonPersonTemplateLtc } }); }