private String toString(RedisConnectionFactory redisConnectionFactory) {
   if (redisConnectionFactory == null) {
     return "<none>";
   } else {
     if (redisConnectionFactory instanceof JedisConnectionFactory) {
       JedisConnectionFactory jcf = (JedisConnectionFactory) redisConnectionFactory;
       return jcf.getHostName().toString() + ":" + jcf.getPort();
     } else if (redisConnectionFactory instanceof LettuceConnectionFactory) {
       LettuceConnectionFactory lcf = (LettuceConnectionFactory) redisConnectionFactory;
       return lcf.getHostName().toString() + ":" + lcf.getPort();
     }
     return "<unknown> " + redisConnectionFactory.getClass();
   }
 }
 @AfterClass
 public static void tearDown() {
   connectionFactory.destroy();
 }
 @BeforeClass
 public static void setup() {
   connectionFactory = new LettuceConnectionFactory();
   connectionFactory.setPort(RedisAvailableRule.REDIS_PORT);
   connectionFactory.afterPropertiesSet();
 }
  @Parameters
  public static Collection<Object[]> testParams() {
    // XStream serializer
    XStreamMarshaller xstream = new XStreamMarshaller();
    try {
      xstream.afterPropertiesSet();
    } catch (Exception ex) {
      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);

    // create Jedis Factory
    ObjectFactory<String> stringFactory = new StringObjectFactory();

    JedisConnectionFactory jedisConnFactory = new JedisConnectionFactory();
    jedisConnFactory.setUsePool(true);

    jedisConnFactory.setPort(SettingsUtils.getPort());
    jedisConnFactory.setHostName(SettingsUtils.getHost());

    jedisConnFactory.afterPropertiesSet();

    RedisTemplate<String, String> genericTemplate = new StringRedisTemplate(jedisConnFactory);

    RedisTemplate<String, String> xstreamGenericTemplate = new RedisTemplate<String, String>();
    xstreamGenericTemplate.setConnectionFactory(jedisConnFactory);
    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();

    // JRedis
    JredisConnectionFactory jredisConnFactory = new JredisConnectionFactory();
    jredisConnFactory.setUsePool(true);
    jredisConnFactory.setPort(SettingsUtils.getPort());
    jredisConnFactory.setHostName(SettingsUtils.getHost());
    jredisConnFactory.afterPropertiesSet();

    RedisTemplate<String, String> genericTemplateJR = new StringRedisTemplate(jredisConnFactory);
    RedisTemplate<String, Person> xGenericTemplateJR = new RedisTemplate<String, Person>();
    xGenericTemplateJR.setConnectionFactory(jredisConnFactory);
    xGenericTemplateJR.setDefaultSerializer(serializer);
    xGenericTemplateJR.afterPropertiesSet();

    RedisTemplate<String, Person> jsonPersonTemplateJR = new RedisTemplate<String, Person>();
    jsonPersonTemplateJR.setConnectionFactory(jredisConnFactory);
    jsonPersonTemplateJR.setDefaultSerializer(jsonSerializer);
    jsonPersonTemplateJR.setHashKeySerializer(jsonSerializer);
    jsonPersonTemplateJR.setHashValueSerializer(jsonStringSerializer);
    jsonPersonTemplateJR.afterPropertiesSet();

    // RJC

    // rjc
    RjcConnectionFactory rjcConnFactory = new RjcConnectionFactory();
    rjcConnFactory.setUsePool(true);
    rjcConnFactory.setPort(SettingsUtils.getPort());
    rjcConnFactory.setHostName(SettingsUtils.getHost());
    rjcConnFactory.afterPropertiesSet();

    RedisTemplate<String, String> genericTemplateRJC = new StringRedisTemplate(jredisConnFactory);
    RedisTemplate<String, Person> xGenericTemplateRJC = new RedisTemplate<String, Person>();
    xGenericTemplateRJC.setConnectionFactory(rjcConnFactory);
    xGenericTemplateRJC.setDefaultSerializer(serializer);
    xGenericTemplateRJC.afterPropertiesSet();

    RedisTemplate<String, Person> jsonPersonTemplateRJC = new RedisTemplate<String, Person>();
    jsonPersonTemplateRJC.setConnectionFactory(rjcConnFactory);
    jsonPersonTemplateRJC.setDefaultSerializer(jsonSerializer);
    jsonPersonTemplateRJC.setHashKeySerializer(jsonSerializer);
    jsonPersonTemplateRJC.setHashValueSerializer(jsonStringSerializer);
    jsonPersonTemplateRJC.afterPropertiesSet();

    // Lettuce
    LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
    lettuceConnFactory.setPort(SettingsUtils.getPort());
    lettuceConnFactory.setHostName(SettingsUtils.getHost());
    lettuceConnFactory.afterPropertiesSet();

    RedisTemplate<String, String> genericTemplateLtc = new StringRedisTemplate(lettuceConnFactory);
    RedisTemplate<String, Person> xGenericTemplateLtc = new RedisTemplate<String, Person>();
    xGenericTemplateLtc.setConnectionFactory(lettuceConnFactory);
    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();

    return Arrays.asList(
        new Object[][] {
          {stringFactory, stringFactory, genericTemplate},
          {stringFactory, stringFactory, genericTemplate},
          {stringFactory, stringFactory, genericTemplate},
          {stringFactory, stringFactory, genericTemplate},
          {stringFactory, stringFactory, xstreamGenericTemplate},
          {stringFactory, stringFactory, genericTemplateJR},
          {stringFactory, stringFactory, genericTemplateJR},
          {stringFactory, stringFactory, genericTemplateJR},
          {stringFactory, stringFactory, genericTemplateJR},
          {stringFactory, stringFactory, xGenericTemplateJR},
          {stringFactory, stringFactory, jsonPersonTemplate},
          {stringFactory, stringFactory, jsonPersonTemplateJR},
          {stringFactory, stringFactory, genericTemplateRJC},
          {stringFactory, stringFactory, genericTemplateRJC},
          {stringFactory, stringFactory, genericTemplateRJC},
          {stringFactory, stringFactory, genericTemplateRJC},
          {stringFactory, stringFactory, xGenericTemplateRJC},
          {stringFactory, stringFactory, jsonPersonTemplateRJC},
          {stringFactory, stringFactory, genericTemplateLtc},
          {stringFactory, stringFactory, genericTemplateLtc},
          {stringFactory, stringFactory, genericTemplateLtc},
          {stringFactory, stringFactory, genericTemplateLtc},
          {stringFactory, stringFactory, xGenericTemplateLtc},
          {stringFactory, stringFactory, jsonPersonTemplateLtc}
        });
  }