Package org.geoserver.wfs

Examples of org.geoserver.wfs.WFSInfo


     * @throws Exception
     */
    @Test
    public void testPrefixedGetStrictCite() throws Exception {
        GeoServer geoServer = getGeoServer();
        WFSInfo service = geoServer.getService(WFSInfo.class);
        try {
            service.setCiteCompliant(true);
            geoServer.save(service);
           
            final QName typeName = CiteTestData.POLYGONS;
            String path = "ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName="
                    + getLayerId(typeName);
            Document doc = getAsDOM(path);
            assertSchema(doc, CiteTestData.POLYGONS);
        } finally {
            service.setCiteCompliant(false);
            geoServer.save(service);
        }
    }
View Full Code Here


        assertSchema(dom, CiteTestData.POLYGONS);
    }
   
    @Test
    public void testGMLAttributeMapping() throws Exception {
        WFSInfo wfs = getWFS();
        GMLInfo gml = wfs.getGML().get(WFSInfo.Version.V_11);
        gml.setOverrideGMLAttributes(false);
        getGeoServer().save(wfs);
       
        Document dom = getAsDOM("ows?service=WFS&version=2.0.0&request=DescribeFeatureType" +
                "&typename=" + getLayerId(CiteTestData.PRIMITIVEGEOFEATURE));
View Full Code Here

   
  @Override
    protected void setUpInternal(SystemTestData dataDirectory) throws Exception {
     
      //temp hack until feature bounding for 3D is fixed.
      WFSInfo wfs = getWFS();
      wfs.setFeatureBounding(false);
      getGeoServer().save(wfs);
     
        // add extra types
        dataDirectory.addVectorLayer(
                new QName( SystemTestData.SF_URI, "With3D", SystemTestData.SF_PREFIX ),                
View Full Code Here

        doTestSrsNameSyntax(SrsNameStyle.XML, true);
    }
   
    void doTestSrsNameSyntax(SrsNameStyle srsNameStyle, boolean doSave) throws Exception {
        if (doSave) {
            WFSInfo wfs = getWFS();
            GMLInfo gml = wfs.getGML().get(WFSInfo.Version.V_20);
            gml.setSrsNameStyle(srsNameStyle);
            getGeoServer().save(wfs);
        }
   
        String q = "wfs?request=getfeature&service=wfs&version=2.0.0&typenames=cgf:Points";
View Full Code Here

        assertEquals(1, xpath.getMatchingNodes("//wfs:FeatureType[wfs:Name='cgf:MPolygons']/wfs:MetadataURL[@xlink:href='http://www.geoserver.org']", doc).getLength());
    }
   
    @Test
    public void testOtherCRS() throws Exception {
        WFSInfo wfs = getGeoServer().getService(WFSInfo.class);
        wfs.getSRS().add("4326"); // this one corresponds to the native one, should not be generated
        wfs.getSRS().add("3857");
        wfs.getSRS().add("3003");
        try {
            getGeoServer().save(wfs);
           
            // perform get caps
            Document doc = getAsDOM("wfs?service=WFS&version=2.0.0&request=getCapabilities");
            // for each enabled type, check we added the otherSRS
            final List<FeatureTypeInfo> enabledTypes = getCatalog().getFeatureTypes();
            for (Iterator<FeatureTypeInfo> it = enabledTypes.iterator(); it.hasNext();) {
                FeatureTypeInfo ft = it.next();
                if (ft.enabled()) {
                    String prefixedName = ft.prefixedName();
   
                    String base = "//wfs:FeatureType[wfs:Name =\"" + prefixedName + "\"]";
                    XMLAssert.assertXpathExists(base, doc);
                    // we generate the other SRS only if it's not equal to native
                    boolean wgs84Native = "EPSG:4326".equals(ft.getSRS());
                    if(wgs84Native) {
                        XMLAssert.assertXpathEvaluatesTo("2", "count(" + base + "/wfs:OtherCRS)", doc);
                    } else {
                        XMLAssert.assertXpathEvaluatesTo("3", "count(" + base + "/wfs:OtherCRS)", doc);
                        XMLAssert.assertXpathExists(base + "[wfs:OtherCRS = 'urn:ogc:def:crs:EPSG::4326']", doc);
                    }
                    XMLAssert.assertXpathExists(base + "[wfs:OtherCRS = 'urn:ogc:def:crs:EPSG::3003']", doc);
                    XMLAssert.assertXpathExists(base + "[wfs:OtherCRS = 'urn:ogc:def:crs:EPSG::3857']", doc);
                }
            }
        } finally {
            wfs.getSRS().clear();
            getGeoServer().save(wfs);
        }
    }
View Full Code Here

        }
    }
   
    @Test
    public void testOtherSRSSingleTypeOverride() throws Exception {
        WFSInfo wfs = getGeoServer().getService(WFSInfo.class);
        wfs.getSRS().add("4326"); // this one corresponds to the native one, should not be generated
        wfs.getSRS().add("3857");
        wfs.getSRS().add("3003");
        String polygonsName = getLayerId(MockData.POLYGONS);
        FeatureTypeInfo polygons = getCatalog().getFeatureTypeByName(polygonsName);
        polygons.getResponseSRS().add("32632");
        polygons.setOverridingServiceSRS(true);
        try {
            getGeoServer().save(wfs);
            getCatalog().save(polygons);
           
            // check for this layer we have a different list
            Document doc = getAsDOM("wfs?service=WFS&version=2.0.0&request=getCapabilities");
            String base = "//wfs:FeatureType[wfs:Name =\"" + polygonsName + "\"]";
            XMLAssert.assertXpathExists(base, doc);
            XMLAssert.assertXpathEvaluatesTo("1", "count(" + base + "/wfs:OtherCRS)", doc);
            XMLAssert.assertXpathExists(base + "[wfs:OtherCRS = 'urn:ogc:def:crs:EPSG::32632']", doc);
        } finally {
            wfs.getSRS().clear();
            getGeoServer().save(wfs);
            polygons.setOverridingServiceSRS(false);
            polygons.getResponseSRS().clear();
            getCatalog().save(polygons);
        }
View Full Code Here

        // make sure typeName _is_ in the default namespace
        Catalog catalog = getCatalog();
        NamespaceInfo defaultNs = catalog.getDefaultNamespace();
       
        GeoServer geoServer = getGeoServer();
        WFSInfo service = geoServer.getService(WFSInfo.class);
        try {
            catalog.setDefaultNamespace(catalog.getNamespaceByURI(typeName.getNamespaceURI()));
            FeatureTypeInfo typeInfo = catalog.getFeatureTypeByName(typeName.getNamespaceURI(), typeName.getLocalPart());
            typeInfo.setEnabled(true);
            catalog.save(typeInfo);
            DataStoreInfo store = typeInfo.getStore();
            store.setEnabled(true);
            catalog.save(store);
           
            // and request typeName without prefix
            String path = "ows?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName="
                + typeName.getLocalPart();
            Document doc;
       
            //first, non cite compliant mode should find the type even if namespace is not specified
            service.setCiteCompliant(false);
            geoServer.save(service);
            doc = getAsDOM(path);
            //print(doc);
            assertEquals("xsd:schema", doc.getDocumentElement().getNodeName());
   
            //then, in cite compliance more, it should not find the type name
            service.setCiteCompliant(true);
            geoServer.save(service);
            doc = getAsDOM(path);
            //print(doc);
            assertEquals("ows:ExceptionReport", doc.getDocumentElement().getNodeName());
        } finally {
            catalog.setDefaultNamespace(defaultNs);
            service.setCiteCompliant(false);
            geoServer.save(service);
        }
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testPrefixedGetStrictCite() throws Exception {
        GeoServer geoServer = getGeoServer();
        WFSInfo service = geoServer.getService(WFSInfo.class);
        try {
            service.setCiteCompliant(true);
            geoServer.save(service);
           
            final QName typeName = CiteTestData.POLYGONS;
            String path = "ows?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName="
                    + getLayerId(typeName);
            Document doc = getAsDOM(path);
            //print(doc);
            assertEquals("xsd:schema", doc.getDocumentElement().getNodeName());
        } finally {
            service.setCiteCompliant(false);
            geoServer.save(service);
        }
    }
View Full Code Here

        print(dom);
    }
   
    @Test
    public void testGMLAttributeMapping() throws Exception {
        WFSInfo wfs = getWFS();
        GMLInfo gml = wfs.getGML().get(WFSInfo.Version.V_11);
        gml.setOverrideGMLAttributes(false);
        getGeoServer().save(wfs);
       
        Document dom = getAsDOM("ows?service=WFS&version=1.1.0&request=DescribeFeatureType" +
                "&typename=" + getLayerId(CiteTestData.PRIMITIVEGEOFEATURE));
        XMLAssert.assertXpathNotExists("//xsd:element[@name = 'name']", dom);
        XMLAssert.assertXpathNotExists("//xsd:element[@name = 'description']", dom);
       
        wfs = getWFS();
        gml = wfs.getGML().get(WFSInfo.Version.V_11);
        gml.setOverrideGMLAttributes(true);
        getGeoServer().save(wfs);
        wfs = getWFS();
        gml = wfs.getGML().get(WFSInfo.Version.V_11);
        assertTrue(gml.getOverrideGMLAttributes());
        dom = getAsDOM("ows?service=WFS&version=1.1.0&request=DescribeFeatureType" +
                "&typename=" + getLayerId(CiteTestData.PRIMITIVEGEOFEATURE));
        XMLAssert.assertXpathExists("//xsd:element[@name = 'name']", dom);
        XMLAssert.assertXpathExists("//xsd:element[@name = 'description']", dom);
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testEncodeFeatureMember() {

        WFSInfo wfs = getGeoServer().getService(WFSInfo.class);
        boolean encodeFeatureMember = wfs.isEncodeFeatureMember();
        // test one featureMember element
        wfs.setEncodeFeatureMember(false);
        getGeoServer().save(wfs);

        String path = "wfs?request=GetFeature&version=1.1.0&typename=gsml:GeologicUnit&featureid=gsml.geologicunit.16777549126932776,gsml.geologicunit.167775491110573732,gsml.geologicunit.16777549126930540";
        Document doc = getAsDOM(path);
        if (printDoc) {
            LOGGER.info("WFS GetFeature&typename=gsml:GeologicUnit response:\n" + prettyString(doc));
        }

        checkSchemaLocation(doc);

        assertXpathEvaluatesTo("3", "/wfs:FeatureCollection/@numberOfFeatures", doc);
        assertXpathCount(3, "//gsml:GeologicUnit", doc);

        assertEquals(0, doc.getElementsByTagName("gml:featureMember").getLength());
        assertEquals(1, doc.getElementsByTagName("gml:featureMembers").getLength());

        checkGU167775491110573732(doc);
        checkGU16777549126930540(doc);
        checkGU16777549126932776(doc);
        // test many featureMember
        wfs.setEncodeFeatureMember(true);
        getGeoServer().save(wfs);

        path = "wfs?request=GetFeature&version=1.1.0&typename=gsml:GeologicUnit&featureid=gsml.geologicunit.16777549126932776,gsml.geologicunit.167775491110573732,gsml.geologicunit.16777549126930540";
        doc = getAsDOM(path);
        if (printDoc) {
            LOGGER.info("WFS GetFeature&typename=gsml:GeologicUnit response:\n" + prettyString(doc));
        }
        checkSchemaLocation(doc);

        assertXpathEvaluatesTo("3", "/wfs:FeatureCollection/@numberOfFeatures", doc);
        assertXpathCount(3, "//gsml:GeologicUnit", doc);

        assertEquals(3, doc.getElementsByTagName("gml:featureMember").getLength());
        assertEquals(0, doc.getElementsByTagName("gml:featureMembers").getLength());

        checkGU167775491110573732(doc);
        checkGU16777549126930540(doc);
        checkGU16777549126932776(doc);

        wfs = getGeoServer().getService(WFSInfo.class);
        wfs.setEncodeFeatureMember(encodeFeatureMember);
        getGeoServer().save(wfs);
    }
View Full Code Here

TOP

Related Classes of org.geoserver.wfs.WFSInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.