Skip to content

Commit

Permalink
Read response entity from InputStream only once
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmartell committed Feb 15, 2016
1 parent e6be53d commit e72b5e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
18 changes: 6 additions & 12 deletions src/main/java/org/opengis/cite/iso19142/ETSAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import net.sf.saxon.s9api.SaxonApiException;
import net.sf.saxon.s9api.XdmValue;

import org.opengis.cite.iso19142.util.ValidationUtils;
import org.opengis.cite.iso19142.util.XMLUtils;
import org.opengis.cite.iso19142.util.NamespaceBindings;
import org.opengis.cite.iso19142.util.TestSuiteLogger;
import org.opengis.cite.iso19142.util.ValidationUtils;
import org.opengis.cite.iso19142.util.WFSClient;
import org.opengis.cite.iso19142.util.XMLUtils;
import org.opengis.cite.validation.SchematronValidator;
import org.opengis.cite.validation.ValidationErrorHandler;
import org.testng.Assert;
Expand All @@ -36,8 +36,6 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.sun.jersey.api.client.ClientResponse;

/**
* Provides a set of custom assertion methods.
*/
Expand Down Expand Up @@ -408,26 +406,22 @@ public static void assertFeatureCount(Document featureCollection,
* <li>[namespace name] = "http://www.opengis.net/ows/1.1"</li>
* </ul>
*
* @param rsp
* A ClientResponse object representing an HTTP response message.
* @param rspEntity
* A Document node representing an HTTP response entity.
* @param exceptionCode
* The expected OGC exception code.
* @param 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.
*/
public static void assertExceptionReport(ClientResponse rsp,
public static void assertExceptionReport(Document rspEntity,
String exceptionCode, String locator) {
Assert.assertEquals(rsp.getStatus(),
ClientResponse.Status.BAD_REQUEST.getStatusCode(),
ErrorMessage.get(ErrorMessageKeys.UNEXPECTED_STATUS));
Document doc = rsp.getEntity(Document.class);
String expr = String.format("//ows11:Exception[@exceptionCode = '%s']",
exceptionCode);
NodeList nodeList = null;
try {
nodeList = XMLUtils.evaluateXPath(doc, expr,
nodeList = XMLUtils.evaluateXPath(rspEntity, expr,
Collections.singletonMap(Namespaces.OWS, "ows11"));
} catch (XPathExpressionException xpe) {
// won't happen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ public void inconsistentFeatureIdentifierAndType(ProtocolBinding binding,
WFSRequest.addResourceIdPredicate(this.reqEntity, idSet);
ClientResponse rsp = wfsClient.submitRequest(reqEntity, binding);
this.rspEntity = extractBodyAsDocument(rsp, binding);
ETSAssert.assertExceptionReport(rsp, "InvalidParameterValue",
"RESOURCEID");
Assert.assertEquals(rsp.getStatus(),
ClientResponse.Status.BAD_REQUEST.getStatusCode(),
ErrorMessage.get(ErrorMessageKeys.UNEXPECTED_STATUS));
ETSAssert.assertExceptionReport(this.rspEntity,
"InvalidParameterValue", "RESOURCEID");
}
}
2 changes: 1 addition & 1 deletion src/site/xhtml/changelog.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ul>
<li style="list-style:square">Fix <a target="_blank"
href="https://github.com/opengeospatial/ets-wfs20/issues/22">issue #22</a>:
Drop typeNames request parameter in unknownFeatureIdentifier test</li>
Add test for inconsistent feature id and type.</li>
<li style="list-style:square">Resolve <a target="_blank"
href="https://github.com/opengeospatial/ets-wfs20/issues/21">issue #21</a>:
Promote preconditions to test methods.</li>
Expand Down

0 comments on commit e72b5e9

Please sign in to comment.