예제 #1
0
  /**
   * Check the Complex Items.
   *
   * @throws Exception
   */
  private void checkComplex() throws Exception {
    XPathComponentHelper xpathHelper = new XPathComponentHelper();

    if (this.extension == null) {
      XMLTestCase.fail("Extension base name is not set.");
    }

    String xpath = xpathHelper.xpathComponentName(this.componentName);
    XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());

    xpath = xpathHelper.xpathCompExtenBase(this.componentName, this.extension);
    XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());

    if (this.sequenceFields.isEmpty() == true && this.choiceSequenceFields.isEmpty() == true) {
      XMLTestCase.assertTrue(true);
    } else {

      // Check all the fields.
      for (Iterator fields = sequenceFields.iterator(); fields.hasNext(); ) {
        ComponentField seqField = (ComponentField) fields.next();
        xpath =
            xpathHelper.xpathCompExtElements(
                this.componentName, this.extension, seqField.getFieldName());
        XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());

        // xpath = xpathHelper.xpathCompExtElementDoc(this.componentName, this.extension,
        // seqField.getFieldName());
        // xmlTest.assertXpathExists(xpath, this.getXsdSourceDocument());

        if (seqField.getMinOccurs() != null) {
          if (seqField.getMinOccurs().equalsIgnoreCase("0")) {
            xpath =
                xpathHelper.xpathCompExtElementOptional(
                    this.componentName, this.extension, seqField.getFieldName());
          } else {
            xpath =
                xpathHelper.xpathCompExtElementMinOccurs(
                    this.componentName,
                    this.extension,
                    seqField.getFieldName(),
                    seqField.getMinOccurs());
          }
          XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        }

        if (seqField.getMaxOccurs() != null) {
          xpath =
              xpathHelper.xpathCompExtElementMaxOccurs(
                  this.componentName,
                  this.extension,
                  seqField.getFieldName(),
                  seqField.getMaxOccurs());
          XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        }
      }
    }
  }
예제 #2
0
  /* (non-Javadoc)
   * @see org.starstandard.oagis90.framework.impl.IComplexType#addChoiceField(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
   */
  public void addChoiceField(String fieldName, String type, String minOccurs, String maxOccurs) {
    ComponentField addField = new ComponentField();

    addField.setFieldName(fieldName);
    addField.setDataType(type);
    addField.setMaxOccurs(maxOccurs);
    addField.setMinOccurs(minOccurs);

    choiceSequenceFields.add(addField);
  }
예제 #3
0
  /* (non-Javadoc)
   * @see org.starstandard.oagis90.framework.impl.IComplexType#addSequenceField(java.lang.String, java.lang.String)
   */
  public void addSequenceField(String fieldName, String type) {
    ComponentField addField = new ComponentField();

    addField.setFieldName(fieldName);
    addField.setDataType(type);
    addField.setMaxOccurs(null);
    addField.setMinOccurs(null);

    sequenceFields.add(addField);
  }
예제 #4
0
  private void checkSequence() throws Exception {
    XPathComponentHelper xpathHelper = new XPathComponentHelper();

    if (this.sequenceFields.isEmpty() == true && this.choiceSequenceFields.isEmpty() == true) {
      XMLTestCase.fail("Component has no fields");
    }

    String xpath = xpathHelper.xpathComponentName(this.componentName);
    XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());

    // Check all the fields.
    for (Iterator fields = sequenceFields.iterator(); fields.hasNext(); ) {
      ComponentField seqField = (ComponentField) fields.next();
      xpath = xpathHelper.xpathCompElement(this.componentName, seqField.getFieldName());
      XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
      // xpath = xpathHelper.xpathCompElementDoc(this.componentName, seqField.getFieldName());
      // xmlTest.assertXpathExists(xpath, this.getXsdSourceDocument());
      if (seqField.getMinOccurs() != null) {
        if (seqField.getMinOccurs().equalsIgnoreCase("0")) {
          xpath = xpathHelper.xpathCompElementOptional(this.componentName, seqField.getFieldName());
        } else {
          xpath =
              xpathHelper.xpathCompElementMinOccurs(
                  this.componentName, seqField.getFieldName(), seqField.getMinOccurs());
        }
        XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
      }
      if (seqField.getMaxOccurs() != null) {
        xpath =
            xpathHelper.xpathCompElementMaxOccurs(
                this.componentName, seqField.getFieldName(), seqField.getMaxOccurs());
        XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
      }
    }

    // Check all Choices

    if (choiceSequenceFields.isEmpty() == false) {
      for (Iterator fields = choiceSequenceFields.iterator(); fields.hasNext(); ) {
        ComponentField choiceField = (ComponentField) fields.next();
        xpath =
            xpathHelper.xpathSequenceChoiceSequenceElement(
                this.componentName, choiceField.getFieldName(), choiceField.getDataType());
        XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        // xpath = xpathHelper.xpathSequenceChoiceSequenceElementDoc(this.componentName,
        // choiceField.getFieldName());
        // xmlTest.assertXpathExists(xpath, this.getXsdSourceDocument());
        if (choiceField.getMinOccurs() != null) {
          if (choiceField.getMinOccurs().equalsIgnoreCase("0")) {
            xpath =
                xpathHelper.xpathSequenceChoiceSequenceElementOptional(
                    this.componentName, choiceField.getFieldName(), choiceField.getDataType());
          } else {
            xpath =
                xpathHelper.xpathSequenceChoiceSequenceElementMinOccurs(
                    this.componentName,
                    choiceField.getFieldName(),
                    choiceField.getDataType(),
                    choiceField.getMinOccurs());
          }
          XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        }
        if (choiceField.getMaxOccurs() != null) {
          xpath =
              xpathHelper.xpathSequenceChoiceSequenceElementMaxOccurs(
                  this.componentName,
                  choiceField.getFieldName(),
                  choiceField.getDataType(),
                  choiceField.getMaxOccurs());
          XMLAssert.assertXpathExists(xpath, this.getXsdSourceDocument());
        }
      }
    }
  }