Skip to content

Commit

Permalink
[GEOS-8710] Invalid WFS-T insert on workspace specific service return…
Browse files Browse the repository at this point in the history
…s the wrong exceptionCode
  • Loading branch information
aaime committed Apr 20, 2018
1 parent babd1af commit be95ab1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,14 @@ else if(el instanceof Replace){
private void ensureFeatureNamespaceUriMatches(List features,
NamespaceInfo ns, TransactionRequest t) {
for (Iterator j = features.iterator(); j.hasNext(); ) {
Feature f = (Feature) j.next();
Name n = f.getType().getName();
if (n.getNamespaceURI() != null && !ns.getURI().equals(n.getNamespaceURI())) {
throw new WFSException(t, "No such feature type " + n);
}
Object next = j.next();
if (next instanceof Feature) {
Feature f = (Feature) next;
Name n = f.getType().getName();
if (n.getNamespaceURI() != null && !ns.getURI().equals(n.getNamespaceURI())) {
throw new WFSException(t, "No such feature type " + n);
}
}
}
}

Expand Down
17 changes: 14 additions & 3 deletions src/wfs/src/test/java/org/geoserver/wfs/v2_0/TransactionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,17 @@ public void elementHandlerOrder() throws Exception {

@Test
public void testInsertUnknownFeatureType() throws Exception {
// perform an insert on an invalid feature type
// perform an insert on an invalid feature type on a global service
testInsertUnkonwnFeatureType("wfs");
}

@Test
public void testInsertUnknownFeatureTypeWorkspaceSpecific() throws Exception {
// perform an insert on an invalid feature type on a workspace specific service
testInsertUnkonwnFeatureType("cgf/wfs");
}

public void testInsertUnkonwnFeatureType(String path) throws Exception {
String insert =
"<wfs:Transaction service='WFS' version='2.0.0' "
+ "xmlns:cgf=\"http://www.opengis.net/cite/geometry\" "
Expand All @@ -952,12 +962,13 @@ public void testInsertUnknownFeatureType() throws Exception {
+ "</wfs:Insert>"
+ "</wfs:Transaction>";

MockHttpServletResponse response = postAsServletResponse("wfs", insert);

MockHttpServletResponse response = postAsServletResponse(path, insert);
assertEquals(400, response.getStatus());
Document dom = dom(new ByteArrayInputStream(response.getContentAsByteArray()));
checkOws11Exception(dom, "2.0.0", "InvalidValue", "Transaction");
}

@Test
public void testUpdateBoundedByWithKML() throws Exception {
GeoServer gs = getGeoServer();
Expand Down

0 comments on commit be95ab1

Please sign in to comment.