示例#1
0
 public static void main(String[] args) throws Exception {
   MukiGenerator generator = new MukiGenerator();
   ExecutionResult result = new ExecutionResult();
   result.setOk(true);
   generator.run(args, result);
   System.out.print("*** Muki v" + Version.id() + " Created by Gabriel Casarini ***");
   System.out.println(result.getLog());
 }
示例#2
0
  private static void loadEnvironment(String[] args) {
    final String defaultConfDir = getProperty("dash.application.conf.dir");
    final String defaultConfFile =
        (defaultConfDir != null ? defaultConfDir + File.separatorChar : "") + "conf.yml";

    ArgumentParser parser =
        ArgumentParsers.newArgumentParser("Dash", true)
            .description("Runs a performance test mix.")
            .version("${prog} " + Version.id())
            .epilog("Dash is a free software under Apache License Version 2.0");

    parser
        .addArgument("-c", "--conf")
        .help("the config file containing the test specification to run (default: ../conf/conf.yml")
        .required(false)
        .setDefault(new File(defaultConfFile))
        .type(File.class);

    parser
        .addArgument("-t", "--test")
        .help("the name of the test to run")
        .required(true)
        .type(String.class);

    parser
        .addArgument("-v", "--version")
        .help("print the version number")
        .action(Arguments.version());

    try {
      YamlEnv yamlEnv = new YamlEnv();
      Namespace namespace = parser.parseArgs(args);

      @SuppressWarnings("unchecked")
      HashMap<String, Object> env =
          (HashMap<String, Object>) yamlEnv.loadProperties((File) namespace.get("conf"));

      String test = namespace.getString("test");
      @SuppressWarnings("unchecked")
      HashMap<String, Object> testSpec = (HashMap<String, Object>) env.get(test);

      if (testSpec == null) {
        System.err.println("Test spec (" + test + ") does not exist in the config file.");
        throw new Error(); // todo: message or log or exit
      }

      for (Map.Entry<String, Object> entry : testSpec.entrySet()) {
        if (entry.getValue() != null) {
          System.setProperty(entry.getKey(), entry.getValue().toString());
        }
      }

    } catch (ArgumentParserException e) {
      parser.handleError(e);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }