opengeospatial / ets-wfs20

Executable Test Suite for WFS 2.0
Other
9 stars 11 forks source link

Comparison test fails to build proper xpath validation expression #74

Closed aaime closed 6 years ago

aaime commented 6 years ago

This test fails to run on a "xs:int" attribute:

https://github.com/opengeospatial/ets-wfs20/blob/d5b632ea04bd719e8e3a8917be0833e1b2ef00b2/src/main/java/org/opengis/cite/iso19142/basic/filter/ComparisonOperatorTests.java#L222

The xpath expression built looks as follows: xs:anySimpleType(ns1:intProperty) ge xs:anySimpleType('-900.0')

This is due to this method not considering the common xs:decimal restrictions (so, most/all of those would also fail in a similar way):

https://github.com/opengeospatial/ets-wfs20/blob/173cea12043185edd33a6a7a1795a81e50d64e3d/src/main/java/org/opengis/cite/iso19142/util/AppSchemaUtils.java#L224

See also "Numeric Data Types" here: https://www.w3schools.com/xml/schema_dtypes_numeric.asp

lgoltz commented 6 years ago

Thank you for reporting.

Can you provide a service for testing?

aaime commented 6 years ago

Hi, I don't have a WFS 2.0 CITE test specific server, but you can hit this one for quick tests as it has attributes in xs:int:

http://cloudsdi.geo-solutions.it/geoserver/ows?service=wfs&version=2.0.0&request=GetCapabilities

http://cloudsdi.geo-solutions.it/geoserver/ows?service=wfs&version=2.0.0&request=DescribeFeatureType&typeNames=test:countries

(you'll get a strange file name if you follow the second link from a browser, but don't worry, it's a schema file)

lgoltz commented 6 years ago

I've tested locally with a unit test and the provided xsd as well as with the service but can reproduce the failure.

lgoltz commented 6 years ago

It seems the provided service for testing is corrupt. "compileXMLSchema" fails with:

3 schema error(s) detected. Severity: WARNING Message: schema_reference.4: Failed to read schema document 'http://cloudsdi.geo-solutions.it:80/geoserver/wfs?request=DescribeFeatureType&version=2.0.0&service=WFS&outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2&typeName=sf%3AAggregateGeoFeature%2Csf%3AEntit%C3%A9G%C3%A9n%C3%A9rique%2Csf%3APrimitiveGeoFeature', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . Location: line=3 column=357 Severity: ERROR Message: src-import.1.1: The namespace attribute 'http://www.eumetsat.int' of an element information item must not be the same as the targetNamespace of the schema it exists in. Location: line=9 column=406 Severity: ERROR Message: src-resolve: Cannot resolve the name 'geosolutions:product_ogclink' to a(n) 'type definition' component. Location: line=288 column=130 

This leads to an empty model and then a NPE in a lot of test (a,omgst others the comparison tests).

@aaime Can you take a look at the provided service?

aaime commented 6 years ago

Weird, was not happening locally, seems like a deployment issue. We'll have a look and get back to you

aaime commented 6 years ago

Note, the test service seems to be working fine now (the above request returns a XML schema document)

lgoltz commented 6 years ago

The problem still occurs. The DescribeFeatureType request [1] returns the follwoing schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
            targetNamespace="http://www.eumetsat.int">
  <xsd:import namespace="http://www.geo-solutions.it"
              schemaLocation="http://cloudsdi.geo-solutions.it:80/geoserver/wfs?request=DescribeFeatureType&amp;version=2.0.0&amp;service=WFS&amp;outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2&amp;typeName=geosolutions%3ALANDSAT8__B1%2Cgeosolutions%3ASENTINEL1__vv%2Cgeosolutions%3ASENTINEL2__B04%2Cgeosolutions%3ASENTINEL2__MOSAIC_B01%2Cgeosolutions%3Aproduct" />
  <xsd:import namespace="http://cite.opengeospatial.org/gmlsf"
              schemaLocation="http://cloudsdi.geo-solutions.it:80/geoserver/wfs?request=DescribeFeatureType&amp;version=2.0.0&amp;service=WFS&amp;outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2&amp;typeName=sf%3AAggregateGeoFeature%2Csf%3AEntit%C3%A9G%C3%A9n%C3%A9rique%2Csf%3APrimitiveGeoFeature" />
  <xsd:import namespace="http://ec2-50-112-206-25.us-west-2.compute.amazonaws.com/geoserver/test"
              schemaLocation="http://cloudsdi.geo-solutions.it:80/geoserver/wfs?request=DescribeFeatureType&amp;version=2.0.0&amp;service=WFS&amp;outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2&amp;typeName=test%3Acountries%2Ctest%3Aeo_collection%2Ctest%3Aeo_product%2Ctest%3Agranule" />
  <xsd:import namespace="http://zaatari.cloudsdi.geo-solutions.it/"
              schemaLocation="http://cloudsdi.geo-solutions.it:80/geoserver/wfs?request=DescribeFeatureType&amp;version=2.0.0&amp;service=WFS&amp;outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2&amp;typeName=zaatari%3AAgricultureSrf%2Czaatari%3ACultureSrf%2Czaatari%3AFacilitySrf%2Czaatari%3AHydrographySrf%2Czaatari%3AInformationPnt%2Czaatari%3ARecreationSrf%2Czaatari%3ASettlementSrf%2Czaatari%3AStructurePnt%2Czaatari%3AStructureSrf%2Czaatari%3ATransportationGroundCrv%2Czaatari%3ATransportationGroundSrf%2Czaatari%3AUtilityInfrastructureSrf%2Czaatari%3Ao2s_A%2Czaatari%3Ao2s_L%2Czaatari%3Aosm_points%2Czaatari%3Azaatari_worldview_timeseries_index" />
  <xsd:import namespace="https://www.openstreetmap.org"
              schemaLocation="http://cloudsdi.geo-solutions.it:80/geoserver/wfs?request=DescribeFeatureType&amp;version=2.0.0&amp;service=WFS&amp;outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2&amp;typeName=osm%3Apublic_gns_iceland_version_log%2Cosm%3Apublic_osm_administrative_version_log%2Cosm%3Apublic_osm_protected_area_version_log" />
  <xsd:import namespace="http://landsat8.com"
              schemaLocation="http://cloudsdi.geo-solutions.it:80/geoserver/wfs?request=DescribeFeatureType&amp;version=2.0.0&amp;service=WFS&amp;outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2&amp;typeName=landsat8%3AB3_index" />
  <xsd:import namespace="http://daraa.cloudsdi.geo-solutions.it/"
              schemaLocation="http://cloudsdi.geo-solutions.it:80/geoserver/wfs?request=DescribeFeatureType&amp;version=2.0.0&amp;service=WFS&amp;outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2&amp;typeName=daraa%3AAgriculturePnt%2Cdaraa%3AAgricultureSrf%2Cdaraa%3ACultivated_2011%2Cdaraa%3ACultivated_2012%2Cdaraa%3ACultivated_2013%2Cdaraa%3ACulturePnt%2Cdaraa%3ACultureSrf%2Cdaraa%3AFacilityPnt%2Cdaraa%3AFacilitySrf%2Cdaraa%3AFieldBoundary_2011%2Cdaraa%3AHealth_2011%2Cdaraa%3AHealth_2012%2Cdaraa%3AHealth_2013%2Cdaraa%3AHydrographyCrv%2Cdaraa%3AHydrographySrf%2Cdaraa%3AInformationPnt%2Cdaraa%3AInventory_2011%2Cdaraa%3AInventory_2012%2Cdaraa%3AInventory_2013%2Cdaraa%3AMilitarySrf%2Cdaraa%3ARecreationPnt%2Cdaraa%3ARecreationSrf%2Cdaraa%3ASettlementPnt%2Cdaraa%3ASettlementSrf%2Cdaraa%3AStructureCrv%2Cdaraa%3AStructurePnt%2Cdaraa%3AStructureSrf%2Cdaraa%3ATransportationGroundCrv%2Cdaraa%3ATransportationGroundPnt%2Cdaraa%3ATransportationGroundSrf%2Cdaraa%3AUtilityInfrastructureCrv%2Cdaraa%3AUtilityInfrastructurePnt%2Cdaraa%3AVegetationSrf%2Cdaraa%3Adaraa_landsat8_timeseries_index%2Cdaraa%3Adaraa_worldview_timeseries_index%2Cdaraa%3Ao2s_A%2Cdaraa%3Ao2s_L%2Cdaraa%3Ao2s_P" />
  <xsd:import namespace="http://www.eumetsat.int"
              schemaLocation="http://cloudsdi.geo-solutions.it:80/geoserver/wfs?request=DescribeFeatureType&amp;version=2.0.0&amp;service=WFS&amp;outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2&amp;typeName=eumetsat%3Ane_10m_coastline%2Ceumetsat%3Ane_boundary_lines_land%2Ceumetsat%3Awind_ascat%2Ceumetsat%3Awind_ascat_reduced%2Ceumetsat%3Awind_ascat_thinned" />
</xsd:schema>

The problem is that the targetNamespace of the schema is the same as the namespace of the last import.

[1] http://cloudsdi.geo-solutions.it/geoserver/ows?service=wfs&version=2.0.0&request=DescribeFeatureType

dstenger commented 6 years ago

@aaime Are there any updates about this issue? Were you able to solve the problem?

aaime commented 6 years ago

I believe that for CITE testing you should be using this URL (notice the sf in the middle of the path): http://cloudsdi.geo-solutions.it/geoserver/sf/ows?service=wfs&version=2.0.0&request=DescribeFeatureType

(the original URL was given for quick tests, then we setup the CITE compliance workspace and referred to it in other tickets and communcations).

The server has a number of uses and it's not configured to be strictly compliant as a whole, just the "sf" workspace is.

That said... GeoServer has been behaving like this in WFS 1.1 and WFS 1.0 as well, for years, so I'm a bit surprised this shows up only now, but I've verified the same error message in the Eclipse XSD validator. I believe that in case of a schema that is just a collection of imports, with no local elements, it would be ok to just remove the targetNamespace attribute, and that would fix the issue, right?

aaime commented 6 years ago

This is still making lots of tests fail, could you have another look using this capabilities URL? http://cloudsdi.geo-solutions.it/geoserver/sf/ows?service=wfs&version=2.0.0&request=GetCapabilities

aaime commented 6 years ago

I've made a pull request that seems to solve the issue for me: https://github.com/opengeospatial/ets-wfs20/pull/105