コード例 #1
0
  static {
    delegates.add(new DatatypeStateEntityListener());
    logger.info("Adding DatatypeStateEntityListener to NabuccoEntityListener.");

    delegates.add(new DatatypeLoggingEntityListener());
    logger.info("Adding DatatypeLoggingEntityListener to NabuccoEntityListener.");
  }
コード例 #2
0
  /** {@inheritDoc} */
  @Override
  public void visit(Foreach foreach, TestScriptResult argument) throws TestScriptException {
    getContext().setCurrentTestScriptElement(foreach);
    Name elementName = foreach.getElementName();
    PropertyReference iterableId = foreach.getIterableRef();
    Property iterableProperty = getContext().getProperty(iterableId);

    if (iterableProperty == null) {
      throw new TestScriptException("Property '" + iterableId + "' not found in context");
    }

    PropertyIterator propertyIterator = new PropertyIterator(iterableProperty);

    if (getContext().getProperty(elementName) != null) {
      throw new TestScriptException(
          "Foreach configuration error -> Property '"
              + elementName
              + "' already exists in context");
    }

    logger.info("Starting Foreach-Loop: " + foreach.getId());
    Iterator<Property> iterator = propertyIterator.iterator();
    Property currentProp = null;

    while (iterator.hasNext()) {
      currentProp = iterator.next();

      if (logger.isDebugEnabled()) {
        logger.debug(
            "Next element: id="
                + currentProp.getName().getValue()
                + ", type="
                + currentProp.getType());
      }

      Property currentClone = currentProp.cloneObject();
      currentClone.setName(elementName);
      getContext().put(currentClone);

      try {
        super.visit(foreach.getTestScriptElementList(), argument);
      } catch (BreakLoopException ex) {
        getContext().remove(currentClone);
        break;
      }

      // remove property with id=elementId from context
      getContext().remove(currentClone);
    }
  }