final String[] queryTokens = { "<ogc:BBOX>",
"<ogc:PropertyName>the_geom</ogc:PropertyName>",
"<gml:Envelope srsDimension=\"2\" srsName=\"urn:x-ogc:def:crs:EPSG:3857\">",
"<gml:lowerCorner>4623055.0 815134.0</gml:lowerCorner>",
"<gml:upperCorner>4629904.0 820740.0</gml:upperCorner>" };
WFSDataStore wfs = getWFSDataStore(new TinyOwsMockHttpClient() {
@Override
public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException {
String request = new String(IOUtils.toByteArray(postContent), "UTF-8");
if (isHitsRequest(request, queryTokens)) {
assertXMLEqual("tinyows/CountFeaturesByBBoxRequest.xml", request);
return new TestHttpResponse(TestData.getResource(this, "tinyows/CountFeaturesByBBox.xml"), "text/xml");
} else if (isResultsRequest(request, queryTokens)) {
assertXMLEqual("tinyows/GetFeaturesByBBoxRequest.xml", request);
return new TestHttpResponse(TestData.getResource(this, "tinyows/GetFeaturesByBBox.xml"), "text/xml");
} else {
return super.post(url, new ByteArrayInputStream(request.getBytes("UTF-8")), postContentType);
}
}
});
SimpleFeatureSource source = wfs.getFeatureSource(typeName);
SimpleFeature sf = getSampleSimpleFeature(source);
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
PropertyName bboxProperty = ff.property(sf.getDefaultGeometryProperty().getName());
Query query = new Query(typeName.getLocalPart(), ff.bbox(bboxProperty, sf.getBounds()));