/** * Test that doing a GetFeature request for data instead of hits still respects max features * with the hitsIgnoreMaxFeatures flag active */ @Test public void testGetFeatureRespectsMaxFeatures() throws Exception { WFSInfo wfs = getWFS(); wfs.setMaxFeatures(1); wfs.setHitsIgnoreMaxFeatures(true); getGeoServer().save(wfs); Document doc = getAsDOM( "wfs?request=GetFeature&typename=cdf:Fifteen" + "&version=1.1.0&service=wfs"); // check we get a feature collection assertEquals("wfs:FeatureCollection", doc.getDocumentElement().getNodeName()); NodeList featureMembers = doc.getElementsByTagName("cdf:Fifteen"); // check feature collection has correct count assertEquals(1, featureMembers.getLength()); }
@Test public void testNumReturnedMatchedWithMaxFeatures() throws Exception { WFSInfo wfs = getWFS(); int oldMaxFeatures = wfs.getMaxFeatures(); boolean oldHitsIgnoreMaxFeatures = wfs.isHitsIgnoreMaxFeatures(); try { wfs.setMaxFeatures(1); wfs.setHitsIgnoreMaxFeatures(true); getGeoServer().save(wfs); Document doc = getAsDOM( "wfs?request=GetFeature&typename=cdf:Seven&version=2.0.0&resultType=results&service=wfs"); assertGML32(doc); assertEquals("7", doc.getDocumentElement().getAttribute("numberMatched")); assertEquals("1", doc.getDocumentElement().getAttribute("numberReturned")); } finally { wfs.setMaxFeatures(oldMaxFeatures); wfs.setHitsIgnoreMaxFeatures(oldHitsIgnoreMaxFeatures); getGeoServer().save(wfs); } }
wfs.setHitsIgnoreMaxFeatures(true); getGeoServer().save(wfs); getAsDOM( "wfs?request=GetFeature&typename=cdf:Seven&version=2.0.0&resultType=hits&service=wfs"); wfs.setHitsIgnoreMaxFeatures(false); getGeoServer().save(wfs); assertEquals("7", doc.getDocumentElement().getAttribute("numberMatched")); } finally { wfs.setMaxFeatures(oldMaxFeatures); wfs.setHitsIgnoreMaxFeatures(hitsIgnoreMaxFeatures); getGeoServer().save(wfs);
/** * Check that max features is respected when the hitsIgnoreMaxFeatures flag is active * * @throws Exception */ @Test public void testHitsIgnoreMaxFeaturesDisabled() throws Exception { WFSInfo wfs = getWFS(); wfs.setMaxFeatures(1); wfs.setHitsIgnoreMaxFeatures(false); getGeoServer().save(wfs); Document doc = getAsDOM( "wfs?request=GetFeature&typename=cdf:Fifteen" + "&version=1.1.0&service=wfs&resultType=hits"); // check it's a feature collection XpathEngine xpath = XMLUnit.newXpathEngine(); assertEquals( "1", xpath.getMatchingNodes("//wfs:FeatureCollection/@numberOfFeatures", doc) .item(0) .getNodeValue()); } }
/** * Check that max features is ignored when the hitsIgnoreMaxFeatures flag is active * * @throws Exception */ @Test public void testHitsIgnoreMaxFeaturesEnabled() throws Exception { WFSInfo wfs = getWFS(); wfs.setMaxFeatures(1); wfs.setHitsIgnoreMaxFeatures(true); getGeoServer().save(wfs); Document doc = getAsDOM( "wfs?request=GetFeature&typename=cdf:Fifteen" + "&version=1.1.0&service=wfs&resultType=hits"); XpathEngine xpath = XMLUnit.newXpathEngine(); assertEquals( "15", xpath.getMatchingNodes("//wfs:FeatureCollection/@numberOfFeatures", doc) .item(0) .getNodeValue()); }