14 Star 27 Fork 9

hao0 / diablo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
SimpleDiabloClientTests.java 1.90 KB
一键复制 编辑 原始数据 按行查看 历史
hao0 提交于 2016-10-14 00:22 . support config listener
package me.hao0.diablo.client;
import me.hao0.diablo.client.listener.ConfigListener;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* Author: haolin
* Email: haolin.h0@gmail.com
*/
public class SimpleDiabloClientTests {
private SimpleDiabloClient client;
@Before
public void start(){
client = new SimpleDiabloClient();
client.setAppName("myapp");
client.setAppKey("123456x");
client.setServers("192.168.0.102:12345,127.0.0.1:12345");
client.addListener(new ConfigListener<String>() {
@Override
public String name() {
return "test_config1";
}
@Override
public void onUpdate(String newValue) {
System.out.println("test_config1 has updated to " + newValue);
}
});
client.start();
}
@After
public void shutdown(){
if (client != null){
client.shutdown();
}
}
@Test
public void testStartClient(){
SimpleDiabloClient client = new SimpleDiabloClient();
client.setAppName("myapp");
client.setAppKey("123456x");
client.setServers("127.0.0.1:12345,192.168.0.100:12345");
client.start();
}
@Test
public void testGet() throws InterruptedException {
String test0 = client.get("test_config1");
System.out.println(test0);
//TODO update the test1 on console
Thread.sleep(20000);
test0 = client.get("test_config1");
System.out.println(test0);
}
@Test
public void testGetJson() throws InterruptedException {
Student student = client.get("test99", Student.class);
System.out.println(student);
//TODO update the test99 on console
Thread.sleep(20000);
student = client.get("test99", Student.class);
System.out.println(student);
}
}
Java
1
https://gitee.com/hao0/diablo.git
git@gitee.com:hao0/diablo.git
hao0
diablo
diablo
master

搜索帮助