WFS_1_1_0_Protocol implements WFSProtocol { public WFSResponse issueGetFeatureGET(final GetFeature request) throws IOException { if (!supportsOperation(WFSOperationType.GET_FEATURE, false)) { throw new UnsupportedOperationException( "The server does not support GetFeature for HTTP method GET"); } URL url = getOperationURL(WFSOperationType.GET_FEATURE, false); RequestComponents reqParts = strategy.createGetFeatureRequest(this, request); GetFeatureType requestType = reqParts.getServerRequest(); Map<String, String> getFeatureKvp = reqParts.getKvpParameters(); if(request instanceof GetFeatureQueryAdapter) { GetFeatureQueryAdapter adapter = (GetFeatureQueryAdapter) request; if(adapter.getVendorParameter() != null) { getFeatureKvp.putAll(adapter.getVendorParameter()); } } if (request.getResultType() == ResultType.HITS) { getFeatureKvp.put("RESULTTYPE", ResultTypeType.HITS_LITERAL.getLiteral()); } WFSResponse response = issueGetRequest(requestType, url, getFeatureKvp); return response; } WFS_1_1_0_Protocol(InputStream capabilitiesReader, HTTPClient http,
            Charset defaultEncoding, WFSStrategy strategy); void setStrategy(WFSStrategy strategy); Version getServiceVersion(); String getServiceTitle(); String getServiceAbstract(); Set<String> getServiceKeywords(); URI getServiceProviderUri(); Set<String> getSupportedGetFeatureOutputFormats(); Set<String> getSupportedOutputFormats(String typeName); Set<QName> getFeatureTypeNames(); QName getFeatureTypeName(String typeName); FilterCapabilities getFilterCapabilities(); boolean supportsOperation(WFSOperationType operation, boolean post); URL getOperationURL(WFSOperationType operation, boolean post); String getFeatureTypeTitle(String typeName); String getFeatureTypeAbstract(String typeName); ReferencedEnvelope getFeatureTypeWGS84Bounds(String typeName); String getDefaultCRS(String typeName); Set<String> getSupportedCRSIdentifiers(String typeName); Set<String> getFeatureTypeKeywords(String typeName); URL getDescribeFeatureTypeURLGet(String typeName); WFSResponse describeFeatureTypeGET(String typeName, String outputFormat); WFSResponse describeFeatureTypePOST(String typeName, String outputFormat); WFSResponse issueGetFeatureGET(final GetFeature request); WFSResponse issueGetFeaturePOST(final GetFeature request); void dispose(); static void encode(final EObject request, final Configuration configuration,
            final OutputStream out, final Charset charset); String getDefaultOutputFormat(WFSOperationType operation); Filter[] splitFilters(Filter filter); @Override SimpleFeatureType issueDescribeFeatureTypeGET(final String prefixedTypeName,
            CoordinateReferenceSystem crs);  }
@Test public void testIssueGetFeature_GET() throws IOException { final InputStream responseContent = TestData.openStream(this, GEOS_ARCHSITES.DATA); final TestHttpResponse httpResponse; final String defaultWfs11OutputFormat = "text/xml; subtype=gml/3.1.1"; httpResponse = new TestHttpResponse(defaultWfs11OutputFormat, "UTF-16", responseContent); TestHttpProtocol mockHttp = new TestHttpProtocol(httpResponse); createTestProtocol(GEOS_ARCHSITES.CAPABILITIES, mockHttp, new GeoServerStrategy()); Query query = new Query(GEOS_ARCHSITES.FEATURETYPENAME); GetFeature getFeature = new GetFeatureQueryAdapter(query, defaultWfs11OutputFormat, "EPSG:4326", ResultType.RESULTS); WFSResponse response; response = wfs.issueGetFeatureGET(getFeature); assertNotNull(response); assertEquals(defaultWfs11OutputFormat, response.getContentType()); assertNotNull(response.getInputStream()); assertEquals(Charset.forName("UTF-16"), response.getCharacterEncoding()); URL baseUrl = mockHttp.targetUrl; assertNotNull(baseUrl); Map<String, String> kvp = requestKvp(baseUrl); assertTrue(baseUrl.toExternalForm().startsWith("http: assertEquals("WFS", kvp.get("SERVICE")); assertEquals("1.1.0", kvp.get("VERSION")); assertEquals("GetFeature", kvp.get("REQUEST")); assertEquals(GEOS_ARCHSITES.FEATURETYPENAME, kvp.get("TYPENAME")); assertEquals(defaultWfs11OutputFormat, kvp.get("OUTPUTFORMAT")); assertNotNull(kvp.get("SRSNAME")); assertNull(kvp.get("PROPERTYNAME")); assertNull(kvp.get("MAXFEATURES")); assertNull(kvp.get("FEATUREID")); assertNull(kvp.get("FILTER")); }
@Test public void testIssueGetFeature_GET_HITS() throws IOException { final InputStream responseContent = TestData.openStream(this, GEOS_ARCHSITES.DATA); final TestHttpResponse httpResponse; final String defaultWfs11OutputFormat = "text/xml; subtype=gml/3.1.1"; httpResponse = new TestHttpResponse(defaultWfs11OutputFormat, "UTF-16", responseContent); TestHttpProtocol mockHttp = new TestHttpProtocol(httpResponse); createTestProtocol(GEOS_ARCHSITES.CAPABILITIES, mockHttp, new GeoServerStrategy()); Query query = new Query(GEOS_ARCHSITES.FEATURETYPENAME); GetFeature getFeature = new GetFeatureQueryAdapter(query, defaultWfs11OutputFormat, "EPSG:4326", ResultType.HITS); WFSResponse response; response = wfs.issueGetFeatureGET(getFeature); assertNotNull(response); assertEquals(defaultWfs11OutputFormat, response.getContentType()); assertNotNull(response.getInputStream()); assertEquals(Charset.forName("UTF-16"), response.getCharacterEncoding()); URL baseUrl = mockHttp.targetUrl; assertNotNull(baseUrl); Map<String, String> kvp = requestKvp(baseUrl); assertTrue(baseUrl.toExternalForm().startsWith("http: assertEquals("WFS", kvp.get("SERVICE")); assertEquals("1.1.0", kvp.get("VERSION")); assertEquals("GetFeature", kvp.get("REQUEST")); assertEquals(GEOS_ARCHSITES.FEATURETYPENAME, kvp.get("TYPENAME")); assertEquals(defaultWfs11OutputFormat, kvp.get("OUTPUTFORMAT")); assertEquals("hits", kvp.get("RESULTTYPE")); assertNotNull(kvp.get("SRSNAME")); assertNull(kvp.get("PROPERTYNAME")); assertNull(kvp.get("MAXFEATURES")); assertNull(kvp.get("FEATUREID")); assertNull(kvp.get("FILTER")); }
@Test public void testIssueGetFeature_GET_OptionalParameters() throws Exception { final InputStream responseContent = TestData.openStream(this, GEOS_ARCHSITES.DATA); final TestHttpResponse httpResponse; final String defaultWfs11OutputFormat = "text/xml; subtype=gml/3.1.1"; httpResponse = new TestHttpResponse(defaultWfs11OutputFormat, "UTF-16", responseContent); TestHttpProtocol mockHttp = new TestHttpProtocol(httpResponse); createTestProtocol(GEOS_ARCHSITES.CAPABILITIES, mockHttp, new GeoServerStrategy()); Query query = new Query(GEOS_ARCHSITES.FEATURETYPENAME); query.setMaxFeatures(1000); query.setPropertyNames(new String[] { "cat", "the_geom" }); query.setCoordinateSystem(CRS.decode("EPSG:23030")); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); Filter filter = ff.id(Collections.singleton(ff.featureId("archsites.1"))); query.setFilter(filter); WFSResponse response; wfs.setDescribeFeatureTypeURLOverride(TestData.url(this, GEOS_ARCHSITES.SCHEMA)); GetFeature getFeature = new GetFeatureQueryAdapter(query, defaultWfs11OutputFormat, "EPSG:26713", ResultType.RESULTS); response = wfs.issueGetFeatureGET(getFeature); assertNotNull(response); Map<String, String> kvp = requestKvp(mockHttp.targetUrl); assertEquals("1000", kvp.get("MAXFEATURES")); String propertyName = kvp.get("PROPERTYNAME"); assertEquals("cat,the_geom", propertyName); String srsName = kvp.get("SRSNAME"); assertEquals("EPSG:26713", srsName); assertEquals("archsites.1", kvp.get("FEATUREID")); assertNull("FEATUREID and FILTER are mutually exclusive", kvp.get("FILTER")); filter = ff.equals(ff.property("cat"), ff.literal(1)); query.setFilter(filter); getFeature = new GetFeatureQueryAdapter(query, defaultWfs11OutputFormat, "EPSG:23030", ResultType.RESULTS); response = wfs.issueGetFeatureGET(getFeature); kvp = requestKvp(mockHttp.targetUrl); assertNull("FEATUREID and FILTER are mutually exclusive", kvp.get("FEATUREID")); String encodedFilter = kvp.get("FILTER"); assertNotNull(encodedFilter); Parser filterParser = new Parser(new OGCConfiguration()); Filter parsed = (Filter) filterParser.parse(new StringReader(encodedFilter)); assertTrue(parsed instanceof PropertyIsEqualTo); }