public Collection<InvalidProperty> process(Map<String, String> properties) {
    List<InvalidProperty> result = new Vector<InvalidProperty>();

    final String files = properties.get(XmlTestConstants.SETTINGS_FILES);
    final String project = properties.get(XmlTestConstants.SETTINGS_PROJECT);

    if (PropertiesUtil.isEmptyOrNull(project) && PropertiesUtil.isEmptyOrNull(files)) {
      result.add(
          new InvalidProperty(
              XmlTestConstants.SETTINGS_FILES, "Files or project option must be specified"));
    }

    return result;
  }
コード例 #2
0
 /**
  * It's not possible to store username/password in the test file, this cretentials are stored in a
  * properties file under user home directory.
  *
  * <p>This method would be used to fetch parameters for the test and allow to avoid committing
  * createntials with source file.
  *
  * @return username, repo, password
  */
 @NotNull
 public static Properties readGitHubAccount() {
   File propsFile = new File(System.getenv("USERPROFILE"), ".github.test.account");
   System.out.println("Loading properites from: " + propsFile);
   try {
     if (!propsFile.exists()) {
       FileUtil.createParentDirs(propsFile);
       Properties ps = new Properties();
       ps.setProperty(URL, "https://api.github.com");
       ps.setProperty(USERNAME, "jonnyzzz");
       ps.setProperty(REPOSITORY, "TeamCity.GitHub");
       ps.setProperty(PASSWORD_REV, rewind("some-password-written-end-to-front"));
       PropertiesUtil.storeProperties(ps, propsFile, "mock properties");
       return ps;
     } else {
       return PropertiesUtil.loadProperties(propsFile);
     }
   } catch (IOException e) {
     throw new RuntimeException("Could not read Amazon Access properties: " + e.getMessage(), e);
   }
 }