@Test public void config_extension() throws Exception { File ext = folder.newFile().getCanonicalFile(); ProfileBuilder builder = new ProfileBuilder(folder.getRoot()); File profile = builder.getProfile(); File script = builder.getScript(); List<String> arguments = new ArrayList<>(); Collections.addAll(arguments, "-profile", profile.getAbsolutePath()); Collections.addAll(arguments, "-script", script.getAbsolutePath()); Collections.addAll(arguments, "-batch", "tbatch"); Collections.addAll(arguments, "-X-testing", ext.getPath()); Configuration conf = Yaess.parseConfiguration(arguments.toArray(new String[arguments.size()])); assertThat(conf.mode, is(Mode.BATCH)); assertThat(conf.batchId, is("tbatch")); assertThat(conf.flowId, is(nullValue())); assertThat(conf.executionId, is(nullValue())); assertThat(conf.phase, is(nullValue())); assertThat(conf.arguments.keySet(), hasSize(0)); assertThat(conf.extensions, hasSize(1)); assertThat(((FileBlob) conf.extensions.get(0).getData()).getFile().getCanonicalFile(), is(ext)); }
static Configuration parseConfiguration(String[] args) throws ParseException { assert args != null; LOG.debug("Analyzing YAESS bootstrap arguments: {}", Arrays.toString(args)); ArgumentList argList = ArgumentList.parse(args); LOG.debug("Argument List: {}", argList); CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, argList.getStandardAsArray()); String profile = cmd.getOptionValue(OPT_PROFILE.getOpt()); LOG.debug("Profile: {}", profile); String script = cmd.getOptionValue(OPT_SCRIPT.getOpt()); LOG.debug("Script: {}", script); String batchId = cmd.getOptionValue(OPT_BATCH_ID.getOpt()); LOG.debug("Batch ID: {}", batchId); String flowId = cmd.getOptionValue(OPT_FLOW_ID.getOpt()); LOG.debug("Flow ID: {}", flowId); String executionId = cmd.getOptionValue(OPT_EXECUTION_ID.getOpt()); LOG.debug("Execution ID: {}", executionId); String phaseName = cmd.getOptionValue(OPT_PHASE_NAME.getOpt()); LOG.debug("Phase name: {}", phaseName); String plugins = cmd.getOptionValue(OPT_PLUGIN.getOpt()); LOG.debug("Plug-ins: {}", plugins); Properties arguments = cmd.getOptionProperties(OPT_ARGUMENT.getOpt()); LOG.debug("Execution arguments: {}", arguments); Properties variables = cmd.getOptionProperties(OPT_ENVIRONMENT_VARIABLE.getOpt()); LOG.debug("Environment variables: {}", variables); Properties definitions = cmd.getOptionProperties(OPT_DEFINITION.getOpt()); LOG.debug("YAESS feature definitions: {}", definitions); LOG.debug("Loading plugins: {}", plugins); List<File> pluginFiles = CommandLineUtil.parseFileList(plugins); ClassLoader loader = CommandLineUtil.buildPluginLoader(Yaess.class.getClassLoader(), pluginFiles); Configuration result = new Configuration(); result.mode = computeMode(flowId, executionId, phaseName); LOG.debug("Loading profile: {}", profile); File file = new File(profile); file = findCustomProfile(file, definitions.getProperty(KEY_CUSTOM_PROFILE)); try { definitions.remove(KEY_CUSTOM_PROFILE); Map<String, String> env = new HashMap<>(); env.putAll(System.getenv()); env.putAll(toMap(variables)); result.context = new ProfileContext(loader, new VariableResolver(env)); Properties properties = CommandLineUtil.loadProperties(file); result.profile = YaessProfile.load(properties, result.context); } catch (Exception e) { YSLOG.error(e, "E01001", file.getPath()); throw new IllegalArgumentException(MessageFormat.format( "Invalid profile \"{0}\".", file), e); } LOG.debug("Loading script: {}", script); try { Properties properties = CommandLineUtil.loadProperties(new File(script)); result.script = properties; } catch (Exception e) { YSLOG.error(e, "E01002", script); throw new IllegalArgumentException(MessageFormat.format( "Invalid script \"{0}\".", script), e); } result.batchId = batchId; result.flowId = flowId; result.executionId = executionId; if (phaseName != null) { result.phase = ExecutionPhase.findFromSymbol(phaseName); if (result.phase == null) { throw new IllegalArgumentException(MessageFormat.format( "Unknown phase name \"{0}\".", phaseName)); } } result.arguments = toMap(arguments); result.definitions = toMap(definitions); result.extensions = CommandLineUtil.loadExtensions(loader, argList.getExtended()); LOG.debug("Analyzed YAESS bootstrap arguments"); return result; }
Yaess { static Configuration parseConfiguration(String[] args) throws ParseException { assert args != null; LOG.debug("Analyzing YAESS bootstrap arguments: {}", Arrays.toString(args)); ArgumentList argList = ArgumentList.parse(args); LOG.debug("Argument List: {}", argList); CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, argList.getStandardAsArray()); String profile = cmd.getOptionValue(OPT_PROFILE.getOpt()); LOG.debug("Profile: {}", profile); String script = cmd.getOptionValue(OPT_SCRIPT.getOpt()); LOG.debug("Script: {}", script); String batchId = cmd.getOptionValue(OPT_BATCH_ID.getOpt()); LOG.debug("Batch ID: {}", batchId); String flowId = cmd.getOptionValue(OPT_FLOW_ID.getOpt()); LOG.debug("Flow ID: {}", flowId); String executionId = cmd.getOptionValue(OPT_EXECUTION_ID.getOpt()); LOG.debug("Execution ID: {}", executionId); String phaseName = cmd.getOptionValue(OPT_PHASE_NAME.getOpt()); LOG.debug("Phase name: {}", phaseName); String plugins = cmd.getOptionValue(OPT_PLUGIN.getOpt()); LOG.debug("Plug-ins: {}", plugins); Properties arguments = cmd.getOptionProperties(OPT_ARGUMENT.getOpt()); LOG.debug("Execution arguments: {}", arguments); Properties variables = cmd.getOptionProperties(OPT_ENVIRONMENT_VARIABLE.getOpt()); LOG.debug("Environment variables: {}", variables); Properties definitions = cmd.getOptionProperties(OPT_DEFINITION.getOpt()); LOG.debug("YAESS feature definitions: {}", definitions); LOG.debug("Loading plugins: {}", plugins); List<File> pluginFiles = CommandLineUtil.parseFileList(plugins); ClassLoader loader = CommandLineUtil.buildPluginLoader(Yaess.class.getClassLoader(), pluginFiles); Configuration result = new Configuration(); result.mode = computeMode(flowId, executionId, phaseName); LOG.debug("Loading profile: {}", profile); File file = new File(profile); file = findCustomProfile(file, definitions.getProperty(KEY_CUSTOM_PROFILE)); try { definitions.remove(KEY_CUSTOM_PROFILE); Map<String, String> env = new HashMap<>(); env.putAll(System.getenv()); env.putAll(toMap(variables)); result.context = new ProfileContext(loader, new VariableResolver(env)); Properties properties = CommandLineUtil.loadProperties(file); result.profile = YaessProfile.load(properties, result.context); } catch (Exception e) { YSLOG.error(e, "E01001", file.getPath()); throw new IllegalArgumentException(MessageFormat.format( "Invalid profile \"{0}\".", file), e); } LOG.debug("Loading script: {}", script); try { Properties properties = CommandLineUtil.loadProperties(new File(script)); result.script = properties; } catch (Exception e) { YSLOG.error(e, "E01002", script); throw new IllegalArgumentException(MessageFormat.format( "Invalid script \"{0}\".", script), e); } result.batchId = batchId; result.flowId = flowId; result.executionId = executionId; if (phaseName != null) { result.phase = ExecutionPhase.findFromSymbol(phaseName); if (result.phase == null) { throw new IllegalArgumentException(MessageFormat.format( "Unknown phase name \"{0}\".", phaseName)); } } result.arguments = toMap(arguments); result.definitions = toMap(definitions); result.extensions = CommandLineUtil.loadExtensions(loader, argList.getExtended()); LOG.debug("Analyzed YAESS bootstrap arguments"); return result; } }
Yaess { static Configuration parseConfiguration(String[] args) throws ParseException { assert args != null; LOG.debug("Analyzing YAESS bootstrap arguments: {}", Arrays.toString(args)); ArgumentList argList = ArgumentList.parse(args); LOG.debug("Argument List: {}", argList); CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, argList.getStandardAsArray()); String profile = cmd.getOptionValue(OPT_PROFILE.getOpt()); LOG.debug("Profile: {}", profile); String script = cmd.getOptionValue(OPT_SCRIPT.getOpt()); LOG.debug("Script: {}", script); String batchId = cmd.getOptionValue(OPT_BATCH_ID.getOpt()); LOG.debug("Batch ID: {}", batchId); String flowId = cmd.getOptionValue(OPT_FLOW_ID.getOpt()); LOG.debug("Flow ID: {}", flowId); String executionId = cmd.getOptionValue(OPT_EXECUTION_ID.getOpt()); LOG.debug("Execution ID: {}", executionId); String phaseName = cmd.getOptionValue(OPT_PHASE_NAME.getOpt()); LOG.debug("Phase name: {}", phaseName); String plugins = cmd.getOptionValue(OPT_PLUGIN.getOpt()); LOG.debug("Plug-ins: {}", plugins); Properties arguments = cmd.getOptionProperties(OPT_ARGUMENT.getOpt()); LOG.debug("Execution arguments: {}", arguments); Properties variables = cmd.getOptionProperties(OPT_ENVIRONMENT_VARIABLE.getOpt()); LOG.debug("Environment variables: {}", variables); Properties definitions = cmd.getOptionProperties(OPT_DEFINITION.getOpt()); LOG.debug("YAESS feature definitions: {}", definitions); LOG.debug("Loading plugins: {}", plugins); List<File> pluginFiles = CommandLineUtil.parseFileList(plugins); ClassLoader loader = CommandLineUtil.buildPluginLoader(Yaess.class.getClassLoader(), pluginFiles); Configuration result = new Configuration(); result.mode = computeMode(flowId, executionId, phaseName); LOG.debug("Loading profile: {}", profile); File file = new File(profile); file = findCustomProfile(file, definitions.getProperty(KEY_CUSTOM_PROFILE)); try { definitions.remove(KEY_CUSTOM_PROFILE); Map<String, String> env = new HashMap<>(); env.putAll(System.getenv()); env.putAll(toMap(variables)); result.context = new ProfileContext(loader, new VariableResolver(env)); Properties properties = CommandLineUtil.loadProperties(file); result.profile = YaessProfile.load(properties, result.context); } catch (Exception e) { YSLOG.error(e, "E01001", file.getPath()); throw new IllegalArgumentException(MessageFormat.format( "Invalid profile \"{0}\".", file), e); } LOG.debug("Loading script: {}", script); try { Properties properties = CommandLineUtil.loadProperties(new File(script)); result.script = properties; } catch (Exception e) { YSLOG.error(e, "E01002", script); throw new IllegalArgumentException(MessageFormat.format( "Invalid script \"{0}\".", script), e); } result.batchId = batchId; result.flowId = flowId; result.executionId = executionId; if (phaseName != null) { result.phase = ExecutionPhase.findFromSymbol(phaseName); if (result.phase == null) { throw new IllegalArgumentException(MessageFormat.format( "Unknown phase name \"{0}\".", phaseName)); } } result.arguments = toMap(arguments); result.definitions = toMap(definitions); result.extensions = CommandLineUtil.loadExtensions(loader, argList.getExtended()); LOG.debug("Analyzed YAESS bootstrap arguments"); return result; } private  Yaess(); }
Yaess { static Configuration parseConfiguration(String[] args) throws ParseException { assert args != null; LOG.debug("Analyzing YAESS bootstrap arguments: {}", Arrays.toString(args)); ArgumentList argList = ArgumentList.parse(args); LOG.debug("Argument List: {}", argList); CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, argList.getStandardAsArray()); String profile = cmd.getOptionValue(OPT_PROFILE.getOpt()); LOG.debug("Profile: {}", profile); String script = cmd.getOptionValue(OPT_SCRIPT.getOpt()); LOG.debug("Script: {}", script); String batchId = cmd.getOptionValue(OPT_BATCH_ID.getOpt()); LOG.debug("Batch ID: {}", batchId); String flowId = cmd.getOptionValue(OPT_FLOW_ID.getOpt()); LOG.debug("Flow ID: {}", flowId); String executionId = cmd.getOptionValue(OPT_EXECUTION_ID.getOpt()); LOG.debug("Execution ID: {}", executionId); String phaseName = cmd.getOptionValue(OPT_PHASE_NAME.getOpt()); LOG.debug("Phase name: {}", phaseName); String plugins = cmd.getOptionValue(OPT_PLUGIN.getOpt()); LOG.debug("Plug-ins: {}", plugins); Properties arguments = cmd.getOptionProperties(OPT_ARGUMENT.getOpt()); LOG.debug("Execution arguments: {}", arguments); Properties variables = cmd.getOptionProperties(OPT_ENVIRONMENT_VARIABLE.getOpt()); LOG.debug("Environment variables: {}", variables); Properties definitions = cmd.getOptionProperties(OPT_DEFINITION.getOpt()); LOG.debug("YAESS feature definitions: {}", definitions); LOG.debug("Loading plugins: {}", plugins); List<File> pluginFiles = CommandLineUtil.parseFileList(plugins); ClassLoader loader = CommandLineUtil.buildPluginLoader(Yaess.class.getClassLoader(), pluginFiles); Configuration result = new Configuration(); result.mode = computeMode(flowId, executionId, phaseName); LOG.debug("Loading profile: {}", profile); File file = new File(profile); file = findCustomProfile(file, definitions.getProperty(KEY_CUSTOM_PROFILE)); try { definitions.remove(KEY_CUSTOM_PROFILE); Map<String, String> env = new HashMap<>(); env.putAll(System.getenv()); env.putAll(toMap(variables)); result.context = new ProfileContext(loader, new VariableResolver(env)); Properties properties = CommandLineUtil.loadProperties(file); result.profile = YaessProfile.load(properties, result.context); } catch (Exception e) { YSLOG.error(e, "E01001", file.getPath()); throw new IllegalArgumentException(MessageFormat.format( "Invalid profile \"{0}\".", file), e); } LOG.debug("Loading script: {}", script); try { Properties properties = CommandLineUtil.loadProperties(new File(script)); result.script = properties; } catch (Exception e) { YSLOG.error(e, "E01002", script); throw new IllegalArgumentException(MessageFormat.format( "Invalid script \"{0}\".", script), e); } result.batchId = batchId; result.flowId = flowId; result.executionId = executionId; if (phaseName != null) { result.phase = ExecutionPhase.findFromSymbol(phaseName); if (result.phase == null) { throw new IllegalArgumentException(MessageFormat.format( "Unknown phase name \"{0}\".", phaseName)); } } result.arguments = toMap(arguments); result.definitions = toMap(definitions); result.extensions = CommandLineUtil.loadExtensions(loader, argList.getExtended()); LOG.debug("Analyzed YAESS bootstrap arguments"); return result; } private  Yaess(); static void main(String... args); }
Yaess { static Configuration parseConfiguration(String[] args) throws ParseException { assert args != null; LOG.debug("Analyzing YAESS bootstrap arguments: {}", Arrays.toString(args)); ArgumentList argList = ArgumentList.parse(args); LOG.debug("Argument List: {}", argList); CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, argList.getStandardAsArray()); String profile = cmd.getOptionValue(OPT_PROFILE.getOpt()); LOG.debug("Profile: {}", profile); String script = cmd.getOptionValue(OPT_SCRIPT.getOpt()); LOG.debug("Script: {}", script); String batchId = cmd.getOptionValue(OPT_BATCH_ID.getOpt()); LOG.debug("Batch ID: {}", batchId); String flowId = cmd.getOptionValue(OPT_FLOW_ID.getOpt()); LOG.debug("Flow ID: {}", flowId); String executionId = cmd.getOptionValue(OPT_EXECUTION_ID.getOpt()); LOG.debug("Execution ID: {}", executionId); String phaseName = cmd.getOptionValue(OPT_PHASE_NAME.getOpt()); LOG.debug("Phase name: {}", phaseName); String plugins = cmd.getOptionValue(OPT_PLUGIN.getOpt()); LOG.debug("Plug-ins: {}", plugins); Properties arguments = cmd.getOptionProperties(OPT_ARGUMENT.getOpt()); LOG.debug("Execution arguments: {}", arguments); Properties variables = cmd.getOptionProperties(OPT_ENVIRONMENT_VARIABLE.getOpt()); LOG.debug("Environment variables: {}", variables); Properties definitions = cmd.getOptionProperties(OPT_DEFINITION.getOpt()); LOG.debug("YAESS feature definitions: {}", definitions); LOG.debug("Loading plugins: {}", plugins); List<File> pluginFiles = CommandLineUtil.parseFileList(plugins); ClassLoader loader = CommandLineUtil.buildPluginLoader(Yaess.class.getClassLoader(), pluginFiles); Configuration result = new Configuration(); result.mode = computeMode(flowId, executionId, phaseName); LOG.debug("Loading profile: {}", profile); File file = new File(profile); file = findCustomProfile(file, definitions.getProperty(KEY_CUSTOM_PROFILE)); try { definitions.remove(KEY_CUSTOM_PROFILE); Map<String, String> env = new HashMap<>(); env.putAll(System.getenv()); env.putAll(toMap(variables)); result.context = new ProfileContext(loader, new VariableResolver(env)); Properties properties = CommandLineUtil.loadProperties(file); result.profile = YaessProfile.load(properties, result.context); } catch (Exception e) { YSLOG.error(e, "E01001", file.getPath()); throw new IllegalArgumentException(MessageFormat.format( "Invalid profile \"{0}\".", file), e); } LOG.debug("Loading script: {}", script); try { Properties properties = CommandLineUtil.loadProperties(new File(script)); result.script = properties; } catch (Exception e) { YSLOG.error(e, "E01002", script); throw new IllegalArgumentException(MessageFormat.format( "Invalid script \"{0}\".", script), e); } result.batchId = batchId; result.flowId = flowId; result.executionId = executionId; if (phaseName != null) { result.phase = ExecutionPhase.findFromSymbol(phaseName); if (result.phase == null) { throw new IllegalArgumentException(MessageFormat.format( "Unknown phase name \"{0}\".", phaseName)); } } result.arguments = toMap(arguments); result.definitions = toMap(definitions); result.extensions = CommandLineUtil.loadExtensions(loader, argList.getExtended()); LOG.debug("Analyzed YAESS bootstrap arguments"); return result; } private  Yaess(); static void main(String... args);  }