Пример #1
0
  /* (non-Javadoc)
   * @see org.starstandard.oagis90.framework.impl.IComplexType#validate(int)
   */
  public void validate(int testType) throws Exception {

    if (this.componentName == null) {
      XMLTestCase.fail("Component Name is NULL");
    }

    if (NamingDesignRules.checkComponentName(this.componentName) == false) {
      XMLTestCase.fail("Component name does not end with the word Type");
    }

    switch (testType) {
      case SIMPLE:
        {
          checkSequence();
          break;
        }
      case COMPLEX:
        {
          checkComplex();
          break;
        }

      case SIMPLECONTENT:
        {
          checkSimpleContent();
          break;
        }
      default:
        XMLTestCase.fail("Unknown Testing type provided.");
    }
  }
Пример #2
0
  private void checkSimpleContent() throws Exception {
    if (this.extension == null) {
      XMLTestCase.fail("Extension base name is not set.");
    }

    // This will always pass as the NDR validation isn't coded yet.
    XMLTestCase.assertTrue(true);
  }
Пример #3
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());
        }
      }
    }
  }
Пример #4
0
 protected void setUp() throws Exception {
   super.setUp();
   serializer = new NdmSerializer();
   method = new Method();
   deeracTasks = new Tasks();
   UserTaskList userTaskList = new UserTaskList();
   deeracTasks.setUserTaskList(userTaskList);
 }
  protected void setUp() throws Exception {
    super.setUp();
    bundle = Platform.getBundle("org.w3c.xqts.testsuite");

    if (bundle == null) {
      System.setProperty(
          "javax.xml.parsers.DocumentBuilderFactory",
          "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    }
    System.setProperty(
        "javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema",
        "org.apache.xerces.jaxp.validation.XMLSchemaFactory");

    staticContextBuilder = new StaticContextBuilder();
  }
Пример #6
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());
        }
      }
    }
  }
 protected void tearDown() throws Exception {
   super.tearDown();
   domDoc = null;
   domDoc2 = null;
   dynamicContext = null;
 }
 /*
  * (non-Javadoc)
  *
  * @see junit.framework.TestCase#setUp()
  */
 protected void setUp() throws Exception {
   super.setUp();
   persistence = new JiBXPersistence();
 }