Search in sources :

Example 6 with ValueVo

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);
    }
}
Also used : RemoteUrl(com.baidu.disconf.core.common.restful.core.RemoteUrl) ValueVo(com.baidu.disconf.core.common.json.ValueVo) Test(org.junit.Test)

Example 7 with ValueVo

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();
}
Also used : RemoteUrl(com.baidu.disconf.core.common.restful.core.RemoteUrl) ValueVo(com.baidu.disconf.core.common.json.ValueVo)

Example 8 with ValueVo

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;
}
Also used : Config(com.baidu.disconf.web.service.config.bo.Config) ValueVo(com.baidu.disconf.core.common.json.ValueVo)

Example 9 with 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);
    }
}
Also used : RemoteUrl(com.baidu.disconf.core.common.restful.core.RemoteUrl) ValueVo(com.baidu.disconf.core.common.json.ValueVo) Test(org.junit.Test)

Example 10 with ValueVo

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);
    }
}
Also used : RemoteUrl(com.baidu.disconf.core.common.restful.core.RemoteUrl) ValueVo(com.baidu.disconf.core.common.json.ValueVo) Test(org.junit.Test)

Aggregations

ValueVo (com.baidu.disconf.core.common.json.ValueVo)10 RemoteUrl (com.baidu.disconf.core.common.restful.core.RemoteUrl)4 Test (org.junit.Test)3 NoAuth (com.baidu.dsp.common.annotation.NoAuth)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Config (com.baidu.disconf.web.service.config.bo.Config)1 Mock (mockit.Mock)1