DATAREDIS-617 - Remove dependency to org.codehaus.jackson.

Remove already deprecated jackson 1 dependency and related RedisSerializer / HashMapper implementations.

Original pull request: #240.
This commit is contained in:
Christoph Strobl
2017-03-10 17:03:49 +01:00
committed by Mark Paluch
parent 202bee64a2
commit f8eb3134e2
12 changed files with 10 additions and 296 deletions

View File

@@ -94,13 +94,6 @@
<!--Mapper -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.8.8</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>

View File

@@ -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

View File

@@ -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> T get(Object key, Class<T> type) {

View File

@@ -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<T> implements HashMapper<T, String, Object> {
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<T> type) {
this(type, new ObjectMapper());
mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
}
public JacksonHashMapper(Class<T> type, ObjectMapper mapper) {
this.mapper = mapper;
this.userType = TypeFactory.defaultInstance().constructType(type);
}
@SuppressWarnings("unchecked")
public T fromHash(Map<String, Object> hash) {
return (T) mapper.convertValue(hash, userType);
}
public Map<String, Object> toHash(T object) {
return mapper.convertValue(object, mapType);
}
}

View File

@@ -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 <a href="http://jackson.codehaus.org/">Jackson's</a>
* {@link ObjectMapper}.
* <p>
* This converter can be used to bind to typed beans, or untyped {@link java.util.HashMap HashMap} instances.
* <b>Note:</b>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<T> implements RedisSerializer<T> {
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<T> 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.
* <p>
* 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.
* <p>
* 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:
*
* <pre class="code">
* protected JavaType getJavaType(Class&lt;?&gt; clazz) {
* if (List.class.isAssignableFrom(clazz)) {
* return TypeFactory.collectionType(ArrayList.class, MyBean.class);
* } else {
* return super.getJavaType(clazz);
* }
* }
* </pre>
*
* @param clazz the class to return the java type for
* @return the java type
*/
protected JavaType getJavaType(Class<?> clazz) {
return TypeFactory.defaultInstance().constructType(clazz);
}
}

View File

@@ -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<Person> jacksonJsonSerializer = new JacksonJsonRedisSerializer<Person>(Person.class);
RedisTemplate<String, Person> jsonPersonTemplate = new RedisTemplate<String, Person>();
jsonPersonTemplate.setConnectionFactory(jedisConnectionFactory);
jsonPersonTemplate.setValueSerializer(jacksonJsonSerializer);
jsonPersonTemplate.afterPropertiesSet();
Jackson2JsonRedisSerializer<Person> jackson2JsonSerializer = new Jackson2JsonRedisSerializer<Person>(Person.class);
RedisTemplate<String, Person> jackson2JsonPersonTemplate = new RedisTemplate<String, Person>();
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 } });
}

View File

@@ -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<Person> personSerializer = new JacksonJsonRedisSerializer<Person>(Person.class);
Jackson2JsonRedisSerializer<Person> personSerializer = new Jackson2JsonRedisSerializer<Person>(Person.class);
this.template = new RedisTemplate<String, Person>();
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(personSerializer);

View File

@@ -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 <T> JacksonHashMapper<T> mapperFor(Class<T> t) {
return new JacksonHashMapper<T>(t);
}
}

View File

@@ -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<Person> serializer = new JacksonJsonRedisSerializer<Person>(Person.class);
Jackson2JsonRedisSerializer<Person> serializer = new Jackson2JsonRedisSerializer<Person>(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)));

View File

@@ -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<Person> jsonSerializer = new JacksonJsonRedisSerializer<Person>(Person.class);
Jackson2JsonRedisSerializer<Person> jackson2JsonSerializer = new Jackson2JsonRedisSerializer<Person>(Person.class);
StringRedisSerializer stringSerializer = new StringRedisSerializer();
@@ -85,12 +84,6 @@ public abstract class CollectionTestParams {
xstreamPersonTemplate.setValueSerializer(serializer);
xstreamPersonTemplate.afterPropertiesSet();
// json
RedisTemplate<String, Person> jsonPersonTemplate = new RedisTemplate<String, Person>();
jsonPersonTemplate.setConnectionFactory(jedisConnFactory);
jsonPersonTemplate.setValueSerializer(jsonSerializer);
jsonPersonTemplate.afterPropertiesSet();
// jackson2
RedisTemplate<String, Person> jackson2JsonPersonTemplate = new RedisTemplate<String, Person>();
jackson2JsonPersonTemplate.setConnectionFactory(jedisConnFactory);
@@ -125,11 +118,6 @@ public abstract class CollectionTestParams {
xstreamPersonTemplateLtc.setConnectionFactory(lettuceConnFactory);
xstreamPersonTemplateLtc.afterPropertiesSet();
RedisTemplate<String, Person> jsonPersonTemplateLtc = new RedisTemplate<String, Person>();
jsonPersonTemplateLtc.setValueSerializer(jsonSerializer);
jsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory);
jsonPersonTemplateLtc.afterPropertiesSet();
RedisTemplate<String, Person> jackson2JsonPersonTemplateLtc = new RedisTemplate<String, Person>();
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 } });
}
}

View File

@@ -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<Object, Object> {
throw new RuntimeException("Cannot init XStream", ex);
}
OxmSerializer serializer = new OxmSerializer(xstream, xstream);
JacksonJsonRedisSerializer<Person> jsonSerializer = new JacksonJsonRedisSerializer<Person>(Person.class);
JacksonJsonRedisSerializer<String> jsonStringSerializer = new JacksonJsonRedisSerializer<String>(String.class);
Jackson2JsonRedisSerializer<Person> jackson2JsonSerializer = new Jackson2JsonRedisSerializer<Person>(Person.class);
Jackson2JsonRedisSerializer<String> jackson2JsonStringSerializer = new Jackson2JsonRedisSerializer<String>(
String.class);
@@ -106,13 +103,6 @@ public class RedisMapTests extends AbstractRedisMapTests<Object, Object> {
xstreamGenericTemplate.setDefaultSerializer(serializer);
xstreamGenericTemplate.afterPropertiesSet();
RedisTemplate<String, Person> jsonPersonTemplate = new RedisTemplate<String, Person>();
jsonPersonTemplate.setConnectionFactory(jedisConnFactory);
jsonPersonTemplate.setDefaultSerializer(jsonSerializer);
jsonPersonTemplate.setHashKeySerializer(jsonSerializer);
jsonPersonTemplate.setHashValueSerializer(jsonStringSerializer);
jsonPersonTemplate.afterPropertiesSet();
RedisTemplate<String, Person> jackson2JsonPersonTemplate = new RedisTemplate<String, Person>();
jackson2JsonPersonTemplate.setConnectionFactory(jedisConnFactory);
jackson2JsonPersonTemplate.setDefaultSerializer(jackson2JsonSerializer);
@@ -142,13 +132,6 @@ public class RedisMapTests extends AbstractRedisMapTests<Object, Object> {
xGenericTemplateLettuce.setDefaultSerializer(serializer);
xGenericTemplateLettuce.afterPropertiesSet();
RedisTemplate<String, Person> jsonPersonTemplateLettuce = new RedisTemplate<String, Person>();
jsonPersonTemplateLettuce.setConnectionFactory(lettuceConnFactory);
jsonPersonTemplateLettuce.setDefaultSerializer(jsonSerializer);
jsonPersonTemplateLettuce.setHashKeySerializer(jsonSerializer);
jsonPersonTemplateLettuce.setHashValueSerializer(jsonStringSerializer);
jsonPersonTemplateLettuce.afterPropertiesSet();
RedisTemplate<String, Person> jackson2JsonPersonTemplateLettuce = new RedisTemplate<String, Person>();
jackson2JsonPersonTemplateLettuce.setConnectionFactory(lettuceConnFactory);
jackson2JsonPersonTemplateLettuce.setDefaultSerializer(jackson2JsonSerializer);
@@ -169,14 +152,12 @@ public class RedisMapTests extends AbstractRedisMapTests<Object, Object> {
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 } });

View File

@@ -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<Person> jsonSerializer = new JacksonJsonRedisSerializer<Person>(Person.class);
JacksonJsonRedisSerializer<String> jsonStringSerializer = new JacksonJsonRedisSerializer<String>(String.class);
Jackson2JsonRedisSerializer<Person> jackson2JsonSerializer = new Jackson2JsonRedisSerializer<Person>(Person.class);
Jackson2JsonRedisSerializer<String> jackson2JsonStringSerializer = new Jackson2JsonRedisSerializer<String>(
String.class);
@@ -265,13 +262,6 @@ public class RedisPropertiesTests extends RedisMapTests {
xstreamGenericTemplate.setDefaultSerializer(serializer);
xstreamGenericTemplate.afterPropertiesSet();
RedisTemplate<String, Person> jsonPersonTemplate = new RedisTemplate<String, Person>();
jsonPersonTemplate.setConnectionFactory(jedisConnFactory);
jsonPersonTemplate.setDefaultSerializer(jsonSerializer);
jsonPersonTemplate.setHashKeySerializer(jsonSerializer);
jsonPersonTemplate.setHashValueSerializer(jsonStringSerializer);
jsonPersonTemplate.afterPropertiesSet();
RedisTemplate<String, Person> jackson2JsonPersonTemplate = new RedisTemplate<String, Person>();
jackson2JsonPersonTemplate.setConnectionFactory(jedisConnFactory);
jackson2JsonPersonTemplate.setDefaultSerializer(jackson2JsonSerializer);
@@ -292,13 +282,6 @@ public class RedisPropertiesTests extends RedisMapTests {
xGenericTemplateLtc.setDefaultSerializer(serializer);
xGenericTemplateLtc.afterPropertiesSet();
RedisTemplate<String, Person> jsonPersonTemplateLtc = new RedisTemplate<String, Person>();
jsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory);
jsonPersonTemplateLtc.setDefaultSerializer(jsonSerializer);
jsonPersonTemplateLtc.setHashKeySerializer(jsonSerializer);
jsonPersonTemplateLtc.setHashValueSerializer(jsonStringSerializer);
jsonPersonTemplateLtc.afterPropertiesSet();
RedisTemplate<String, Person> jackson2JsonPersonTemplateLtc = new RedisTemplate<String, Person>();
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 } });
}