use of com.baidu.disconf.core.common.json.ValueVo 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.json.ValueVo 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.json.ValueVo in project disconf by knightliao.
the class ConfigFetchMgrImpl method getConfItemByParameter.
/**
* 根据详细参数获取配置返回
*/
public ValueVo getConfItemByParameter(Long appId, Long envId, String version, String key) {
Config config = configDao.getByParameter(appId, envId, version, key, DisConfigTypeEnum.ITEM);
if (config == null) {
return ConfigUtils.getErrorVo("cannot find this config");
}
ValueVo valueVo = new ValueVo();
valueVo.setValue(config.getValue());
valueVo.setStatus(Constants.OK);
return valueVo;
}
use of com.baidu.disconf.core.common.json.ValueVo 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.json.ValueVo 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);
}
}
Aggregations