001: package org.geoserver.wfs;
002:
003: import org.w3c.dom.Document;
004: import org.w3c.dom.NodeList;
005:
006: public class GeometrylessTest extends WFSTestSupport {
007:
008: public void testGetFeature10() throws Exception {
009: Document doc = getAsDOM("wfs?request=GetFeature&typename=cite:Geometryless&version=1.0.0&service=wfs");
010: assertEquals("wfs:FeatureCollection", doc.getDocumentElement()
011: .getNodeName());
012: // print(doc);
013:
014: NodeList featureMembers = doc
015: .getElementsByTagName("gml:featureMember");
016: assertFalse(featureMembers.getLength() == 0);
017: NodeList features = doc
018: .getElementsByTagName("cite:Geometryless");
019: assertEquals(3, featureMembers.getLength());
020: }
021:
022: public void testGetFeatureReproject10() throws Exception {
023: getWFS().setFeatureBounding(true);
024: Document doc = getAsDOM("wfs?request=GetFeature&typename=cite:Geometryless&version=1.0.0&service=wfs&srsName=EPSG:900913");
025: assertEquals("wfs:FeatureCollection", doc.getDocumentElement()
026: .getNodeName());
027: // print(doc);
028:
029: NodeList featureMembers = doc
030: .getElementsByTagName("gml:featureMember");
031: assertFalse(featureMembers.getLength() == 0);
032: NodeList features = doc
033: .getElementsByTagName("cite:Geometryless");
034: assertEquals(3, featureMembers.getLength());
035: }
036:
037: public void testGetFeature11() throws Exception {
038: Document doc = getAsDOM("wfs?request=GetFeature&typename=cite:Geometryless&version=1.1.0&service=wfs");
039: assertEquals("wfs:FeatureCollection", doc.getDocumentElement()
040: .getNodeName());
041: // print(doc);
042:
043: NodeList featureMembers = doc
044: .getElementsByTagName("gml:featureMembers");
045: assertFalse(featureMembers.getLength() == 0);
046: NodeList features = doc
047: .getElementsByTagName("cite:Geometryless");
048: assertEquals(3, features.getLength());
049: }
050:
051: public void testGetFeatureReproject11() throws Exception {
052: getWFS().setFeatureBounding(true);
053: Document doc = getAsDOM("wfs?request=GetFeature&typename=cite:Geometryless&version=1.1.0&service=wfs&srsName=EPSG:900913");
054: assertEquals("wfs:FeatureCollection", doc.getDocumentElement()
055: .getNodeName());
056:
057: NodeList featureMembers = doc
058: .getElementsByTagName("gml:featureMembers");
059: assertFalse(featureMembers.getLength() == 0);
060: NodeList features = doc
061: .getElementsByTagName("cite:Geometryless");
062: assertEquals(3, features.getLength());
063: }
064:
065: public void testGetFeatureReprojectPost() throws Exception {
066: String request = "<wfs:GetFeature service=\"WFS\" xmlns:wfs=\"http://www.opengis.net/wfs\" "
067: + "version=\"1.0.0\" outputFormat=\"GML2\" "
068: + "xmlns:topp=\"http://www.openplans.org/topp\" "
069: + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
070: + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
071: + "xsi:schemaLocation=\"http://www.opengis.net/wfs "
072: + "http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd\">"
073: + "<wfs:Query typeName=\"cite:Geometryless\" srsName=\"EPSG:900913\"/></wfs:GetFeature>";
074: System.out.println(request);
075: Document doc = postAsDOM("wfs", request);
076:
077: assertEquals("wfs:FeatureCollection", doc.getDocumentElement()
078: .getNodeName());
079:
080: NodeList featureMembers = doc
081: .getElementsByTagName("gml:featureMember");
082: assertEquals(3, featureMembers.getLength());
083: NodeList features = doc
084: .getElementsByTagName("cite:Geometryless");
085: assertEquals(3, features.getLength());
086: }
087:
088: public void testUpdate() throws Exception {
089: // perform an update
090: String update = "<wfs:Transaction service=\"WFS\" version=\"1.0.0\" "
091: + "xmlns:cite=\"http://www.opengis.net/cite\" "
092: + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
093: + "xmlns:wfs=\"http://www.opengis.net/wfs\" "
094: + "xmlns:gml=\"http://www.opengis.net/gml\"> "
095: + "<wfs:Update typeName=\"cite:Geometryless\" > "
096: + "<wfs:Property>"
097: + "<wfs:Name>name</wfs:Name>"
098: + "<wfs:Value>AnotherName</wfs:Value>"
099: + "</wfs:Property>"
100: + "<ogc:Filter>"
101: + "<ogc:FeatureId fid=\"Geometryless.2\"/>"
102: + "</ogc:Filter>"
103: + "</wfs:Update>"
104: + "</wfs:Transaction>";
105:
106: Document dom = postAsDOM("wfs", update);
107: assertTrue(dom.getElementsByTagName("wfs:SUCCESS").getLength() != 0);
108:
109: // do another get feature
110: dom = getAsDOM("wfs?request=GetFeature&typename=cite:Geometryless&version=1.0.0&service=wfs&featureId=Geometryless.2");
111: assertEquals("AnotherName", dom.getElementsByTagName(
112: "cite:name").item(0).getFirstChild().getNodeValue());
113: }
114:
115: public void testDelete() throws Exception {
116: // perform an update
117: String insert = "<wfs:Transaction service=\"WFS\" version=\"1.0.0\" "
118: + "xmlns:cite=\"http://www.opengis.net/cite\" "
119: + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
120: + "xmlns:wfs=\"http://www.opengis.net/wfs\" "
121: + "xmlns:gml=\"http://www.opengis.net/gml\"> "
122: + "<wfs:Delete typeName=\"cite:Geometryless\" > "
123: + "<ogc:Filter>"
124: + "<ogc:FeatureId fid=\"Geometryless.2\"/>"
125: + "</ogc:Filter>"
126: + "</wfs:Delete>"
127: + "</wfs:Transaction>";
128:
129: Document dom = postAsDOM("wfs", insert);
130: assertTrue(dom.getElementsByTagName("wfs:SUCCESS").getLength() != 0);
131:
132: // do another get feature
133: dom = getAsDOM("wfs?request=GetFeature&typename=cite:Geometryless&version=1.0.0&service=wfs&featureId=Geometryless.2");
134: assertEquals(0, dom.getElementsByTagName("cite:Geometryless")
135: .getLength());
136: }
137:
138: public void testInsert() throws Exception {
139: // perform an insert
140: String insert = "<wfs:Transaction service=\"WFS\" version=\"1.0.0\" "
141: + "xmlns:cite=\"http://www.opengis.net/cite\" "
142: + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
143: + "xmlns:wfs=\"http://www.opengis.net/wfs\" "
144: + "xmlns:gml=\"http://www.opengis.net/gml\"> "
145: + "<wfs:Insert > "
146: + "<cite:Geometryless fid=\"Geometryless.4\">"
147: + "<cite:name>Gimbo</cite:name>"
148: + "<cite:number>1000</cite:number>"
149: + "</cite:Geometryless>"
150: + "</wfs:Insert>"
151: + "</wfs:Transaction>";
152:
153: Document dom = postAsDOM("wfs", insert);
154: assertTrue(dom.getElementsByTagName("wfs:SUCCESS").getLength() != 0);
155: assertTrue(dom.getElementsByTagName("wfs:InsertResult")
156: .getLength() != 0);
157:
158: // do another get feature
159: dom = getAsDOM("wfs?request=GetFeature&typename=cite:Geometryless&version=1.0.0&service=wfs");
160: assertEquals(4, dom.getElementsByTagName("cite:Geometryless")
161: .getLength());
162: }
163:
164: }
|