package org.darkphoenixs.pool.redis;

import java.util.Properties;

import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.junit.Test;

import redis.clients.jedis.Jedis;

public class RedisConnectionFactoryTest {

	@Test
	public void test() throws Exception {

		Properties prop = new Properties();
		
		RedisConnectionFactory factory;
		
		try {
			factory = new RedisConnectionFactory(prop);

		} catch (Exception e) {
		}

		prop.setProperty(RedisConfig.ADDRESS_PROPERTY, RedisConfig.DEFAULT_HOST
				+ ":" + RedisConfig.DEFAULT_PORT);
		prop.setProperty(RedisConfig.CONN_TIMEOUT_PROPERTY,
				RedisConfig.DEFAULT_TIMEOUT + "");
		prop.setProperty(RedisConfig.SO_TIMEOUT_PROPERTY,
				RedisConfig.DEFAULT_TIMEOUT + "");
		prop.setProperty(RedisConfig.DATABASE_PROPERTY,
				RedisConfig.DEFAULT_DATABASE + "");
		prop.setProperty(RedisConfig.CLIENTNAME_PROPERTY, "Test");
		prop.setProperty(RedisConfig.PASSWORD_PROPERTY, "Test");

		factory = new RedisConnectionFactory(prop);

		factory = new RedisConnectionFactory(RedisConfig.DEFAULT_HOST,
				RedisConfig.DEFAULT_PORT, RedisConfig.DEFAULT_TIMEOUT,
				RedisConfig.DEFAULT_TIMEOUT, RedisConfig.DEFAULT_PASSWORD,
				RedisConfig.DEFAULT_DATABASE, RedisConfig.DEFAULT_CLIENTNAME);

		try {
			factory.makeObject();

		} catch (Exception e) {
		}

		factory.activateObject(new DefaultPooledObject<Jedis>(new Jedis()));

		try {
			factory.activateObject(new DefaultPooledObject<Jedis>(null));
		} catch (Exception e) {
		}

		factory.validateObject(new DefaultPooledObject<Jedis>(new Jedis()));

		try {
			factory.validateObject(new DefaultPooledObject<Jedis>(null));
		} catch (Exception e) {
		}

		factory.passivateObject(new DefaultPooledObject<Jedis>(new Jedis()));

		try {
			factory.passivateObject(new DefaultPooledObject<Jedis>(null));
		} catch (Exception e) {
		}

		factory.destroyObject(new DefaultPooledObject<Jedis>(new Jedis()));

		try {
			factory.destroyObject(new DefaultPooledObject<Jedis>(null));
		} catch (Exception e) {
		}
	}
}

@@ -143,16 +143,56 @@
 .Test;%0A%0A
+import redis.clients.jedis.HostAndPort;%0A
 import r
@@ -346,18 +346,16 @@
 ties();%0A
-%09%09
 %0A%09%09Redis
@@ -381,18 +381,16 @@
 actory;%0A
-%09%09
 %0A%09%09try %7B
@@ -1275,24 +1275,126 @@
 IENTNAME);%0A%0A
+%09%09factory.setHostAndPort(new HostAndPort(RedisConfig.DEFAULT_HOST,%0A%09%09%09%09RedisConfig.DEFAULT_PORT));%0A%09%09%0A
 %09%09try %7B%0A%09%09%09f

fix test