代码拉取完成,页面将自动刷新
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);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。