/** * Extracts test run arguments from an XML properties file. The arguments * are added to the resulting <code>RuntimeOptions</code> object as * key-value pairs represented as a string: "{key}={value}". * * @param testRunArgs An XML representation of a properties file containing * an {@literal <entry>} element for each supplied argument. * @return The configuration settings for a test run, including a list of * parameters (which may be empty). * * @see * <a target="_blank" href="https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html">Properties</a> */ RuntimeOptions extractTestRunArguments(Document testRunArgs) { RuntimeOptions runOpts = new RuntimeOptions(); if (null != testRunArgs) { NodeList entries = testRunArgs.getElementsByTagName("entry"); for (int i = 0; i < entries.getLength(); i++) { Element entry = (Element) entries.item(i); String kvp = String.format("%s=%s", entry.getAttribute("key"), entry.getTextContent().trim()); runOpts.addParam(kvp); this.testInputs.put(entry.getAttribute("key"), entry.getTextContent().trim()); } } return runOpts; }
/** * Returns the location of the directory containing the test run output. * * @return A String representing a file URI denoting the path name of a * directory. */ public String getTestRunDirectory() { String logDirURI = opts.getLogDir().toURI().toString(); return logDirURI + opts.getSessionId(); }
public TECore(Engine engine, Index index, RuntimeOptions opts) { this.engine = engine; this.index = index; this.opts = opts; this.recordedForms = new RecordedForms(opts.getRecordedForms()); testPath = opts.getSessionId(); out = System.out; }
String cmd = "java com.occamlab.te.Test"; File workDir = setupOpts.getWorkDir(); runOpts.setWorkDir(workDir); File logDir = runOpts.getLogDir(); String session = null; int mode = TEST_MODE; session = arg.substring(9); } else if (arg.startsWith("-base=")) { runOpts.setBaseURI(arg.substring(6)); } else if (arg.startsWith("-test=")) { runOpts.setTestName(arg.substring(6)); } else if (arg.startsWith("-suite=")) { runOpts.setSuiteName(arg.substring(7)); } else if (arg.startsWith("-profile=")) { runOpts.addProfile(arg.substring(9)); } else if (arg.startsWith("@")) { runOpts.addParam(arg.substring(1)); } else if (arg.equals("-mode=test")) { mode = TEST_MODE; setupOpts.setValidate(false); } else if ((arg.startsWith("-form="))) { runOpts.addRecordedForm(arg.substring(6)); } else if (!arg.startsWith("-")) { if (mode == RETEST_MODE) { runOpts.addTestPath(arg); } else { System.out.println("Unrecognized parameter \"" + arg
grandParent.setType("Mandatory"); testStack.push(grandParent); String sessionId = opts.getSessionId(); int mode = opts.getMode(); ArrayList<String> params = opts.getParams(); reexecute_test(sessionId); } else if (mode == Test.RETEST_MODE) { for (String testPath : opts.getTestPaths()) { reexecute_test(testPath); String testName = opts.getTestName(); if (testName != null) { XdmNode contextNode = opts.getContextNode(); execute_test(testName, params, contextNode); } else { String suiteName = opts.getSuiteName(); List<String> profiles = opts.getProfiles(); if (suiteName != null || profiles.size() == 0) { execute_suite(suiteName, params); if (opts.getLogDir() != null) { LogUtils.createFullReportLog(opts.getLogDir().getAbsolutePath() + File.separator + opts.getSessionId()); File resultsDir = new File(opts.getLogDir(), opts.getSessionId()); if(supportHtmlReport == true){ Map<String, String> testInputMap = new HashMap<String, String>();
public void reexecute_test(String testPath) throws Exception { Document log = LogUtils.readLog(opts.getLogDir(), testPath); String testId = LogUtils.getTestIdFromLog(log); TestEntry test = index.getTest(testId); XdmNode paramsNode = LogUtils.getParamsFromLog(builder, log); XdmNode contextNode = LogUtils.getContextFromLog(builder, log); XPathContext context = getXPathContext(test, opts.getSourcesName(), contextNode); setTestPath(testPath); executeTest(test, paramsNode, context); if (testPath.equals(opts.getSessionId())) { suiteLog = LogUtils.readLog(opts.getLogDir(), testPath); ArrayList<String> params = opts.getParams(); List<String> profiles = opts.getProfiles(); if (profiles.contains("*")) { for (String profile : index.getProfileKeys()) {
public Source execute(Document testRunArgs) { RuntimeOptions runOpts = extractTestRunArguments(testRunArgs); runOpts.setLogDir(new File(System.getProperty("java.io.tmpdir"))); if (null == runOpts.getSessionId()) { runOpts.setSessionId(UUID.randomUUID().toString()); throw new RuntimeException(ex); File resultsDir = new File(runOpts.getLogDir(), runOpts.getSessionId()); File testLog = new File(resultsDir, "report_logs.xml");
public File getLogDir() { return opts.getLogDir(); }
/** * Constructs a test executor with default options. */ public Test() { this.setupOpts = new SetupOptions(); this.runOpts = new RuntimeOptions(); }
if (opts.getMode() == Test.RESUME_MODE && prevLog != null) { for (Element e : DomUtils.getElementsByTagName(prevLog, "formresults")) { method)); formTransformer.setParameter(new QName("base"), new XdmAtomicValue(opts.getBaseURI())); formTransformer.setParameter(new QName("action"), new XdmAtomicValue( getTestServletURL()));
String cmd = "java com.occamlab.te.Test"; File workDir = setupOpts.getWorkDir(); runOpts.setWorkDir(workDir); File logDir = runOpts.getLogDir(); String session = null; int mode = TEST_MODE; session = arg.substring(9); } else if (arg.startsWith("-base=")) { runOpts.setBaseURI(arg.substring(6)); } else if (arg.startsWith("-test=")) { runOpts.setTestName(arg.substring(6)); } else if (arg.startsWith("-suite=")) { runOpts.setSuiteName(arg.substring(7)); } else if (arg.startsWith("-profile=")) { runOpts.addProfile(arg.substring(9)); } else if (arg.startsWith("@")) { runOpts.addParam(arg.substring(1)); } else if (arg.equals("-mode=test")) { mode = TEST_MODE; setupOpts.setValidate(false); } else if ((arg.startsWith("-form="))) { runOpts.addRecordedForm(arg.substring(6)); } else if (!arg.startsWith("-")) { if (mode == RETEST_MODE) { runOpts.addTestPath(arg); } else { System.out.println("Unrecognized parameter \"" + arg
grandParent.setType("Mandatory"); testStack.push(grandParent); String sessionId = opts.getSessionId(); int mode = opts.getMode(); ArrayList<String> params = opts.getParams(); reexecute_test(sessionId); } else if (mode == Test.RETEST_MODE) { for (String testPath : opts.getTestPaths()) { reexecute_test(testPath); String testName = opts.getTestName(); if (testName != null) { XdmNode contextNode = opts.getContextNode(); execute_test(testName, params, contextNode); } else { String suiteName = opts.getSuiteName(); List<String> profiles = opts.getProfiles(); if (suiteName != null || profiles.size() == 0) { execute_suite(suiteName, params); if (opts.getLogDir() != null) { LogUtils.createFullReportLog(opts.getLogDir().getAbsolutePath() + File.separator + opts.getSessionId()); File resultsDir = new File(opts.getLogDir(), opts.getSessionId()); if(supportHtmlReport == true){ Map<String, String> testInputMap = new HashMap<String, String>();
public void reexecute_test(String testPath) throws Exception { Document log = LogUtils.readLog(opts.getLogDir(), testPath); String testId = LogUtils.getTestIdFromLog(log); TestEntry test = index.getTest(testId); XdmNode paramsNode = LogUtils.getParamsFromLog(builder, log); XdmNode contextNode = LogUtils.getContextFromLog(builder, log); XPathContext context = getXPathContext(test, opts.getSourcesName(), contextNode); setTestPath(testPath); executeTest(test, paramsNode, context); if (testPath.equals(opts.getSessionId())) { suiteLog = LogUtils.readLog(opts.getLogDir(), testPath); ArrayList<String> params = opts.getParams(); List<String> profiles = opts.getProfiles(); if (profiles.contains("*")) { for (String profile : index.getProfileKeys()) {
public Source execute(Document testRunArgs) { RuntimeOptions runOpts = extractTestRunArguments(testRunArgs); runOpts.setLogDir(new File(System.getProperty("java.io.tmpdir"))); if (null == runOpts.getSessionId()) { runOpts.setSessionId(UUID.randomUUID().toString()); throw new RuntimeException(ex); File resultsDir = new File(runOpts.getLogDir(), runOpts.getSessionId()); File testLog = new File(resultsDir, "report_logs.xml");
public File getLogDir() { return opts.getLogDir(); }
public TECore(Engine engine, Index index, RuntimeOptions opts) { this.engine = engine; this.index = index; this.opts = opts; this.recordedForms = new RecordedForms(opts.getRecordedForms()); this.testPath = opts.getSessionId(); this.out = System.out; this.imageHandler = new ImageHandler(opts.testLogDir, opts.sessionId); }
/** * Constructs a test executor with default options. */ public Test() { this.setupOpts = new SetupOptions(); this.runOpts = new RuntimeOptions(); }
if (opts.getMode() == Test.RESUME_MODE && prevLog != null) { for (Element e : DomUtils.getElementsByTagName(prevLog, "formresults")) { method)); formTransformer.setParameter(new QName("base"), new XdmAtomicValue(opts.getBaseURI())); formTransformer.setParameter(new QName("action"), new XdmAtomicValue( getTestServletURL()));