fix casting problems with varargs

add integration tests
This commit is contained in:
Costin Leau
2012-03-30 15:34:43 +03:00
parent e934acacd9
commit 9fc7c32117
5 changed files with 126 additions and 36 deletions

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2011-2012 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.connection.srp;
import org.junit.Test;
import org.springframework.data.redis.SettingsUtils;
import org.springframework.data.redis.connection.AbstractConnectionIntegrationTests;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.sredis.SRedisConnectionFactory;
import redis.client.RedisClient;
/**
* @author Costin Leau
*/
public class SrpConnectionIntegrationTests extends AbstractConnectionIntegrationTests {
SRedisConnectionFactory factory;
public SrpConnectionIntegrationTests() {
factory = new SRedisConnectionFactory();
factory.setPort(SettingsUtils.getPort());
factory.setHostName(SettingsUtils.getHost());
factory.afterPropertiesSet();
}
protected RedisConnectionFactory getConnectionFactory() {
return factory;
}
@Test
public void testRaw() throws Exception {
RedisClient rc = (RedisClient) factory.getConnection().getNativeConnection();
System.out.println(rc.dbsize());
System.out.println(rc.exists("foobar"));
rc.set("foobar", "barfoo");
System.out.println(rc.get("foobar"));
}
}

View File

@@ -23,6 +23,7 @@ import org.springframework.data.redis.SettingsUtils;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
import org.springframework.data.redis.connection.rjc.RjcConnectionFactory;
import org.springframework.data.redis.connection.sredis.SRedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer;
@@ -135,6 +136,32 @@ public abstract class CollectionTestParams {
jsonPersonTemplateRJC.setConnectionFactory(rjcConnFactory);
jsonPersonTemplateRJC.afterPropertiesSet();
// SRP
SRedisConnectionFactory srConnFactory = new SRedisConnectionFactory();
srConnFactory.setPort(SettingsUtils.getPort());
srConnFactory.setHostName(SettingsUtils.getHost());
srConnFactory.afterPropertiesSet();
RedisTemplate<String, String> stringTemplateSRP = new StringRedisTemplate(srConnFactory);
RedisTemplate<String, Person> personTemplateSRP = new RedisTemplate<String, Person>();
personTemplateSRP.setConnectionFactory(srConnFactory);
personTemplateSRP.afterPropertiesSet();
RedisTemplate<String, Person> xstreamStringTemplateSRP = new RedisTemplate<String, Person>();
xstreamStringTemplateSRP.setConnectionFactory(srConnFactory);
xstreamStringTemplateSRP.setDefaultSerializer(serializer);
xstreamStringTemplateSRP.afterPropertiesSet();
RedisTemplate<String, Person> xstreamPersonTemplateSRP = new RedisTemplate<String, Person>();
xstreamPersonTemplateSRP.setValueSerializer(serializer);
xstreamPersonTemplateSRP.setConnectionFactory(srConnFactory);
xstreamPersonTemplateSRP.afterPropertiesSet();
RedisTemplate<String, Person> jsonPersonTemplateSRP = new RedisTemplate<String, Person>();
jsonPersonTemplateSRP.setValueSerializer(jsonSerializer);
jsonPersonTemplateSRP.setConnectionFactory(srConnFactory);
jsonPersonTemplateSRP.afterPropertiesSet();
return Arrays.asList(new Object[][] { { stringFactory, stringTemplate }, { stringFactory, stringTemplateRJC },
{ personFactory, personTemplateRJC },
//{ stringFactory, stringTemplateJR },
@@ -146,6 +173,10 @@ public abstract class CollectionTestParams {
{ personFactory, jsonPersonTemplate },
//{ personFactory, jsonPersonTemplateJR },
{ stringFactory, xstreamStringTemplateRJC }, { personFactory, xstreamPersonTemplateRJC },
{ personFactory, jsonPersonTemplateRJC } });
{ personFactory, jsonPersonTemplateRJC },
{ stringFactory, stringTemplateSRP },{ personFactory, personTemplateSRP },
{ stringFactory, xstreamStringTemplateSRP }, { personFactory, xstreamPersonTemplateSRP },
{ personFactory, jsonPersonTemplateSRP }
});
}
}