diff --git a/src/extension/app-schema/app-schema-postgis-test/pom.xml b/src/extension/app-schema/app-schema-postgis-test/pom.xml index b97feb05c66..0a5994c3348 100644 --- a/src/extension/app-schema/app-schema-postgis-test/pom.xml +++ b/src/extension/app-schema/app-schema-postgis-test/pom.xml @@ -4,240 +4,239 @@ This code is licensed under the GPL 2.0 license, available at the root application directory. --> - + - 4.0.0 - - - org.geoserver.extension - gs-app-schema - 2.20-SNAPSHOT - + 4.0.0 + org.geoserver.extension - gs-app-schema-postgis-test - Application Schema Integration Online Test with Postgis Database + gs-app-schema + 2.20-SNAPSHOT + + + org.geoserver.extension + gs-app-schema-postgis-test + Application Schema Integration Online Test with Postgis Database - - - org.geoserver.extension - gs-app-schema-core - ${gs.version} - - - org.geoserver - gs-main - - - org.geoserver - gs-main - tests - - - org.geoserver - gs-kml - test - - - - org.geoserver - gs-wfs - - - - org.geoserver - gs-wms - - - net.sf.opencsv - opencsv - 1.8 - test - - - org.geoserver - gs-restconfig - ${project.version} - test - - - org.geoserver - gs-restconfig - ${project.version} - tests - test - - - org.springframework - spring-test - test - - - xmlunit - xmlunit - test - - - org.geotools - gt-app-schema - ${gt.version} - - - org.geotools - gt-app-schema - ${gt.version} - tests - test - - - - org.geotools.schemas - geosciml-2.0 - 2.0.2-4 - test - - - org.geotools.schemas - earthresourceml-1.1 - 1.1.0-3 - test - - - org.geotools.schemas - wfs-1.1 - 1.1.2-2 - test - - - org.geotools - gt-sample-data - ${gt.version} - test - - - org.geotools - gt-jdbc - ${gt.version} - test-jar - test - - - org.geotools.jdbc - gt-jdbc-postgis - ${gt.version} - test - - - org.geotools.jdbc - gt-jdbc-oracle - ${gt.version} - test - - - org.geotools.schemas - geosciml-3.0-seegrid - 3.0.0-1 - test - - - org.geotools.schemas - geosciml-3.2 - 3.2.0-1 - test - - - org.geotools.schemas - wfs-2.0 - 2.0.0-2 - test - - - org.geotools.schemas - samplingSpecimen-2.0 - 2.0.0-1 - test - - - com.fasterxml.jackson.core - jackson-core - test - - - com.fasterxml.jackson.core - jackson-annotations - test - - - com.fasterxml.jackson.core - jackson-databind - test - - - - org.geoserver.web - gs-web-core - ${project.version} - tests - test - - - org.geoserver.web - gs-web-demo - ${project.version} - test - - - org.geoserver.web - gs-web-demo - ${project.version} - tests - test - - + + org.geotools.schemas + geosciml-2.0 + 2.0.2-4 + test + + + org.geotools.schemas + earthresourceml-1.1 + 1.1.0-3 + test + + + org.geotools.schemas + wfs-1.1 + 1.1.2-2 + test + + + org.geotools + gt-sample-data + ${gt.version} + test + + + org.geotools + gt-jdbc + ${gt.version} + test-jar + test + + + org.geotools.jdbc + gt-jdbc-postgis + ${gt.version} + test + + + org.geotools.jdbc + gt-jdbc-oracle + ${gt.version} + test + + + org.geotools.schemas + geosciml-3.0-seegrid + 3.0.0-1 + test + + + org.geotools.schemas + geosciml-3.2 + 3.2.0-1 + test + + + org.geotools.schemas + wfs-2.0 + 2.0.0-2 + test + + + org.geotools.schemas + samplingSpecimen-2.0 + 2.0.0-1 + test + + + com.fasterxml.jackson.core + jackson-core + test + + + com.fasterxml.jackson.core + jackson-annotations + test + + + com.fasterxml.jackson.core + jackson-databind + test + + + + org.geoserver.web + gs-web-core + ${project.version} + tests + test + + + org.geoserver.web + gs-web-demo + ${project.version} + test + + + org.geoserver.web + gs-web-demo + ${project.version} + tests + test + + - - ${app-schema-test-dir}/src/test/java - - - org.apache.maven.plugins - maven-surefire-plugin - - - - **/onlineTest/*.java - **/DefaultGeometryTest.java - ${test.exclude.pattern} - - -Xmx${test.maxHeapSize} -enableassertions ${jvm.opts} + + ${app-schema-test-dir}/src/test/java + + + ${app-schema-test-dir}/src/test/resources + + **/*.properties + **/*.xml + **/*.xsd + **/*.sql + **/*.sld + **/*.png + **/*.json + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + **/onlineTest/*.java + **/DefaultGeometryTest.java + ${test.exclude.pattern} + + -Xmx${test.maxHeapSize} -enableassertions ${jvm.opts} -Djava.awt.headless=${java.awt.headless} -DquietTests=${quietTests} -Dapp-schema.joining=true -DtestDatabase=postgis - - - - - - ${app-schema-test-dir}/src/test/resources - - **/*.properties - **/*.xml - **/*.xsd - **/*.sql - **/*.sld - **/*.png - **/*.json - - - - + + + + diff --git a/src/extension/app-schema/app-schema-test/pom.xml b/src/extension/app-schema/app-schema-test/pom.xml index c7b6b22b782..244632b3c1e 100644 --- a/src/extension/app-schema/app-schema-test/pom.xml +++ b/src/extension/app-schema/app-schema-test/pom.xml @@ -300,8 +300,8 @@ **/IdFunctionWfsWithJoiningTest.java **/XPathPredicateTest.java ${test.exclude.pattern} - **/GetFeaturesNumberMatchedTest.java - **/GetFeatureNumberMatchedFeatureChainingTest.java + **/GetFeatureNumberMatchedGMLTest.java + **/GetFeatureNumberMatchedGeoJSONTest.java **/FeatureChainingWfsTest.java **/NoIdExpressionTest.java diff --git a/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeatureNumberMatchedFeatureChainingTest.java b/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeatureNumberMatchedFeatureChainingTest.java deleted file mode 100644 index 4cca97210cc..00000000000 --- a/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeatureNumberMatchedFeatureChainingTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.geoserver.test; - -import static org.junit.Assert.assertEquals; - -import net.sf.json.JSON; -import net.sf.json.JSONObject; -import org.junit.Test; - -public class GetFeatureNumberMatchedFeatureChainingTest extends AbstractAppSchemaTestSupport { - @Override - protected AbstractAppSchemaMockData createTestData() { - return new FeatureChainingMockData(); - } - - @Test - public void testGetFeatureNumberMatchedWithAndNestedFilterOnDifferentTypes() throws Exception { - - JSON json = - getAsJSON( - "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" - + "&cql_filter= gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'" - + "OR gsml:specification.gsml:GeologicUnit.gsml:composition.gsml:CompositionPart.gsml:proportion.gsml:CGI_TermValue.gsml:value = 'significant'"); - - JSONObject resp = (JSONObject) json; - int numberMatched = resp.getInt("numberMatched"); - int numberReturned = resp.getInt("numberReturned"); - assertEquals(3, numberMatched); - assertEquals(3, numberReturned); - } - - @Test - public void testGetFeatureNumberMatchedWithAndNestedFilterOnSameTypes() throws Exception { - - JSON json = - getAsJSON( - "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" - + "&cql_filter=gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'" - + "AND gsml:specification.gsml:GeologicUnit.gml:name = 'New Group'"); - - JSONObject resp = (JSONObject) json; - int numberMatched = resp.getInt("numberMatched"); - int numberReturned = resp.getInt("numberReturned"); - assertEquals(1, numberMatched); - assertEquals(1, numberReturned); - } -} diff --git a/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeatureNumberMatchedGMLTest.java b/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeatureNumberMatchedGMLTest.java new file mode 100644 index 00000000000..da8b9bf91af --- /dev/null +++ b/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeatureNumberMatchedGMLTest.java @@ -0,0 +1,207 @@ +/* (c) 2014 Open Source Geospatial Foundation - all rights reserved + * (c) 2001 - 2013 OpenPlans + * This code is licensed under the GPL 2.0 license, available at the root + * application directory. + */ + +package org.geoserver.test; + +import org.junit.Test; +import org.w3c.dom.Document; + +/** + * Test the proper encoding of duplicated/repeated features with Ids + * + * @author Victor Tey, CSIRO Exploration and Mining + */ +public class GetFeatureNumberMatchedGMLTest extends AbstractAppSchemaTestSupport { + + @Override + protected FeatureGML32MockData createTestData() { + return new FeatureGML32MockData(); + } + + /** Tests that a count for All the features works * */ + @Test + public void testGetMappedFeatureHitsCount() { + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits"); + LOGGER.info("WFS GetFeature, typename=gsml:MappedFeature response:\n" + prettyString(doc)); + + assertNumberMathcedAndNumberReturned(doc, 5, 0); + } + + /** Test that count with a filter pointing to a root property works */ + @Test + public void testGetFeatureHitsCountWithFilterOnRootAttribute() throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits" + + "&cql_filter=gsml:MappedFeature.gml:name = 'MURRADUC BASALT'"); + LOGGER.info(prettyString(doc)); + assertNumberMathcedAndNumberReturned(doc, 1, 0); + } + + /** Test that count with a filter pointing to a nested property works */ + @Test + public void testGetFeatureHitsCountWithFilterOnNestedAttribute() throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits" + + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'"); + LOGGER.info(prettyString(doc)); + assertNumberMathcedAndNumberReturned(doc, 1, 0); + } + + /** Test that count with a filter pointing to a nested property works */ + @Test + public void testGetFeatureHitsCountWithFilterOnNestedAttribute2() throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits" + + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27"); + LOGGER.info(prettyString(doc)); + + assertNumberMathcedAndNumberReturned(doc, 3, 0); + } + + @Test + public void testGetFeatureHitsCountWithFilterOnNestedAttributeWithMaxNumber() throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits" + + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27&count=1"); + LOGGER.info(prettyString(doc)); + assertNumberMathcedAndNumberReturned(doc, 3, 0); + } + + /** Test that count with a filter pointing to a nested property works */ + @Test + public void testGetFeatureNumberMatchedWithFilterOnNestedAttribute() throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'"); + LOGGER.info(prettyString(doc)); + + assertNumberMathcedAndNumberReturned(doc, 1, 1); + } + + @Test + public void testGetFeatureNumberMatchedWithFilterOnNestedAttribute2() throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27"); + LOGGER.info(prettyString(doc)); + + assertNumberMathcedAndNumberReturned(doc, 3, 3); + } + + @Test + public void testGetFeatureNumberMatchedWithAndNestedFilterOnSameTypes() throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'" + + "AND gsml:specification.gsml:GeologicUnit.gml:name = 'New Group'"); + assertNumberMathcedAndNumberReturned(doc, 1, 1); + } + + @Test + public void testGetFeatureNumberMatchedWithComplexPropertyORSimpleProperty() throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27" + + " OR gsml:MappedFeature.gml:name = 'MURRADUC BASALT'"); + + assertNumberMathcedAndNumberReturned(doc, 4, 4); + } + + @Test + public void testGetFeatureNumberMatchedWithSimplePropertyANDComplexProperty() throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'" + + " AND gsml:MappedFeature.gml:name = 'MURRADUC BASALT'"); + + assertNumberMathcedAndNumberReturned(doc, 1, 1); + } + + @Test + public void testGetFeatureNumberMatchedWithComplexPropertyORSimplePropertyWithPagination() + throws Exception { + + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27" + + " OR gsml:MappedFeature.gml:name = 'MURRADUC BASALT'&startIndex=3&count=2"); + + assertNumberMathcedAndNumberReturned(doc, 4, 1); + } + + @Test + public void testGetFeatureNumberMatchedWithMultipleAND() throws Exception { + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gml:name = 'New Group'" + + " AND gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%25%27 AND gsml:MappedFeature.gml:name = 'MURRADUC BASALT'"); + + assertNumberMathcedAndNumberReturned(doc, 1, 1); + } + + @Test + public void testGetFeatureNumberMatchedWithGeomComplexFilter() throws Exception { + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter= intersects(gsml:shape, buffer(POLYGON((-1.3 52.5,-1.3 52.6,-1.2 52.6,-1.2 52.5,-1.3 52.5)),100))" + + " AND gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27"); + + assertNumberMathcedAndNumberReturned(doc, 3, 3); + } + + @Test + public void testGetFeatureNumberMatchedWithGeomComplexFilterWithPagination() throws Exception { + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter= intersects(gsml:shape, buffer(POLYGON((-1.3 52.5,-1.3 52.6,-1.2 52.6,-1.2 52.5,-1.3 52.5)),100))" + + " AND gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27&startIndex=1"); + + assertNumberMathcedAndNumberReturned(doc, 3, 2); + } + + @Test + public void testGetFeatureNumberMatchedWithGeomComplexFilterManyAND() throws Exception { + Document doc = + getAsDOM( + "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" + + "&cql_filter= intersects(gsml:shape, buffer(POLYGON((-1.3 52.5,-1.3 52.6,-1.2 52.6,-1.2 52.5,-1.3 52.5)),100))" + + " AND gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27 AND gsml:MappedFeature.gml:name = 'GUNTHORPE FORMATION'"); + + assertNumberMathcedAndNumberReturned(doc, 1, 1); + } + + private void assertNumberMathcedAndNumberReturned( + Document doc, int numberMatched, int numberReturned) { + assertXpathEvaluatesTo( + String.valueOf(numberMatched), "/wfs:FeatureCollection/@numberMatched", doc); + assertXpathEvaluatesTo( + String.valueOf(numberReturned), "/wfs:FeatureCollection/@numberReturned", doc); + } +} diff --git a/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeatureNumberMatchedGeoJSONTest.java b/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeatureNumberMatchedGeoJSONTest.java new file mode 100644 index 00000000000..9bd30ab2e68 --- /dev/null +++ b/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeatureNumberMatchedGeoJSONTest.java @@ -0,0 +1,127 @@ +package org.geoserver.test; + +import static org.junit.Assert.assertEquals; + +import net.sf.json.JSON; +import net.sf.json.JSONObject; +import org.junit.Test; + +public class GetFeatureNumberMatchedGeoJSONTest extends AbstractAppSchemaTestSupport { + @Override + protected AbstractAppSchemaMockData createTestData() { + return new FeatureChainingMockData(); + } + + @Test + public void testGetFeatureNumberMatchedWithAndNestedFilterOnDifferentTypes() throws Exception { + + JSON json = + getAsJSON( + "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" + + "&cql_filter= gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'" + + "OR gsml:specification.gsml:GeologicUnit.gsml:composition.gsml:CompositionPart.gsml:proportion.gsml:CGI_TermValue.gsml:value = 'significant'"); + + assertNumberMatchedAndNumberReturned(json, 3, 3); + } + + @Test + public void testGetFeatureNumberMatchedWithAndNestedFilterOnSameTypes() throws Exception { + + JSON json = + getAsJSON( + "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'" + + "AND gsml:specification.gsml:GeologicUnit.gml:name = 'New Group'"); + + assertNumberMatchedAndNumberReturned(json, 1, 1); + } + + @Test + public void testGetFeatureNumberMatchedWithComplexPropertyORSimpleProperty() throws Exception { + + JSON json = + getAsJSON( + "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gsml:composition.gsml:CompositionPart.gsml:proportion.gsml:CGI_TermValue.gsml:value = 'significant'" + + " OR gsml:MappedFeature.gml:name = 'MURRADUC BASALT'"); + + assertNumberMatchedAndNumberReturned(json, 3, 3); + } + + @Test + public void testGetFeatureNumberMatchedWithSimplePropertyANDComplexProperty() throws Exception { + + JSON json = + getAsJSON( + "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gsml:composition.gsml:CompositionPart.gsml:proportion.gsml:CGI_TermValue.gsml:value = 'significant'" + + " AND gsml:MappedFeature.gml:name = 'MURRADUC BASALT'"); + + assertNumberMatchedAndNumberReturned(json, 1, 1); + } + + @Test + public void testGetFeatureNumberMatchedWithComplexPropertyORSimplePropertyWithPagination() + throws Exception { + + JSON json = + getAsJSON( + "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gsml:composition.gsml:CompositionPart.gsml:proportion.gsml:CGI_TermValue.gsml:value = 'significant'" + + " OR gsml:MappedFeature.gml:name = 'MURRADUC BASALT'&startIndex=2"); + + assertNumberMatchedAndNumberReturned(json, 3, 1); + } + + @Test + public void testGetFeatureNumberMatchedWithMultipleAND() throws Exception { + JSON json = + getAsJSON( + "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" + + "&cql_filter=gsml:specification.gsml:GeologicUnit.gsml:composition.gsml:CompositionPart.gsml:proportion.gsml:CGI_TermValue.gsml:value = 'significant'" + + " AND gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%25%27 AND gsml:MappedFeature.gml:name = 'MURRADUC BASALT'"); + + assertNumberMatchedAndNumberReturned(json, 1, 1); + } + + @Test + public void testGetFeatureNumberMatchedWithGeomComplexFilter() throws Exception { + JSON json = + getAsJSON( + "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" + + "&cql_filter= intersects(gsml:shape, buffer(POLYGON((-1.3 52.5,-1.3 52.6,-1.2 52.6,-1.2 52.5,-1.3 52.5)),100))" + + " AND gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27"); + + assertNumberMatchedAndNumberReturned(json, 3, 3); + } + + @Test + public void testGetFeatureNumberMatchedWithGeomComplexFilterWithPagination() throws Exception { + JSON json = + getAsJSON( + "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" + + "&cql_filter= intersects(gsml:shape, buffer(POLYGON((-1.3 52.5,-1.3 52.6,-1.2 52.6,-1.2 52.5,-1.3 52.5)),100))" + + " AND gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27&startIndex=1"); + + assertNumberMatchedAndNumberReturned(json, 3, 2); + } + + @Test + public void testGetFeatureNumberMatchedWithGeomComplexFilterManyAND() throws Exception { + JSON json = + getAsJSON( + "ows?service=WFS&outputFormat=application/json&version=1.1.0&request=GetFeature&typeName=gsml:MappedFeature" + + "&cql_filter= intersects(gsml:shape, buffer(POLYGON((-1.3 52.5,-1.3 52.6,-1.2 52.6,-1.2 52.5,-1.3 52.5)),100))" + + " AND gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27 AND gsml:MappedFeature.gml:name = 'GUNTHORPE FORMATION'"); + assertNumberMatchedAndNumberReturned(json, 1, 1); + } + + private void assertNumberMatchedAndNumberReturned( + JSON resp, int numberMatched, int numberReturned) { + JSONObject jsonObject = (JSONObject) resp; + int numberMatchedValue = jsonObject.getInt("numberMatched"); + int numberReturnedValue = jsonObject.getInt("numberReturned"); + assertEquals(numberMatched, numberMatchedValue); + assertEquals(numberReturned, numberReturnedValue); + } +} diff --git a/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeaturesNumberMatchedTest.java b/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeaturesNumberMatchedTest.java deleted file mode 100644 index 70ebbbe6fbd..00000000000 --- a/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/GetFeaturesNumberMatchedTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* (c) 2014 Open Source Geospatial Foundation - all rights reserved - * (c) 2001 - 2013 OpenPlans - * This code is licensed under the GPL 2.0 license, available at the root - * application directory. - */ - -package org.geoserver.test; - -import org.junit.Test; -import org.w3c.dom.Document; - -/** - * Test the proper encoding of duplicated/repeated features with Ids - * - * @author Victor Tey, CSIRO Exploration and Mining - */ -public class GetFeaturesNumberMatchedTest extends AbstractAppSchemaTestSupport { - - @Override - protected FeatureGML32MockData createTestData() { - return new FeatureGML32MockData(); - } - - /** Tests that a count for All the features works * */ - @Test - public void testGetMappedFeatureHitsCount() { - Document doc = - getAsDOM( - "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits"); - LOGGER.info("WFS GetFeature, typename=gsml:MappedFeature response:\n" + prettyString(doc)); - assertXpathEvaluatesTo("4", "/wfs:FeatureCollection/@numberMatched", doc); - } - - /** Test that count with a filter pointing to a root property works */ - @Test - public void testGetFeatureHitsCountWithFilterOnRootAttribute() throws Exception { - - Document doc = - getAsDOM( - "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits" - + "&cql_filter=gsml:MappedFeature.gml:name = 'MURRADUC BASALT'"); - LOGGER.info(prettyString(doc)); - - assertXpathEvaluatesTo("1", "/wfs:FeatureCollection/@numberMatched", doc); - } - - /** Test that count with a filter pointing to a nested property works */ - @Test - public void testGetFeatureHitsCountWithFilterOnNestedAttribute() throws Exception { - - Document doc = - getAsDOM( - "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits" - + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'"); - LOGGER.info(prettyString(doc)); - - assertXpathEvaluatesTo("1", "/wfs:FeatureCollection/@numberMatched", doc); - } - - /** Test that count with a filter pointing to a nested property works */ - @Test - public void testGetFeatureHitsCountWithFilterOnNestedAttribute2() throws Exception { - - Document doc = - getAsDOM( - "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits" - + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27"); - LOGGER.info(prettyString(doc)); - - assertXpathEvaluatesTo("3", "/wfs:FeatureCollection/@numberMatched", doc); - } - - @Test - public void testGetFeatureHitsCountWithFilterOnNestedAttributeWithMaxNumber() throws Exception { - - Document doc = - getAsDOM( - "ows?service=WFS&version=2.0.0&outputFormat=gml3&request=GetFeature&typeNames=gsml:MappedFeature&resulttype=hits" - + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27&count=1"); - LOGGER.info(prettyString(doc)); - - assertXpathEvaluatesTo("3", "/wfs:FeatureCollection/@numberMatched", doc); - } - - /** Test that count with a filter pointing to a nested property works */ - @Test - public void testGetFeatureNumberMatchedWithFilterOnNestedAttribute() throws Exception { - - Document doc = - getAsDOM( - "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" - + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description = 'Olivine basalt'"); - LOGGER.info(prettyString(doc)); - - assertXpathEvaluatesTo("1", "/wfs:FeatureCollection/@numberMatched", doc); - assertXpathEvaluatesTo("1", "/wfs:FeatureCollection/@numberReturned", doc); - } - - @Test - public void testGetFeatureNumberMatchedWithFilterOnNestedAttribute2() throws Exception { - - Document doc = - getAsDOM( - "ows?service=WFS&version=2.0.0&outputFormat=gml32&request=GetFeature&typeNames=gsml:MappedFeature" - + "&cql_filter=gsml:MappedFeature.gsml:specification.gsml:GeologicUnit.gml:description LIKE %27%25Olivine%20basalt%2C%20tuff%25%27"); - LOGGER.info(prettyString(doc)); - - assertXpathEvaluatesTo("3", "/wfs:FeatureCollection/@numberMatched", doc); - assertXpathEvaluatesTo("3", "/wfs:FeatureCollection/@numberReturned", doc); - } -} diff --git a/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/IdFunctionWfsTest.java b/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/IdFunctionWfsTest.java index f954a1e4ec1..37c6064c2d0 100644 --- a/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/IdFunctionWfsTest.java +++ b/src/extension/app-schema/app-schema-test/src/test/java/org/geoserver/test/IdFunctionWfsTest.java @@ -72,12 +72,10 @@ public void testGetFeature() { /** Test content of GetFeature response. */ @Test public void testGetFeatureContent() throws Exception { - Document doc = - getAsDOM( - "wfs?request=GetFeature&version=1.1.0&typename=gsml:MappedFeature&featureID=mf1,mf2,mf3,mf4"); + Document doc = getAsDOM("wfs?request=GetFeature&version=1.1.0&typename=gsml:MappedFeature"); LOGGER.info("WFS GetFeature&typename=gsml:MappedFeature response:\n" + prettyString(doc)); - assertXpathEvaluatesTo("4", "/wfs:FeatureCollection/@numberOfFeatures", doc); - assertXpathCount(4, "//gsml:MappedFeature", doc); + assertXpathEvaluatesTo("5", "/wfs:FeatureCollection/@numberOfFeatures", doc); + assertXpathCount(5, "//gsml:MappedFeature", doc); // mf1 {