use of com.baidu.disconf.core.common.restful.core.RemoteUrl in project disconf by knightliao.
the class RestfulMgrTestCase method tetGetJsonData.
/**
*
*/
@Test
public void tetGetJsonData() {
try {
RemoteUrl remoteUrl = new RemoteUrl(RemoteMockServer.ITEM_URL, RemoteMockServer.LOCAL_HOST_LIST);
ValueVo valueVo = restfulMgr.getJsonData(ValueVo.class, remoteUrl, 3, 3);
Assert.assertEquals(String.valueOf(RemoteMockServer.DEFAULT_ITEM_VALUE), valueVo.getValue());
} catch (Exception e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
use of com.baidu.disconf.core.common.restful.core.RemoteUrl in project disconf by knightliao.
the class FetcherMgrImpl method getValueFromServer.
/**
* 根据 URL 从远程 获取Value值
*/
public String getValueFromServer(String url) throws Exception {
// 远程地址
RemoteUrl remoteUrl = new RemoteUrl(url, hostList);
ValueVo confItemVo = restfulMgr.getJsonData(ValueVo.class, remoteUrl, retryTime, retrySleepSeconds);
LOGGER.debug("remote server return: " + confItemVo.toString());
if (confItemVo.getStatus().equals(Constants.NOTOK)) {
throw new Exception("status is not ok.");
}
return confItemVo.getValue();
}
use of com.baidu.disconf.core.common.restful.core.RemoteUrl in project disconf by knightliao.
the class FetcherMgrImpl method downloadFileFromServer.
/**
* 下载配置文件, remoteUrl是 url
*
* @throws Exception
*/
public String downloadFileFromServer(String url, String fileName, String targetFileDir) throws Exception {
// 下载的路径
String localDir = getLocalDownloadDirPath();
// 设置远程地址
RemoteUrl remoteUrl = new RemoteUrl(url, hostList);
// 下载
return restfulMgr.downloadFromServer(remoteUrl, fileName, localDir, localDownloadDirTemp, targetFileDir, enableLocalDownloadDirInClassPath, retryTime, retrySleepSeconds);
}
use of com.baidu.disconf.core.common.restful.core.RemoteUrl in project disconf by knightliao.
the class RestfulMgrTestCase method testZooHost.
/**
*
*/
@Test
public void testZooHost() {
try {
RemoteUrl remoteUrl = new RemoteUrl(RemoteMockServer.ZOO_URL, RemoteMockServer.LOCAL_HOST_LIST);
ValueVo valueVo = restfulMgr.getJsonData(ValueVo.class, remoteUrl, 3, 3);
Assert.assertEquals(String.valueOf(RemoteMockServer.ZOO_HOSTS), valueVo.getValue());
} catch (Exception e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
use of com.baidu.disconf.core.common.restful.core.RemoteUrl in project disconf by knightliao.
the class RestfulMgrTestCase method testZooPrefixUrl.
/**
*
*/
@Test
public void testZooPrefixUrl() {
try {
RemoteUrl remoteUrl = new RemoteUrl(RemoteMockServer.ZOO_PREFIX_URL, RemoteMockServer.LOCAL_HOST_LIST);
ValueVo valueVo = restfulMgr.getJsonData(ValueVo.class, remoteUrl, 3, 3);
Assert.assertEquals(String.valueOf(RemoteMockServer.ZOO_PREFIX_VALUE), valueVo.getValue());
} catch (Exception e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}