// Path: shiziqiu-configuration-core/src/main/java/com/shiziqiu/configuration/core/zk/ShiZiQiuConfClient.java
// public class ShiZiQiuConfClient {
// 
// 	private static Logger logger = LoggerFactory.getLogger(ShiZiQiuConfClient.class);
// 	public static Properties localProp = PropertiesUtil.loadProperties("local.properties");
// 	private static Cache cache;
// 	
// 	static {
// 		CacheManager manager = CacheManager.create();
// 		cache = new Cache(Configure.CONF_DATA_PATH, 10000, false, true, 1800, 1800);
// 		manager.addCache(cache);
// 	}
// 	
// 	public static void set(String key, String value) {
// 		if (cache != null) {
// 			logger.info(">>>>>>>>>> shiziqiu-conf: 初始化配置: [{}:{}]", new Object[]{key, value});
// 			cache.put(new Element(key, value));
// 		}
// 	}
// 	
// 	public static void update(String key, String value) {
// 		if (cache != null) {
// 			if (cache.get(key)!=null) {
// 				logger.info(">>>>>>>>>> shiziqiu-conf: 更新配置: [{}:{}]", new Object[]{key, value});
// 				cache.put(new Element(key, value));
// 			}
// 		}
// 	}
// 	
// 	public static String get(String key, String defaultVal) {
// 		if (localProp!=null && localProp.containsKey(key)) {
// 			return localProp.getProperty(key);
// 		}
// 		if (cache != null) {
// 			Element element = cache.get(key);
// 			if (element != null) {
// 				return (String) element.getObjectValue();
// 			}
// 		}
// 		String zkData = ShiZiQiuZkConfClient.getPathDataByKey(key);
// 		if (zkData!=null) {
// 			set(key, zkData);
// 			return zkData;
// 		}
// 
// 		return defaultVal;
// 	}
// 
// 	public static boolean remove(String key) {
// 		if (cache != null) {
// 			logger.info(">>>>>>>>>> shiziqiu-conf: 删除配置：key ", key);
// 			return cache.remove(key);
// 		}
// 		return false;
// 	}
// 
// 	public static void main(String[] args) {
// 		String key = "key";
// 		String value = "hello";
// 		set(key, value);
// 		System.out.println(get(key, "-1"));
// 	}
// 	
// 	
// }


import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.shiziqiu.configuration.core.zk.ShiZiQiuConfClient;
package com.shiziqiu.example;


/**
 * ²âÊÔ°¸Àý
 * @title : TestShiZiQiuConfClient
 * @author : crazy
 * @date : 2017Äê9ÔÂ7ÈÕ ÏÂÎç2:21:41
 * @Fun :
 * ÔÚ×Ô¼ºµÄxml×îÉÏÃæÌí¼ÓÏÂÃæÅäÖÃ
 * <bean id="shiziqiuConfPropertyPlaceholderConfigurer" class="com.shiziqiu.configuration.core.spring.ShiZiQiuConfPlaceholderConfigurer" />
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationcontext-shiziqiu-conf.xml")
public class TestShiZiQiuConfClient {

	@Test
	public void TestShiZiQiuConfClientGet(){
		/**
		 * ´ÓÅäÖÃÎÄ¼þÀï»ñÈ¡ÅäÖÃµÄÊý¾Ý
		 */
// Path: shiziqiu-configuration-core/src/main/java/com/shiziqiu/configuration/core/zk/ShiZiQiuConfClient.java
// public class ShiZiQiuConfClient {
// 
// 	private static Logger logger = LoggerFactory.getLogger(ShiZiQiuConfClient.class);
// 	public static Properties localProp = PropertiesUtil.loadProperties("local.properties");
// 	private static Cache cache;
// 	
// 	static {
// 		CacheManager manager = CacheManager.create();
// 		cache = new Cache(Configure.CONF_DATA_PATH, 10000, false, true, 1800, 1800);
// 		manager.addCache(cache);
// 	}
// 	
// 	public static void set(String key, String value) {
// 		if (cache != null) {
// 			logger.info(">>>>>>>>>> shiziqiu-conf: 初始化配置: [{}:{}]", new Object[]{key, value});
// 			cache.put(new Element(key, value));
// 		}
// 	}
// 	
// 	public static void update(String key, String value) {
// 		if (cache != null) {
// 			if (cache.get(key)!=null) {
// 				logger.info(">>>>>>>>>> shiziqiu-conf: 更新配置: [{}:{}]", new Object[]{key, value});
// 				cache.put(new Element(key, value));
// 			}
// 		}
// 	}
// 	
// 	public static String get(String key, String defaultVal) {
// 		if (localProp!=null && localProp.containsKey(key)) {
// 			return localProp.getProperty(key);
// 		}
// 		if (cache != null) {
// 			Element element = cache.get(key);
// 			if (element != null) {
// 				return (String) element.getObjectValue();
// 			}
// 		}
// 		String zkData = ShiZiQiuZkConfClient.getPathDataByKey(key);
// 		if (zkData!=null) {
// 			set(key, zkData);
// 			return zkData;
// 		}
// 
// 		return defaultVal;
// 	}
// 
// 	public static boolean remove(String key) {
// 		if (cache != null) {
// 			logger.info(">>>>>>>>>> shiziqiu-conf: 删除配置：key ", key);
// 			return cache.remove(key);
// 		}
// 		return false;
// 	}
// 
// 	public static void main(String[] args) {
// 		String key = "key";
// 		String value = "hello";
// 		set(key, value);
// 		System.out.println(get(key, "-1"));
// 	}
// 	
// 	
// }


// Path: shiziqiu-configuration-example/src/test/java/com/shiziqiu/example/TestShiZiQiuConfClient.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.shiziqiu.configuration.core.zk.ShiZiQiuConfClient;

package com.shiziqiu.example;


/**
 * ²âÊÔ°¸Àý
 * @title : TestShiZiQiuConfClient
 * @author : crazy
 * @date : 2017Äê9ÔÂ7ÈÕ ÏÂÎç2:21:41
 * @Fun :
 * ÔÚ×Ô¼ºµÄxml×îÉÏÃæÌí¼ÓÏÂÃæÅäÖÃ
 * <bean id="shiziqiuConfPropertyPlaceholderConfigurer" class="com.shiziqiu.configuration.core.spring.ShiZiQiuConfPlaceholderConfigurer" />
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationcontext-shiziqiu-conf.xml")
public class TestShiZiQiuConfClient {

	@Test
	public void TestShiZiQiuConfClientGet(){
		/**
		 * ´ÓÅäÖÃÎÄ¼þÀï»ñÈ¡ÅäÖÃµÄÊý¾Ý
		 */
		String redis = ShiZiQiuConfClient.get("redis.port", null);