Пример #1
0
  public void createTestsFromElement(
      Element xmlDefinition,
      HashMap<String, JTestContainer> targetAndParent,
      HashMap<String, Integer> targetAndPlace) {
    // Create the "then" section
    super.createTestsFromElement(xmlDefinition, targetAndParent, targetAndPlace);

    // Create the "else if" tests, which might exist
    ArrayList<Element> nodes = XmlUtils.getChildElementsByTag(AntIfElseIf.XML_TAG, xmlDefinition);
    for (Element node : nodes) {
      JTestContainer elseifContainer = AntIfElseIf.fromElement(this, node);
      elseifContainer.setLoadVersion(loadVersion);
      elseifContainer.createTestsFromElement(node, targetAndParent, targetAndPlace);
      rootTests.add(elseifContainer);
    }

    // Create the "else" section - each "if" must have an "else"
    nodes = XmlUtils.getChildElementsByTag(AntIfElse.XML_TAG, xmlDefinition);

    if (nodes.size() > 0) {
      Element node = nodes.get(0);
      AntFlowControl elseContainer = AntIfElse.fromElement(this, node);
      elseContainer.setLoadVersion(loadVersion);
      elseContainer.createTestsFromElement(node, targetAndParent, targetAndPlace);
      rootTests.add(elseContainer);
    }
  }
Пример #2
0
  public Element addExecutorXml(Element targetScenario, Document doc) {
    Element ifElement = doc.createElement(getXmlTag());
    appendAdditionalData(ifElement);

    Element scriptCondition = getScriptConditionElement(doc);

    ifElement.appendChild(scriptCondition);

    if (!(this instanceof AntIfElseIf)) {
      Element echo1 = doc.createElement("echo");
      echo1.setAttribute("message", "Check condition " + test.getConditionString());
      targetScenario.appendChild(echo1);
    }

    /*
     * Create and add the sequential tag and content
     */
    Element then = doc.createElement(XML_CONTAINER_TAG);

    // go over all tests append a target that invokes them
    // to the ant script and add an antcall to the test in the execute scenario target
    ifElement.appendChild(then);
    for (JTest jtest : rootTests) {
      // Add echos for AntIfElseIf...
      if (jtest instanceof AntIfElseIf) {
        AntIfElseIf elseIf = (AntIfElseIf) jtest;
        Element elseIf1 = doc.createElement("echo");
        elseIf1.setAttribute("message", "Else if " + elseIf.getIfTest().getConditionString());
        targetScenario.appendChild(elseIf1);
      }
      if ((jtest instanceof AntIfElseIf) || (jtest instanceof AntIfElse)) {
        jtest.addExecutorXml(ifElement, doc);
      } else {
        jtest.addExecutorXml(then, doc);
      }
    }

    targetScenario.appendChild(ifElement);

    return ifElement;
  }
Пример #3
0
 public AntIfElseIf cloneTest() throws Exception {
   AntIfElseIf test = new AntIfElseIf(getParent(), getTestId());
   test.rootTests = cloneRootTests(test);
   return test;
 }