當前位置: 首頁>>代碼示例>>Java>>正文


Java DisconfCoreMgr類代碼示例

本文整理匯總了Java中com.baidu.disconf.client.core.DisconfCoreMgr的典型用法代碼示例。如果您正苦於以下問題:Java DisconfCoreMgr類的具體用法?Java DisconfCoreMgr怎麽用?Java DisconfCoreMgr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DisconfCoreMgr類屬於com.baidu.disconf.client.core包,在下文中一共展示了DisconfCoreMgr類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: demo

import com.baidu.disconf.client.core.DisconfCoreMgr; //導入依賴的package包/類
@Test
public void demo() {

    //
    // mock up factory method
    //
    new MockUp<DisconfCoreFactory>() {

        @Mock
        public DisconfCoreMgr getDisconfCoreMgr(Registry registry) throws Exception {

            FetcherMgr fetcherMgr = FetcherFactory.getFetcherMgr();

            // Watch 模塊
            final WatchMgr watchMgr = new WatchMgrMock().getMockInstance();
            watchMgr.init("", "", true);

            // registry
            DisconfCoreMgr disconfCoreMgr = new DisconfCoreMgrImpl(watchMgr, fetcherMgr,
                    registry);

            return disconfCoreMgr;
        }
    };

    //
    // 正式測試
    //
    try {

        LOGGER.info("================ BEFORE DISCONF ==============================");

        LOGGER.info("before disconf values:");
        LOGGER.info(String.valueOf("varA: " + confA.getVarA()));
        LOGGER.info(String.valueOf("varA2: " + confA.getVarA2()));
        LOGGER.info(String.valueOf("varAA: " + serviceA.getVarAA()));

        LOGGER.info("================ BEFORE DISCONF ==============================");

        //
        // start it
        //
        Set<String> fileSet = new HashSet<String>();
        fileSet.add("atomserverl.properties");
        fileSet.add("atomserverm_slave.properties");
        DisconfCenterHostFilesStore.getInstance().addJustHostFileSet(fileSet);

        DisconfMgr.getInstance().setApplicationContext(applicationContext);
        DisconfMgr.getInstance().start(StringUtil.parseStringToStringList(ScanPackTestCase.SCAN_PACK_NAME,
                DisconfMgrBean.SCAN_SPLIT_TOKEN));

        //
        LOGGER.info(DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().confToString());

        //
        LOGGER.info(DisconfStoreProcessorFactory.getDisconfStoreItemProcessor().confToString());

        LOGGER.info("================ AFTER DISCONF ==============================");

        LOGGER.info(String.valueOf("varA: " + confA.getVarA()));
        Assert.assertEquals(new Long(1000), confA.getVarA());

        LOGGER.info(String.valueOf("varA2: " + confA.getVarA2()));
        Assert.assertEquals(new Long(2000), confA.getVarA2());

        LOGGER.info(String.valueOf("varAA: " + serviceA.getVarAA()));
        Assert.assertEquals(new Integer(1000).intValue(), serviceA.getVarAA());

        LOGGER.info(String.valueOf("static var: " + StaticConf.getStaticvar()));
        Assert.assertEquals(new Integer(50).intValue(), StaticConf.getStaticvar());

        testDynamicGetter();

        LOGGER.info("================ AFTER DISCONF ==============================");

    } catch (Exception e) {

        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
 
開發者ID:knightliao,項目名稱:disconf,代碼行數:82,代碼來源:DisconfMgrTestCase.java


注:本文中的com.baidu.disconf.client.core.DisconfCoreMgr類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。