# WFS 2.0 Conformance Test Suite

## Scope

This executable test suite (ETS) verifies that a WFS 2.0 implementation conforms to OGC 09-025r2/ISO 19142 (Geographic information -- Web feature service) and related standards as depicted in Figure 1. Conformance testing is a kind of "black box" testing that examines externally visible characteristics or behaviors of the SUT and is independent of any implementation details.

Figure 1 - Relevant specifications

The fundamental conformance levels defined in the WFS 2.0 specification are covered by this test suite:

Preconditions
All GML application schemas
GML application schemas defining features and feature collections
Simple WFS
  Implements the following operations: GetCapabilities, DescribeFeatureType, ListStoredQueries, DescribeStoredQueries, and the GetFeature operation with at least the StoredQuery action (GetFeatureById).
Basic WFS
  As for Simple WFS, plus the GetFeature operation with the Query action and the GetPropertyValue operation.
Spatial filter
  Implements the BBOX spatial operator and one or more of the other spatial operators.
  At least one feature needs to have spatial attributes, so that an envelope can be calculated for the tests.
Temporal filter
  Implements the During temporal operator and one or more of the other temporal operators.
Transactional WFS
  As for Basic WFS, plus the Transaction operation.
Locking WFS
  As for Transactional WFS, plus at least one of the GetFeatureWithLock or LockFeature operations.
Spatial joins
  The server shall implement join predicates using spatial operators.
Response paging
  The server shall implement the ability to page through the set of response features or values.
Manage stored queries
  The server shall implement the CreateStoredQuery and the DropStoredQuery operations.
Feature versions
  The server shall implement the ability to navigate feature versions.

## Test requirements

The documents listed below stipulate requirements that must be satisfied by a conforming implementation.

- [ OGC 09-025r2] OpenGIS Web Feature Service 2.0 Interface Standard - With Corrigendum, Version 2.0.2
- [ OGC 09-026r2] OGC Filter Encoding 2.0 Standard - With Corrigendum, Version 2.0.2
- [ OGC 07-036] OpenGIS Geography Markup Language (GML) Encoding Standard, Version 3.2.1

The test suite is schema-aware in the sense that the WFS under test does not need to support any particular application schema or to be pre-loaded with specialized test data. However, the following preconditions must be satisfied by the implementation under test (IUT):

1. The GML application schema meets the requirements of the GML conformance class "GML application schemas defining features and feature collections" (ISO 19136, A.1.4).
2. Data are available for at least one feature type advertised in the capabilities document.

A feature identifier may be supplied for the purpose of verifying the behavior of the `GetFeatureById` stored query. This identifier is required to test a "Simple WFS" implementation but is ignored if the WFS under test implements the "Basic WFS" conformance class.

## Test coverage

Some optional conformance classes are not covered by the test suite. The following capabilities are not tested:

- Inheritance
- Remote resolve

## Test suite structure

The test suite definition file (testng.xml) is located in the root package, `org.opengis.cite.iso19142`. A conformance class corresponds to a <test> element; each test element includes a set of test classes that contain the actual test methods. The general structure of the test suite is shown in Table 1. Note that some schema-related tests are imported from the GML 3.2 test suite.

Table 1 - Test suite structure
Conformance class | Test classes
--- | ---
Preconditions | org.opengis.cite.iso19142.SuitePreconditions
All GML application schemas | org.opengis.cite.iso19136.general.XMLSchemaTests org.opengis.cite.iso19136.general.GeneralSchemaTests org.opengis.cite.iso19136.general.ModelAndSyntaxTests org.opengis.cite.iso19136.general.ComplexPropertyTests
GML application schemas defining features and feature collections | org.opengis.cite.iso19136.components.FeatureComponentTests
Simple WFS | org.opengis.cite.iso19142.simple.*
Basic WFS | org.opengis.cite.iso19142.basic.* org.opengis.cite.iso19142.basic.filter.*
Spatial filter | org.opengis.cite.iso19142.basic.filter.spatial.*
Temporal filter | org.opengis.cite.iso19142.basic.filter.temporal.*
Transactional WFS | org.opengis.cite.iso19142.transaction.TransactionCapabilitiesTests org.opengis.cite.iso19142.transaction.Update org.opengis.cite.iso19142.transaction.InsertTests org.opengis.cite.iso19142.transaction.ReplaceTests org.opengis.cite.iso19142.transaction.DeleteTests
Locking WFS | org.opengis.cite.iso19142.locking.LockingCapabilitiesTests org.opengis.cite.iso19142.locking.LockFeatureTests org.opengis.cite.iso19142.locking.GetFeatureWithLockTests
Spatial joins | org.opengis.cite.iso19142.joins.SpatialJoinTests
Response paging | org.opengis.cite.iso19142.paging.*
Manage stored queries | org.opengis.cite.iso19142.querymgmt.*
Feature versions | org.opengis.cite.iso19142.versioning.*

The Javadoc documentation provides more detailed information about the test methods that constitute the suite.

## How to run the tests

The test suite may be run in any of the following environments:

- Integrated development environment (IDE): The main Java class is `org.opengis.cite.iso19142.TestNGController`.
- REST API: Submit a request that includes the necessary arguments to the test run controller (/rest/suites/wfs20/1.43/run).
- TEAM Engine: Run the CTL script located in the `/src/main/ctl/` directory.

The test run arguments are summarized in Table 2. The Obligation descriptor can have the following values: M (mandatory), O (optional), or C (conditional).

Table 2 - Test run arguments
Name | Value domain | Obligation | Description
--- | --- | --- | ---
wfs | URI | M | A URI that refers to a representation of the service capabilities document. This document does not need to be obtained from the service under test (SUT), but it must describe the SUT. Ampersand ('&') characters appearing within a query parameter value must be percent-encoded as %26.

Note: A test method is skipped if any preconditions were not satisfied. Test prerequisites are usually checked in a configuration method; the results of these can be viewed in the TestNG report by selecting the "Config" check box.

Which tests are actually run is determined by the content of the WFS capabilities document; in particular, the conformance classes that the implementation claims to support. There is a service constraint defined for each conformance class, except for the mandatory "Simple WFS" conformance class (see ISO 19142, Table 13). The boolean-valued service constraints are listed in the OperationsMetadata section of the capabilities document as shown below.

    <OperationsMetadata xmlns="http://www.opengis.net/ows/1.1">
      <!-- Operation and common Parameter definitions omitted -->
      <Constraint name="ImplementsBasicWFS">
        <AllowedValues>
          <Value>TRUE</Value>
          <Value>FALSE</Value>
        </AllowedValues>
        <DefaultValue>TRUE</DefaultValue>
      </Constraint>
      <Constraint name="KVPEncoding">
        <AllowedValues>
          <Value>TRUE</Value>
          <Value>FALSE</Value>
        </AllowedValues>
        <DefaultValue>TRUE</DefaultValue>
      </Constraint>
      <Constraint name="XMLEncoding">
        <AllowedValues>
          <Value>TRUE</Value>
          <Value>FALSE</Value>
        </AllowedValues>
        <DefaultValue>TRUE</DefaultValue>
      </Constraint>
    </OperationsMetadata>