当前位置: 首页>>代码示例>>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;未经允许,请勿转载。