Package org.opengis.cite.iso19142

# Class ETSAssert

java.lang.Object
org.opengis.cite.iso19142.ETSAssert

public class ETSAssert extends Object
Provides a set of custom assertion methods.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `assertDescendantElementCount(Document xmlEntity, QName elementName, int expectedCount)`
  Asserts that the given XML entity contains the expected number of descendant elements having the specified name.
  `static void`
  `assertExceptionReport(Document rspEntity, String exceptionCode, String locator)`
  Asserts that the given response message contains an OGC exception report.
  `static void`
  `assertFeatureAvailability(String id, boolean isAvailable, WFSClient wfsClient)`
  Asserts the availability of a feature having the specified resource identifier.
  `static void`
  `assertFeatureCount(Document featureCollection, QName featureType, int expectedCount)`
  Asserts that the given GetFeature response entity contains the expected number of feature instances having the specified type name.
  `static void`
  `assertQualifiedName(Node node, QName qName)`
  Asserts that the qualified name of a DOM Node matches the expected value.
  `static void`
  `assertResultSetNotEmpty(Document entity, QName featureType)`
  Asserts that the given response entity contains at least one feature instance of the specified type.
  `static void`
  `assertSchematronValid(URL schemaRef, Source xmlSource)`
  Asserts that an XML resource satisfies all applicable constraints specified in a Schematron (ISO 19757-3) schema.
  `static void`
  `assertSchemaValid(Validator validator, Source source)`
  Asserts that an XML resource is schema-valid.
  `static void`
  `assertSimpleProperties(Element feature, Map<org.apache.xerces.xs.XSElementDeclaration,Object> expectedValues, Map<String,String> nsBindings)`
  Asserts that one or more simple properties of a feature have the expected values.
  `static void`
  `assertSimpleWFSCapabilities(Document doc)`
  Asserts that the given DOM document contains a description of a "Simple WFS" implementation.
  `static void`
  `assertSpatialReference(Document entity, String crsId)`
  Asserts that the specified spatial reference occurs in the given XML entity.
  `static void`
  `assertStatusCode(int actualCode, int[] expectedCodes)`
  Asserts that the actual HTTP status code matches one of the expected status codes.
  `static void`
  `assertXPath(String expr, Node context, Map<String,String> nsBindings)`
  Asserts that an XPath 1.0 expression holds true for the given evaluation context.
  `static void`
  `assertXPath2(String expr, Source source, Map<String,String> namespaceBindings)`
  Asserts that an XPath 2.0 expression evaluates to `true` for the given XML source.
  `static boolean`
  `evaluateXPathToBoolean(String expr, Node context, Map<String,String> nsBindings)`
  The XPath is evaluated for given expr and context.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### assertQualifiedName

    public static void assertQualifiedName(Node node, QName qName)
    Asserts that the qualified name of a DOM Node matches the expected value.
    Parameters:
      `node` - The Node to check.
      `qName` - A QName object containing a namespace name (URI) and a local part.

  - ### assertXPath

    public static void assertXPath(String expr, Node context, Map<String,String> nsBindings)
    Asserts that an XPath 1.0 expression holds true for the given evaluation context. The following standard namespace bindings do not need to be explicitly declared:
    - wfs: "http://www.opengis.net/wfs/2.0"
    - fes: "http://www.opengis.net/fes/2.0"
    - ows: "http://www.opengis.net/ows/1.1"
    - xlink: "http://www.w3.org/1999/xlink"
    - gml: "http://www.opengis.net/gml/3.2"
    - soap: "http://www.w3.org/2003/05/soap-envelope"
    - xsi: "http://www.w3.org/2001/XMLSchema-instance"
    The method arguments will be logged at level FINE or lower.
    Parameters:
      `expr` - A valid XPath 1.0 expression.
      `context` - The context node.
      `nsBindings` - A collection of namespace bindings for the XPath expression, where each entry maps a namespace URI (key) to a prefix (value). It may be `null`.

  - ### evaluateXPathToBoolean

    public static boolean evaluateXPathToBoolean(String expr, Node context, Map<String,String> nsBindings)
    The XPath is evaluated for given expr and context.
    Parameters:
      `expr` - A valid XPath expression.
      `context` - A context node.
      `nsBindings` - The list of namespace required for the expr.
    Returns:
      True if XPath is evaluated successfully otherwise false.

  - ### assertXPath2

    public static void assertXPath2(String expr, Source source, Map<String,String> namespaceBindings)
    Asserts that an XPath 2.0 expression evaluates to `true` for the given XML source. That is, the result set is not empty.
    Parameters:
      `expr` - An XPath 2.0 expression.
      `source` - A Source object representing an XML resource.
      `namespaceBindings` - A collection of namespace bindings for the XPath expression, where each entry maps a namespace URI (key) to a prefix (value). It may be `null`.

  - ### assertSchemaValid

    public static void assertSchemaValid(Validator validator, Source source)
    Asserts that an XML resource is schema-valid.
    Parameters:
      `validator` - The Validator to use.
      `source` - The XML Source to be validated.

  - ### assertSchematronValid

    public static void assertSchematronValid(URL schemaRef, Source xmlSource)
    Asserts that an XML resource satisfies all applicable constraints specified in a Schematron (ISO 19757-3) schema. The "xslt2" query language binding is supported. All patterns are checked.
    Parameters:
      `schemaRef` - A URL that denotes the location of a Schematron schema.
      `xmlSource` - The XML Source to be validated.

  - ### assertFeatureAvailability

    public static void assertFeatureAvailability(String id, boolean isAvailable, WFSClient wfsClient)
    Asserts the availability of a feature having the specified resource identifier. The following XPath expression is checked against the GetFeature response entity: `//wfs:member/*[@gml:id = '$id']`
    Parameters:
      `id` - The feature identifier (assigned by the system).
      `isAvailable` - A boolean value asserting that the feature either is ( `true`) or is not (`false`) available.
      `wfsClient` - A WFSClient component that interacts with the SUT.

  - ### assertSimpleProperties

    public static void assertSimpleProperties(Element feature, Map<org.apache.xerces.xs.XSElementDeclaration,Object> expectedValues, Map<String,String> nsBindings)
    Asserts that one or more simple properties of a feature have the expected values. If a property occurs more than once, only the first occurrence is checked.
    Parameters:
      `feature` - An Element node representing a GML feature.
      `expectedValues` - A collection of feature properties containing {prop: value} entries, where the `prop` key is an element declaration (XSElementDeclaration) denoting a property.
      `nsBindings` - A collection of namespace bindings for the supplied properties, where each entry is a {namespace-name: prefix} pair. A binding is not required for standard GML properties.

  - ### assertDescendantElementCount

    public static void assertDescendantElementCount(Document xmlEntity, QName elementName, int expectedCount)
    Asserts that the given XML entity contains the expected number of descendant elements having the specified name.
    Parameters:
      `xmlEntity` - A Document representing an XML entity.
      `elementName` - The qualified name of the element.
      `expectedCount` - The expected number of occurrences.

  - ### assertStatusCode

    public static void assertStatusCode(int actualCode, int[] expectedCodes)
    Asserts that the actual HTTP status code matches one of the expected status codes.
    Parameters:
      `actualCode` - The actual status code.
      `expectedCodes` - An int[] array containing the expected status codes.

  - ### assertSimpleWFSCapabilities

    public static void assertSimpleWFSCapabilities(Document doc)
    Asserts that the given DOM document contains a description of a "Simple WFS" implementation.
    Parameters:
      `doc` - A Document node representing a WFS capabilities document (wfs:WFS_Capabilities}.

  - ### assertFeatureCount

    public static void assertFeatureCount(Document featureCollection, QName featureType, int expectedCount)
    Asserts that the given GetFeature response entity contains the expected number of feature instances having the specified type name.
    Parameters:
      `featureCollection` - A Document representing a GetFeature response (wfs:FeatureCollection).
      `featureType` - The qualified name of a feature type; this may be null, in which case the actual type is ignored.
      `expectedCount` - The expected number of feature instances.

  - ### assertExceptionReport

    public static void assertExceptionReport(Document rspEntity, String exceptionCode, String locator)
    Asserts that the given response message contains an OGC exception report. The message body must contain an XML document that has a document element with the following properties:
    - [local name] = "ExceptionReport"
    - [namespace name] = "http://www.opengis.net/ows/1.1"
    Parameters:
      `rspEntity` - A Document node representing an HTTP response entity.
      `exceptionCode` - The expected OGC exception code.
      `locator` - A case-insensitive string value expected to occur in the locator attribute (e.g. a parameter name); the attribute value will be ignored if the argument is null or empty.

  - ### assertSpatialReference

    public static void assertSpatialReference(Document entity, String crsId)
    Asserts that the specified spatial reference occurs in the given XML entity. In general the reference is conveyed by the srsName attribute that may appear on any geometry element or gml:Envelope. All occurrences must match.
    Parameters:
      `entity` - A Document representing an XML entity such as a GML document or a WFS GetFeature response.
      `crsId` - A CRS identifier (an absolute URI value).

  - ### assertResultSetNotEmpty

    public static void assertResultSetNotEmpty(Document entity, QName featureType)
    Asserts that the given response entity contains at least one feature instance of the specified type.
    Parameters:
      `entity` - A Document representing a GetFeature response entity (wfs:FeatureCollection).
      `featureType` - A QName that identifies the expected feature type; if null, any type is acceptable.