Ejemplo n.º 1
0
 protected static void initAtomConfig(String path, String appName, String dbKey) throws Exception {
   String globaStr = LoadPropsUtil.loadProps2Str(path + GLOBAL_PATH_SUFFIX);
   dataMap.put(TAtomConstants.getGlobalDataId(dbKey), globaStr);
   String appStr = LoadPropsUtil.loadProps2Str(path + APP_PATH_SUFFIX);
   dataMap.put(TAtomConstants.getAppDataId(appName, dbKey), appStr);
   TAtomDsConfDO tAtomDsConfDO = TAtomConfParser.parserTAtomDsConfDO(globaStr, appStr);
   String passwdStr = LoadPropsUtil.loadProps2Str(PASSWD_PATH_FULL);
   dataMap.put(
       TAtomConstants.getPasswdDataId(
           tAtomDsConfDO.getDbName(), tAtomDsConfDO.getDbType(), tAtomDsConfDO.getUserName()),
       passwdStr);
 }
Ejemplo n.º 2
0
  protected static void setMatrixMockInfo(String groupsPath, String key, boolean isOracle)
      throws Exception {
    // -----------------获取groups信息
    String groupsStr = LoadPropsUtil.loadProps2OneLine(groupsPath, key);
    if (groupsStr == null || StringUtils.isBlank(groupsStr)) {
      throw new Exception("指定path = " + groupsPath + ",key = " + key + "的groups信息为null或者为空字符。");
    }

    // -----------------oracle or mysql
    String groupPath = BaseAtomGroupTestCase.GROUP_PATH;
    String atomPath = BaseAtomGroupTestCase.ATOM_PATH;
    if (isOracle) {
      groupPath = BaseAtomGroupTestCase.GROUP_ORA_PATH;
      atomPath = BaseAtomGroupTestCase.ATOM_ORA_PATH;
    }

    // -----------------获取group信息
    BaseAtomGroupTestCase.dataMap = new HashMap<String, String>();
    String[] groupArr = groupsStr.split(",");

    for (String group : groupArr) {
      group = group.trim();
      String groupStr = "";
      groupStr =
          LoadPropsUtil.loadProps2OneLine(
              groupPath + group + BaseAtomGroupTestCase.PROPERTIES_FILE, group);
      if (groupsStr != null && StringUtils.isNotBlank(groupsStr)) {
        // 获取atom信息
        String[] atomArr = groupStr.split(",");
        for (String atom : atomArr) {
          atom = atom.trim();
          atom = atom.substring(0, atom.indexOf(":"));
          BaseAtomGroupTestCase.initAtomConfig(
              atomPath + atom, BaseAtomGroupTestCase.APPNAME, atom);
        }
        // 获取groupkey
        BaseAtomGroupTestCase.dataMap.put(TGroupDataSource.getFullDbGroupKey(group), groupStr);
      }
    }

    // -----------------dbgroups
    BaseAtomGroupTestCase.dataMap.put(
        new MessageFormat("com.taobao.tddl.v1_{0}_dbgroups")
            .format(new Object[] {BaseAtomGroupTestCase.APPNAME}),
        groupsStr);

    // 建立MockServer
    MockServer.setConfigInfos(BaseAtomGroupTestCase.dataMap);
  }