Skip to content

Commit

Permalink
Fix #38: Use GET method only
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmartell committed Nov 10, 2016
1 parent 346ac7b commit 5c2d7c4
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,94 +39,81 @@
*/
public class ResourceIdFilterTests extends QueryFilterFixture {

/**
* [{@code Test}] Submits a GetFeature request containing a ResourceId
* predicate with two resource identifiers. The response entity must include
* only instances of the requested type with matching gml:id attribute
* values.
*
* @param binding
* The ProtocolBinding to use for this request.
* @param featureType
* A QName representing the qualified name of some feature type.
*/
@Test(description = "See ISO 19142: 7.2.2; ISO 19143: 7.11", dataProvider = "protocol-featureType")
public void twoValidFeatureIdentifiers(ProtocolBinding binding,
QName featureType) {
WFSMessage.appendSimpleQuery(this.reqEntity, featureType);
Set<String> idSet = this.dataSampler.selectRandomFeatureIdentifiers(
featureType, 2);
WFSMessage.addResourceIdPredicate(this.reqEntity, idSet);
ClientResponse rsp = wfsClient.submitRequest(reqEntity, binding);
this.rspEntity = extractBodyAsDocument(rsp);
Assert.assertEquals(rsp.getStatus(),
ClientResponse.Status.OK.getStatusCode(),
ErrorMessage.get(ErrorMessageKeys.UNEXPECTED_STATUS));
ETSAssert.assertDescendantElementCount(this.rspEntity, featureType,
idSet.size());
}
/**
* [{@code Test}] Submits a GetFeature request containing a ResourceId
* predicate with two resource identifiers. The response entity must include
* only instances of the requested type with matching gml:id attribute
* values.
*
* @param binding
* The ProtocolBinding to use for this request.
* @param featureType
* A QName representing the qualified name of some feature type.
*/
@Test(description = "See ISO 19142: 7.2.2; ISO 19143: 7.11", dataProvider = "protocol-featureType")
public void twoValidFeatureIdentifiers(ProtocolBinding binding, QName featureType) {
WFSMessage.appendSimpleQuery(this.reqEntity, featureType);
Set<String> idSet = this.dataSampler.selectRandomFeatureIdentifiers(featureType, 2);
WFSMessage.addResourceIdPredicate(this.reqEntity, idSet);
ClientResponse rsp = wfsClient.submitRequest(reqEntity, binding);
this.rspEntity = extractBodyAsDocument(rsp);
Assert.assertEquals(rsp.getStatus(), ClientResponse.Status.OK.getStatusCode(),
ErrorMessage.get(ErrorMessageKeys.UNEXPECTED_STATUS));
ETSAssert.assertDescendantElementCount(this.rspEntity, featureType, idSet.size());
}

/**
* [{@code Test}] Submits a GetFeature request containing a ResourceId
* predicate with an unknown feature identifier. The response entity is
* expected to be a wfs:FeatureCollection that has no matching feature
* member.
*
* @param binding
* The ProtocolBinding to use for this request (e.g. GET, POST).
* @param featureType
* A QName representing the qualified name of some supported
* feature type.
*/
@Test(description = "See ISO 19142: 7.2.2, Table 8", dataProvider = "protocol-featureType")
public void unknownFeatureIdentifier(ProtocolBinding binding,
QName featureType) {
WFSMessage.appendSimpleQuery(this.reqEntity, featureType);
Set<String> idSet = new HashSet<String>();
idSet.add("test-" + UUID.randomUUID());
WFSMessage.addResourceIdPredicate(this.reqEntity, idSet);
ClientResponse rsp = wfsClient.submitRequest(reqEntity, binding);
this.rspEntity = extractBodyAsDocument(rsp);
Assert.assertEquals(rsp.getStatus(),
ClientResponse.Status.OK.getStatusCode(),
ErrorMessage.get(ErrorMessageKeys.UNEXPECTED_STATUS));
ETSAssert.assertQualifiedName(this.rspEntity.getDocumentElement(),
new QName(Namespaces.WFS, WFS2.FEATURE_COLLECTION));
ETSAssert.assertFeatureCount(this.rspEntity, featureType, 0);
}
/**
* [{@code Test}] Submits a GetFeature request containing a ResourceId
* predicate with an unknown feature identifier. The response entity is
* expected to be a wfs:FeatureCollection that has no matching feature
* member.
*
* @param binding
* The ProtocolBinding to use for this request (e.g. GET, POST).
* @param featureType
* A QName representing the qualified name of some supported
* feature type.
*/
@Test(description = "See ISO 19142: 7.2.2, Table 8", dataProvider = "protocol-featureType")
public void unknownFeatureIdentifier(ProtocolBinding binding, QName featureType) {
WFSMessage.appendSimpleQuery(this.reqEntity, featureType);
Set<String> idSet = new HashSet<String>();
idSet.add("test-" + UUID.randomUUID());
WFSMessage.addResourceIdPredicate(this.reqEntity, idSet);
ClientResponse rsp = wfsClient.submitRequest(reqEntity, binding);
this.rspEntity = extractBodyAsDocument(rsp);
Assert.assertEquals(rsp.getStatus(), ClientResponse.Status.OK.getStatusCode(),
ErrorMessage.get(ErrorMessageKeys.UNEXPECTED_STATUS));
ETSAssert.assertQualifiedName(this.rspEntity.getDocumentElement(),
new QName(Namespaces.WFS, WFS2.FEATURE_COLLECTION));
ETSAssert.assertFeatureCount(this.rspEntity, featureType, 0);
}

/**
* [{@code Test}] If a feature instance identified by the RESOURCEID
* parameter is not of the type specified by the TYPENAMES parameter, the
* server shall raise an InvalidParameterValue exception where the "locator"
* attribute value shall be set to "RESOURCEID".
*
* @param binding
* The ProtocolBinding to use for this request.
* @param featureType
* A QName representing the qualified name of some feature type.
*
* @see "OGC 09-025r1, cl. 7.9.2.4.1: typeNames parameter"
*/
@Test(description = "See ISO 19142: 7.9.2.4.1", dataProvider = "protocol-featureType")
public void inconsistentFeatureIdentifierAndType(ProtocolBinding binding,
QName featureType) {
WFSMessage.appendSimpleQuery(this.reqEntity, featureType);
Set<String> idSet = new HashSet<String>();
String featureId = this.dataSampler.getFeatureId(featureType, false);
if (null == featureId) {
throw new SkipException(
"Unable to find id of feature instance that is NOT of type "
+ featureType);
}
idSet.add(featureId);
WFSMessage.addResourceIdPredicate(this.reqEntity, idSet);
ClientResponse rsp = wfsClient.submitRequest(reqEntity, binding);
this.rspEntity = extractBodyAsDocument(rsp);
Assert.assertEquals(rsp.getStatus(),
ClientResponse.Status.BAD_REQUEST.getStatusCode(),
ErrorMessage.get(ErrorMessageKeys.UNEXPECTED_STATUS));
ETSAssert.assertExceptionReport(this.rspEntity,
"InvalidParameterValue", "RESOURCEID");
}
/**
* [{@code Test}] If a feature instance identified by the RESOURCEID
* parameter is not of the type specified by the TYPENAMES parameter, the
* server shall raise an InvalidParameterValue exception where the "locator"
* attribute value shall be set to "RESOURCEID".
*
* @param featureType
* A QName representing the qualified name of some feature type.
*
* @see "OGC 09-025r1, cl. 7.9.2.4.1: typeNames parameter"
*/
@Test(description = "See ISO 19142: 7.9.2.4.1", dataProvider = "instantiated-feature-types")
public void inconsistentFeatureIdentifierAndType(QName featureType) {
WFSMessage.appendSimpleQuery(this.reqEntity, featureType);
Set<String> idSet = new HashSet<String>();
String featureId = this.dataSampler.getFeatureId(featureType, false);
if (null == featureId) {
throw new SkipException("Unable to find id of feature instance that is NOT of type " + featureType);
}
idSet.add(featureId);
WFSMessage.addResourceIdPredicate(this.reqEntity, idSet);
ClientResponse rsp = wfsClient.submitRequest(reqEntity, ProtocolBinding.GET);
this.rspEntity = extractBodyAsDocument(rsp);
Assert.assertEquals(rsp.getStatus(), ClientResponse.Status.BAD_REQUEST.getStatusCode(),
ErrorMessage.get(ErrorMessageKeys.UNEXPECTED_STATUS));
ETSAssert.assertExceptionReport(this.rspEntity, "InvalidParameterValue", "RESOURCEID");
}
}
2 changes: 2 additions & 0 deletions src/site/xhtml/changelog.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
beforePeriod test fails sometimes (empty result set)</li>
<li style="list-style:square">Fix <a target="_blank" href="https://github.com/opengeospatial/ets-wfs20/issues/39">#39</a>:
Schematron validation fails if resolve parameter is set globally</li>
<li style="list-style:square">Fix <a target="_blank" href="https://github.com/opengeospatial/ets-wfs20/issues/38">#38</a>:
ResourceIdFilterTests::inconsistentFeatureIdentifierAndType and POST request</li>
<li style="list-style:square">Fix <a target="_blank" href="https://github.com/opengeospatial/ets-wfs20/issues/23">#23</a>:
SOAP response is not evaluated correctly in describeAllFeatureTypes</li>
<li style="list-style:square">Fix ClassCastException in temporal query tests when operand is gml:TimePeriod</li>
Expand Down

0 comments on commit 5c2d7c4

Please sign in to comment.