Esempio n. 1
0
  @Override
  public void startElement(
      final String namespaceURI,
      final String localName,
      final String qName,
      final Attributes attrs) {
    if ("testsuite".equals(qName)) {
      final TestSuite node = new TestSuite();
      node.setName(attrs.getValue("name"));

      final TestSuite parentNode = getParentTestSuite();
      if (parentNode != null) {
        parentNode.addTestNode(node);
        node.setParent(parentNode);
      }

      if (rootNode == null) {
        rootNode = node;
      }

      queue.add(node);
    } else if ("testcase".equals(qName)) {
      final TestCase node = new TestCase();
      node.setName(attrs.getValue("name"));
      node.setInternalId(Integer.parseInt(attrs.getValue("internalid")));

      final TestSuite parentNode = getParentTestSuite();
      if (parentNode != null) {
        parentNode.addTestNode(node);
        node.setParent(parentNode);
      }

      queue.add(node);
    } else if ("step".equals(qName)) {
      final TestStep node = new TestStep();

      final TestCase parentNode = getParentTestCase();
      if (parentNode != null) {
        parentNode.addTestStep(node);
        node.setParent(parentNode);
      }

      queue.add(node);
    } else if ("keyword".equals(qName)) {
      final TestNode testNode = getCurrentTestNode();
      if (testNode != null) {
        final String name = attrs.getValue("name");
        if (StringUtil.isNotBlank(name)) {
          testNode.addKeyword(name);
        }
      }

      queue.add(EMPTY_OBJ);
    } else if ("node_order".equals(qName) //
        || "details".equals(qName) //
        || "externalid".equals(qName) //
        || "version".equals(qName) //
        || "summary".equals(qName) //
        || "preconditions".equals(qName) //
        || "execution_type".equals(qName) //
        || "importance".equals(qName) //
        || "step_number".equals(qName) //
        || "actions".equals(qName) //
        || "expectedresults".equals(qName) //
        || "execution_type".equals(qName) //
    ) {
      queue.add(new StringBuilder(100));
    } else {
      queue.add(EMPTY_OBJ);
    }
    // TODO notes
  }
Esempio n. 2
0
 @Override
 public void endElement(final String namespaceURI, final String localName, final String qName) {
   if ("testsuite".equals(qName)) {
     // nothing
   } else if ("testcase".equals(qName)) {
     // nothing
   } else if ("step".equals(qName)) {
     // nothing
   } else if ("node_order".equals(qName)) {
     final TestNode node = getParentTestNode();
     if (node != null) {
       node.setNodeOrder(getTextValueAsInt());
     }
   } else if ("details".equals(qName)) {
     final TestSuite node = getParentTestSuite();
     if (node != null) {
       node.setDetails(getTextValue());
     }
   } else if ("externalid".equals(qName)) {
     final TestCase node = getParentTestCase();
     if (node != null) {
       node.setExternalId(getTextValueAsInt());
     }
   } else if ("version".equals(qName)) {
     final TestCase node = getParentTestCase();
     if (node != null) {
       node.setVersion(getTextValueAsInt());
     }
   } else if ("summary".equals(qName)) {
     final TestCase node = getParentTestCase();
     if (node != null) {
       node.setSummary(getTextValue());
     }
   } else if ("preconditions".equals(qName)) {
     final TestCase node = getParentTestCase();
     if (node != null) {
       node.setPreconditions(getTextValue());
     }
   } else if ("execution_type".equals(qName)) {
     final TestCase node = getParentTestCase();
     if (node != null) {
       node.setExecutionType(getTextValueAsInt());
     }
   } else if ("importance".equals(qName)) {
     final TestCase node = getParentTestCase();
     if (node != null) {
       node.setImportance(getTextValueAsInt());
     }
   } else if ("step_number".equals(qName)) {
     final TestStep node = getParentTestStep();
     if (node != null) {
       node.setStepNumber(getTextValueAsInt());
     }
   } else if ("actions".equals(qName)) {
     final TestStep node = getParentTestStep();
     if (node != null) {
       node.setActions(getTextValue());
     }
   } else if ("expectedresults".equals(qName)) {
     final TestStep node = getParentTestStep();
     if (node != null) {
       node.setExpectedResults(getTextValue());
     }
   } else if ("execution_type".equals(qName)) {
     final TestStep node = getParentTestStep();
     if (node != null) {
       node.setExecutionType(getTextValueAsInt());
     }
   }
   queue.removeLast();
 }