Class DataFixture

java.lang.Object
org.opengis.cite.om20.level1.DataFixture
Direct Known Subclasses:
ArrayObservationValidation, CategoryObservationValidation, ComplexObservationValidation, CountObservationValidation, GenericObservationDataValidation, GeometryObservationValidation, MeasurementDataValidation, SamplingCurveDataValidation, SamplingFeatureObservationValidation, SamplingPointDataValidation, SamplingSolidDataValidation, SamplingSurfaceDataValidation, ScalarObservationValidation, SchematronTests, SpatialObservationValidation, SpatialSamplingFeatureValidation, SpecimenObservationValidation, TemporalObservationValidation, TruthObservationValidation

public class DataFixture extends Object
A supporting base class that provides a common fixture for validating data sets. The configuration methods are invoked before any that may be defined in a subclass.
  • Field Details

    • dataFile

      protected File dataFile
      Files containing tested subject.
    • originalSubject

      protected Document originalSubject
    • testSubject

      protected Document testSubject
    • testSubjectUri

      protected URI testSubjectUri
    • Resource_GML_Path

      protected String Resource_GML_Path
    • Resource_SWE_Path

      protected String Resource_SWE_Path
    • model

      protected org.apache.xerces.xs.XSModel model
      An XSModel object representing a GML application schema.
    • observation_type_measurement

      protected final String observation_type_measurement
      See Also:
    • observation_type_category

      protected final String observation_type_category
      See Also:
    • observation_type_count

      protected final String observation_type_count
      See Also:
    • observation_type_truth

      protected final String observation_type_truth
      See Also:
    • observation_type_complex

      protected final String observation_type_complex
      See Also:
    • observation_type_geometry

      protected final String observation_type_geometry
      See Also:
    • observation_type_temporal

      protected final String observation_type_temporal
      See Also:
    • observation_type_swe_simple

      protected final String observation_type_swe_simple
      See Also:
    • observation_type_swe_array

      protected final String observation_type_swe_array
      See Also:
  • Constructor Details

    • DataFixture

      public DataFixture()

      Constructor for DataFixture.

  • Method Details

    • obtainTestSubject

      @BeforeClass(alwaysRun=true) public void obtainTestSubject(org.testng.ITestContext testContext)

      obtainTestSubject.

      Parameters:
      testContext - a ITestContext object
    • setDataFile

      public void setDataFile(File dataFile)
      Sets the data file. This is a convenience method intended to facilitate unit testing.
      Parameters:
      dataFile - A File containing the data to be validated.
    • setSchemaModel

      public void setSchemaModel(org.apache.xerces.xs.XSModel xsModel)
      Sets the schema model (for unit testing purposes).
      Parameters:
      xsModel - An XSModel object representing a GML application schema.
    • generateXPathExpression

      public String generateXPathExpression(List<QName> elemNames, Map<String,String> namespaceBindings)
      Generates an XPath expression to find all instances of the given elements in the data being validated. The supplied namespace bindings will be supplemented if necessary.
      Parameters:
      elemNames - A list of qualified names corresponding to element declarations.
      namespaceBindings - A collection of namespace bindings required to evaluate the XPath expression, where each entry maps a namespace URI (key) to a prefix (value).
      Returns:
      An XPath (1.0) expression.
    • GetFileViaResourcePath

      public File GetFileViaResourcePath(String resourcePath)

      GetFileViaResourcePath.

      Parameters:
      resourcePath - a String object
      Returns:
      a File object
    • CreateValidator

      public Validator CreateValidator(URL xsdPath) throws XMLStreamException, SAXException, IOException
      Create Validator for checking XML file against XML Schema file
      Parameters:
      xsdPath - URL path of the XSD file
      Returns:
      schema validator
      Throws:
      XMLStreamException - javax.xml.stream.XMLStreamException
      IOException - java.io.IOException
      SAXException - SAX Error
    • evaluateXPath2Modified

      public static net.sf.saxon.s9api.XdmValue evaluateXPath2Modified(File xmlFile, String expr, Map<String,String> nsBindings) throws net.sf.saxon.s9api.SaxonApiException
      Evaluates an XPath 2.0 expression using the Saxon s9api interfaces modified version
      Parameters:
      xmlFile - The XML file.
      expr - The XPath expression to be evaluated.
      nsBindings - A collection of namespace bindings required to evaluate the XPath expression, where each entry maps a namespace URI (key) to a prefix (value); this may be null if not needed.
      Returns:
      An XdmValue object representing a value in the XDM data model; this is a sequence of zero or more items, where each item is either an atomic value or a node.
      Throws:
      net.sf.saxon.s9api.SaxonApiException - net.sf.saxon.s9api.SaxonApiException
    • CheckXPath2Modified

      public net.sf.saxon.s9api.XdmValue CheckXPath2Modified(String xpath2, File xmlFile)
      Check XPath2.0 modified version
      Parameters:
      xpath2 - String denoting an xpath syntax
      xmlFile - the File xml
      Returns:
      XdmValue converted to string
    • SchemaElement

      public String SchemaElement(String candidateNode, String nodeName, File schemaFile) throws net.sf.saxon.s9api.SaxonApiException
      Return "true" if candidate element node satisfy all three of the following conditions: Condition 1: The name of the candidate node matches the specified nodeName or matches the name of an element in a substitution group headed by an element named nodeName. Condition 2: derives-from(AT, ET) is true, where AT is the type annotation of the candidate node and ET is the schema type declared for element nodeName in the in-scope element declarations. Condition 3: If the element declaration for nodeName in the in-scope element declarations is not nillable, then the nilled property of the candidateNode is false
      Parameters:
      candidateNode - the candidate node for testing
      nodeName - name of node for comparing
      schemaFile - the location of schema used for testing
      Returns:
      return string value "true" or "false"
      Throws:
      net.sf.saxon.s9api.SaxonApiException - net.sf.saxon.s9api.SaxonApiException
    • CreateValidatorFromXSD

      public Validator CreateValidatorFromXSD(URL xsdPath) throws SAXException, IOException, URISyntaxException
      Create validator from xsd file
      Parameters:
      xsdPath - A URL that denotes the location of a XML schema.
      Returns:
      schema validator
      Throws:
      SAXException - org.xml.sax.SAXException
      URISyntaxException - java.net.URISyntaxException
      IOException - java.io.IOException
    • CheckXPath2

      public String CheckXPath2(String xpath)
      Check XPath2.0
      Parameters:
      xpath - String denoting an xpath syntax
      Returns:
      XdmValue converted to string
    • CheckObservationTypeMeasurement

      public List<String> CheckObservationTypeMeasurement(String href)
      Check Observation Type Measurement in schematron document resultTypeConsistent.sch
      Parameters:
      href - the value of om:type/xlink:href to make the context
      Returns:
      return list of values containing "true" or "false"
    • CheckObservationTypeCategory

      public List<String> CheckObservationTypeCategory(String href)
      Check Observation Type Category in schematron document resultTypeConsistent.sch
      Parameters:
      href - the value of om:type/xlink:href to make the context
      Returns:
      return list of values containing "true" or "false"
    • CheckObservationTypeCount

      public List<String> CheckObservationTypeCount(String href)
      Check Observation Type Count in schematron document resultTypeConsistent.sch
      Parameters:
      href - the value of om:type/xlink:href to make the context
      Returns:
      return list of values containing "true" or "false"
    • CheckObservationTypeTruth

      public List<String> CheckObservationTypeTruth(String href)
      Check Observation Type Truth in schematron document resultTypeConsistent.sch
      Parameters:
      href - the value of om:type/xlink:href to make the context
      Returns:
      return list of values containing "true" or "false"
    • GetResultTypeHref

      public List<String> GetResultTypeHref()

      GetResultTypeHref.

      Returns:
      a List object