Source Code Cross Referenced for TransactionTest.java in  » GIS » GeoServer » org » geoserver » wfs » v1_1 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoServer » org.geoserver.wfs.v1_1 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.geoserver.wfs.v1_1;
002:
003:        import javax.xml.namespace.QName;
004:
005:        import org.geoserver.data.test.MockData;
006:        import org.geoserver.wfs.WFSTestSupport;
007:        import org.geoserver.wfs.kvp.SrsNameKvpParser;
008:        import org.w3c.dom.Document;
009:        import org.w3c.dom.Element;
010:        import org.w3c.dom.NodeList;
011:
012:        public class TransactionTest extends WFSTestSupport {
013:
014:            protected void setUp() throws Exception {
015:                super .setUp();
016:
017:                dataDirectory.addFeatureType(new QName(MockData.SF_URI,
018:                        "WithGMLProperties", MockData.SF_PREFIX), getClass()
019:                        .getResourceAsStream("WithGMLProperties.properties"));
020:                applicationContext.refresh();
021:
022:            }
023:
024:            public void testInsert1() throws Exception {
025:                String xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\" "
026:                        + " xmlns:wfs=\"http://www.opengis.net/wfs\" "
027:                        + " xmlns:gml=\"http://www.opengis.net/gml\" "
028:                        + " xmlns:sf=\"http://cite.opengeospatial.org/gmlsf\">"
029:                        + "<wfs:Insert handle=\"insert-1\">"
030:                        + " <sf:PrimitiveGeoFeature gml:id=\"cite.gmlsf0-f01\">"
031:                        + "  <gml:description>"
032:                        + "Fusce tellus ante, tempus nonummy, ornare sed, accumsan nec, leo."
033:                        + "Vivamus pulvinar molestie nisl."
034:                        + "</gml:description>"
035:                        + "<gml:name>Aliquam condimentum felis sit amet est.</gml:name>"
036:                        //+ "<gml:name codeSpace=\"http://cite.opengeospatial.org/gmlsf\">cite.gmlsf0-f01</gml:name>"
037:                        + "<sf:curveProperty>"
038:                        + "  <gml:LineString gml:id=\"cite.gmlsf0-g01\" srsName=\"urn:x-ogc:def:crs:EPSG:6.11.2:4326\">"
039:                        + "   <gml:posList>47.608284 19.034142 51.286873 16.7836 49.849854 15.764992</gml:posList>"
040:                        + " </gml:LineString>"
041:                        + "</sf:curveProperty>"
042:                        + "<sf:intProperty>1025</sf:intProperty>"
043:                        + "<sf:measurand>7.405E2</sf:measurand>"
044:                        + "<sf:dateTimeProperty>2006-06-23T12:43:12+01:00</sf:dateTimeProperty>"
045:                        + "<sf:decimalProperty>90.62</sf:decimalProperty>"
046:                        + "</sf:PrimitiveGeoFeature>"
047:                        + "</wfs:Insert>"
048:                        + "<wfs:Insert handle=\"insert-2\">"
049:                        + "<sf:AggregateGeoFeature gml:id=\"cite.gmlsf0-f02\">"
050:                        + " <gml:description>"
051:                        + "Duis nulla nisi, molestie vel, rhoncus a, ullamcorper eu, justo. Sed bibendum."
052:                        + " Ut sem. Mauris nec nunc a eros aliquet pharetra. Mauris nonummy, pede et"
053:                        + " tincidunt ultrices, mauris lectus fermentum massa, in ullamcorper lectus"
054:                        + "felis vitae metus. Sed imperdiet sollicitudin dolor."
055:                        + " </gml:description>"
056:                        + " <gml:name codeSpace=\"http://cite.opengeospatial.org/gmlsf\">cite.gmlsf0-f02</gml:name>"
057:                        + " <gml:name>Quisqué viverra</gml:name>"
058:                        + " <gml:boundedBy>"
059:                        + "   <gml:Envelope srsName=\"urn:x-ogc:def:crs:EPSG:6.11.2:4326\">"
060:                        + "     <gml:lowerCorner>36.1 8.0</gml:lowerCorner>"
061:                        + "    <gml:upperCorner>52.0 21.1</gml:upperCorner>"
062:                        + "   </gml:Envelope>"
063:                        + "  </gml:boundedBy>"
064:                        + "   <sf:multiPointProperty>"
065:                        + "<gml:MultiPoint srsName=\"urn:x-ogc:def:crs:EPSG:6.11.2:4326\">"
066:                        + "<gml:pointMember>"
067:                        + " <gml:Point><gml:pos>49.325176 21.036873</gml:pos></gml:Point>"
068:                        + "</gml:pointMember>"
069:                        + "<gml:pointMember>"
070:                        + "  <gml:Point><gml:pos>36.142586 13.56189</gml:pos></gml:Point>"
071:                        + "</gml:pointMember>"
072:                        + "<gml:pointMember>"
073:                        + "  <gml:Point><gml:pos>51.920937 8.014193</gml:pos></gml:Point>"
074:                        + "</gml:pointMember>"
075:                        + "</gml:MultiPoint>"
076:                        + "</sf:multiPointProperty>"
077:                        +
078:
079:                        "<sf:doubleProperty>2012.78</sf:doubleProperty>"
080:                        + "  <sf:intRangeProperty>43</sf:intRangeProperty>"
081:                        + " <sf:strProperty>"
082:                        + "Donec ligulä pede, sodales iń, vehicula eu, sodales et, lêo."
083:                        + "</sf:strProperty>"
084:                        + "<sf:featureCode>AK121</sf:featureCode>"
085:                        + "</sf:AggregateGeoFeature>"
086:                        + "</wfs:Insert>"
087:                        + "</wfs:Transaction>";
088:
089:                Document dom = postAsDOM("wfs", xml);
090:                assertEquals("wfs:TransactionResponse", dom
091:                        .getDocumentElement().getNodeName());
092:                assertTrue(dom.getElementsByTagName("ogc:FeatureId")
093:                        .getLength() > 0);
094:            }
095:
096:            public void testInsertWithNoSRS() throws Exception {
097:                // 1. do a getFeature
098:                String getFeature = "<wfs:GetFeature " + "service=\"WFS\" "
099:                        + "version=\"1.1.0\" "
100:                        + "xmlns:cgf=\"http://www.opengis.net/cite/geometry\" "
101:                        + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
102:                        + "xmlns:wfs=\"http://www.opengis.net/wfs\" " + "> "
103:                        + "<wfs:Query typeName=\"cgf:Points\"> "
104:                        + "<wfs:PropertyName>cite:id</wfs:PropertyName> "
105:                        + "</wfs:Query> " + "</wfs:GetFeature>";
106:
107:                Document dom = postAsDOM("wfs", getFeature);
108:                int n = dom.getElementsByTagName("cgf:Points").getLength();
109:
110:                // perform an insert
111:                String insert = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\" "
112:                        + "xmlns:cgf=\"http://www.opengis.net/cite/geometry\" "
113:                        + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
114:                        + "xmlns:wfs=\"http://www.opengis.net/wfs\" "
115:                        + "xmlns:gml=\"http://www.opengis.net/gml\"> "
116:                        + "<wfs:Insert > "
117:                        + "<cgf:Points>"
118:                        + "<cgf:pointProperty>"
119:                        + "<gml:Point>"
120:                        + "<gml:pos>20 40</gml:pos>"
121:                        + "</gml:Point>"
122:                        + "</cgf:pointProperty>"
123:                        + "<cgf:id>t0002</cgf:id>"
124:                        + "</cgf:Points>"
125:                        + "</wfs:Insert>"
126:                        + "</wfs:Transaction>";
127:
128:                dom = postAsDOM("wfs", insert);
129:
130:                NodeList numberInserteds = dom
131:                        .getElementsByTagName("wfs:totalInserted");
132:                Element numberInserted = (Element) numberInserteds.item(0);
133:                assertNotNull(numberInserted);
134:                assertEquals("1", numberInserted.getFirstChild().getNodeValue());
135:                String fid = getFirstElementByTagName(dom, "ogc:FeatureId")
136:                        .getAttribute("fid");
137:
138:                // check insertion occurred
139:                dom = postAsDOM("wfs", getFeature);
140:                assertEquals(n + 1, dom.getElementsByTagName("cgf:Points")
141:                        .getLength());
142:
143:                // check coordinate order is preserved
144:                getFeature = "<wfs:GetFeature " + "service=\"WFS\" "
145:                        + "version=\"1.1.0\" "
146:                        + "xmlns:cgf=\"http://www.opengis.net/cite/geometry\" "
147:                        + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
148:                        + "xmlns:wfs=\"http://www.opengis.net/wfs\" " + "> "
149:                        + "<wfs:Query typeName=\"cgf:Points\"> "
150:                        + "<ogc:Filter>" + "<ogc:PropertyIsEqualTo>"
151:                        + "<ogc:PropertyName>cgf:id</ogc:PropertyName>"
152:                        + "<ogc:Literal>t0002</ogc:Literal>"
153:                        + "</ogc:PropertyIsEqualTo>"
154:                        + "</ogc:Filter></wfs:Query> " + "</wfs:GetFeature>";
155:                dom = postAsDOM("wfs", getFeature);
156:                //        print(dom);
157:                assertEquals("20.0 40.0", getFirstElementByTagName(dom,
158:                        "gml:pos").getFirstChild().getNodeValue());
159:            }
160:
161:            public void testInsertWithSRS() throws Exception {
162:
163:                // 1. do a getFeature
164:                String getFeature = "<wfs:GetFeature " + "service=\"WFS\" "
165:                        + "version=\"1.1.0\" "
166:                        + "xmlns:cgf=\"http://www.opengis.net/cite/geometry\" "
167:                        + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
168:                        + "xmlns:wfs=\"http://www.opengis.net/wfs\" " + "> "
169:                        + "<wfs:Query typeName=\"cgf:Points\"/> "
170:                        + "</wfs:GetFeature>";
171:
172:                Document dom = postAsDOM("wfs", getFeature);
173:                //        print(dom);
174:                int n = dom.getElementsByTagName("cgf:Points").getLength();
175:
176:                // perform an insert
177:                String insert = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\" "
178:                        + "xmlns:cgf=\"http://www.opengis.net/cite/geometry\" "
179:                        + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
180:                        + "xmlns:wfs=\"http://www.opengis.net/wfs\" "
181:                        + "xmlns:gml=\"http://www.opengis.net/gml\"> "
182:                        + "<wfs:Insert srsName=\"EPSG:32615\"> "
183:                        + "<cgf:Points>"
184:                        + "<cgf:pointProperty>"
185:                        + "<gml:Point>"
186:                        + "<gml:pos>1 1</gml:pos>"
187:                        + "</gml:Point>"
188:                        + "</cgf:pointProperty>"
189:                        + "<cgf:id>t0003</cgf:id>"
190:                        + "</cgf:Points>"
191:                        + "</wfs:Insert>" + "</wfs:Transaction>";
192:
193:                dom = postAsDOM("wfs", insert);
194:
195:                NodeList numberInserteds = dom
196:                        .getElementsByTagName("wfs:totalInserted");
197:                Element numberInserted = (Element) numberInserteds.item(0);
198:
199:                assertNotNull(numberInserted);
200:                assertEquals("1", numberInserted.getFirstChild().getNodeValue());
201:
202:                // do another get feature
203:                getFeature = "<wfs:GetFeature "
204:                        + "service=\"WFS\" version=\"1.1.0\" "
205:                        + "xmlns:cgf=\"http://www.opengis.net/cite/geometry\" "
206:                        + "xmlns:ogc=\"http://www.opengis.net/ogc\" "
207:                        + "xmlns:wfs=\"http://www.opengis.net/wfs\" " + "> "
208:                        + "<wfs:Query typeName=\"cgf:Points\"> "
209:                        + "</wfs:Query> " + "</wfs:GetFeature>";
210:                dom = postAsDOM("wfs", getFeature);
211:                //        print(dom);
212:
213:                NodeList pointsList = dom.getElementsByTagName("cgf:Points");
214:                assertEquals(n + 1, pointsList.getLength());
215:            }
216:
217:            public void testInsertWithGMLProperties() throws Exception {
218:
219:                String xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\" "
220:                        + "xmlns:wfs=\"http://www.opengis.net/wfs\" "
221:                        + "xmlns:sf=\"http://cite.opengeospatial.org/gmlsf\" "
222:                        + "xmlns:gml=\"http://www.opengis.net/gml\">"
223:                        + "<wfs:Insert>"
224:                        + "<sf:WithGMLProperties>"
225:                        + "<gml:location>"
226:                        + "<gml:Point>"
227:                        + "<gml:coordinates>2,2</gml:coordinates>"
228:                        + "</gml:Point>"
229:                        + "</gml:location>"
230:                        + "<gml:name>two</gml:name>"
231:                        + "<sf:foo>2</sf:foo>"
232:                        + "</sf:WithGMLProperties>"
233:                        + "</wfs:Insert>"
234:                        + "</wfs:Transaction>";
235:
236:                Document dom = postAsDOM("wfs", xml);
237:                assertEquals("wfs:TransactionResponse", dom
238:                        .getDocumentElement().getNodeName());
239:
240:                Element inserted = getFirstElementByTagName(dom,
241:                        "wfs:totalInserted");
242:                assertEquals("1", inserted.getFirstChild().getNodeValue());
243:
244:                dom = getAsDOM("wfs?request=getfeature&service=wfs&version=1.1.0&typename=sf:WithGMLProperties");
245:                NodeList features = dom
246:                        .getElementsByTagName("sf:WithGMLProperties");
247:                assertEquals(2, features.getLength());
248:
249:                Element feature = (Element) features.item(1);
250:                assertEquals("two", getFirstElementByTagName(feature,
251:                        "gml:name").getFirstChild().getNodeValue());
252:                assertEquals("2", getFirstElementByTagName(feature, "sf:foo")
253:                        .getFirstChild().getNodeValue());
254:
255:                Element location = getFirstElementByTagName(feature,
256:                        "gml:location");
257:                Element pos = getFirstElementByTagName(location, "gml:pos");
258:
259:                assertEquals("2.0 2.0", pos.getFirstChild().getNodeValue());
260:
261:                xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\" "
262:                        + "xmlns:wfs=\"http://www.opengis.net/wfs\" "
263:                        + "xmlns:sf=\"http://cite.opengeospatial.org/gmlsf\" "
264:                        + "xmlns:gml=\"http://www.opengis.net/gml\">"
265:                        + "<wfs:Insert>" + "<sf:WithGMLProperties>"
266:                        + "<sf:location>" + "<gml:Point>"
267:                        + "<gml:coordinates>3,3</gml:coordinates>"
268:                        + "</gml:Point>" + "</sf:location>"
269:                        + "<sf:name>three</sf:name>" + "<sf:foo>3</sf:foo>"
270:                        + "</sf:WithGMLProperties>" + "</wfs:Insert>"
271:                        + "</wfs:Transaction>";
272:
273:                dom = postAsDOM("wfs", xml);
274:
275:                assertEquals("wfs:TransactionResponse", dom
276:                        .getDocumentElement().getNodeName());
277:
278:                dom = getAsDOM("wfs?request=getfeature&service=wfs&version=1.1.0&typename=sf:WithGMLProperties");
279:
280:                features = dom.getElementsByTagName("sf:WithGMLProperties");
281:                assertEquals(3, features.getLength());
282:
283:                feature = (Element) features.item(2);
284:                assertEquals("three", getFirstElementByTagName(feature,
285:                        "gml:name").getFirstChild().getNodeValue());
286:                assertEquals("3", getFirstElementByTagName(feature, "sf:foo")
287:                        .getFirstChild().getNodeValue());
288:
289:                location = getFirstElementByTagName(feature, "gml:location");
290:                pos = getFirstElementByTagName(location, "gml:pos");
291:
292:                assertEquals("3.0 3.0", pos.getFirstChild().getNodeValue());
293:            }
294:
295:            public void testUpdateWithGMLProperties() throws Exception {
296:                String xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\""
297:                        + " xmlns:sf=\"http://cite.opengeospatial.org/gmlsf\""
298:                        + " xmlns:ogc=\"http://www.opengis.net/ogc\""
299:                        + " xmlns:gml=\"http://www.opengis.net/gml\""
300:                        + " xmlns:wfs=\"http://www.opengis.net/wfs\">"
301:                        + " <wfs:Update typeName=\"sf:WithGMLProperties\">"
302:                        + "   <wfs:Property>"
303:                        + "     <wfs:Name>gml:name</wfs:Name>"
304:                        + "     <wfs:Value>two</wfs:Value>"
305:                        + "   </wfs:Property>"
306:                        + "   <wfs:Property>"
307:                        + "     <wfs:Name>gml:location</wfs:Name>"
308:                        + "     <wfs:Value>"
309:                        + "        <gml:Point>"
310:                        + "          <gml:coordinates>2,2</gml:coordinates>"
311:                        + "        </gml:Point>"
312:                        + "     </wfs:Value>"
313:                        + "   </wfs:Property>"
314:                        + "   <wfs:Property>"
315:                        + "     <wfs:Name>sf:foo</wfs:Name>"
316:                        + "     <wfs:Value>2</wfs:Value>"
317:                        + "   </wfs:Property>"
318:                        + "   <ogc:Filter>"
319:                        + "     <ogc:PropertyIsEqualTo>"
320:                        + "       <ogc:PropertyName>foo</ogc:PropertyName>"
321:                        + "       <ogc:Literal>1</ogc:Literal>"
322:                        + "     </ogc:PropertyIsEqualTo>"
323:                        + "   </ogc:Filter>"
324:                        + " </wfs:Update>" + "</wfs:Transaction>";
325:
326:                Document dom = postAsDOM("wfs", xml);
327:                assertEquals("wfs:TransactionResponse", dom
328:                        .getDocumentElement().getNodeName());
329:
330:                Element updated = getFirstElementByTagName(dom,
331:                        "wfs:totalUpdated");
332:                assertEquals("1", updated.getFirstChild().getNodeValue());
333:
334:                dom = getAsDOM("wfs?request=getfeature&service=wfs&version=1.1.0&typename=sf:WithGMLProperties");
335:                //        print( dom );
336:                NodeList features = dom
337:                        .getElementsByTagName("sf:WithGMLProperties");
338:                assertEquals(1, features.getLength());
339:
340:                Element feature = (Element) features.item(0);
341:                assertEquals("two", getFirstElementByTagName(feature,
342:                        "gml:name").getFirstChild().getNodeValue());
343:                assertEquals("2", getFirstElementByTagName(feature, "sf:foo")
344:                        .getFirstChild().getNodeValue());
345:
346:                Element location = getFirstElementByTagName(feature,
347:                        "gml:location");
348:                Element pos = getFirstElementByTagName(location, "gml:pos");
349:
350:                assertEquals("2.0 2.0", pos.getFirstChild().getNodeValue());
351:
352:                xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\""
353:                        + " xmlns:sf=\"http://cite.opengeospatial.org/gmlsf\""
354:                        + " xmlns:ogc=\"http://www.opengis.net/ogc\""
355:                        + " xmlns:gml=\"http://www.opengis.net/gml\""
356:                        + " xmlns:wfs=\"http://www.opengis.net/wfs\">"
357:                        + " <wfs:Update typeName=\"sf:WithGMLProperties\">"
358:                        + "   <wfs:Property>"
359:                        + "     <wfs:Name>sf:name</wfs:Name>"
360:                        + "     <wfs:Value>trhee</wfs:Value>"
361:                        + "   </wfs:Property>" + "   <wfs:Property>"
362:                        + "     <wfs:Name>sf:location</wfs:Name>"
363:                        + "     <wfs:Value>" + "        <gml:Point>"
364:                        + "          <gml:coordinates>3,3</gml:coordinates>"
365:                        + "        </gml:Point>" + "     </wfs:Value>"
366:                        + "   </wfs:Property>" + "   <wfs:Property>"
367:                        + "     <wfs:Name>sf:foo</wfs:Name>"
368:                        + "     <wfs:Value>3</wfs:Value>"
369:                        + "   </wfs:Property>" + "   <ogc:Filter>"
370:                        + "     <ogc:PropertyIsEqualTo>"
371:                        + "       <ogc:PropertyName>foo</ogc:PropertyName>"
372:                        + "       <ogc:Literal>2</ogc:Literal>"
373:                        + "     </ogc:PropertyIsEqualTo>" + "   </ogc:Filter>"
374:                        + " </wfs:Update>" + "</wfs:Transaction>";
375:
376:                dom = postAsDOM("wfs", xml);
377:                assertEquals("wfs:TransactionResponse", dom
378:                        .getDocumentElement().getNodeName());
379:
380:                updated = getFirstElementByTagName(dom, "wfs:totalUpdated");
381:                assertEquals("1", updated.getFirstChild().getNodeValue());
382:
383:                dom = getAsDOM("wfs?request=getfeature&service=wfs&version=1.1.0&typename=sf:WithGMLProperties");
384:
385:                features = dom.getElementsByTagName("sf:WithGMLProperties");
386:                assertEquals(1, features.getLength());
387:
388:                feature = (Element) features.item(0);
389:                assertEquals("trhee", getFirstElementByTagName(feature,
390:                        "gml:name").getFirstChild().getNodeValue());
391:                assertEquals("3", getFirstElementByTagName(feature, "sf:foo")
392:                        .getFirstChild().getNodeValue());
393:
394:                location = getFirstElementByTagName(feature, "gml:location");
395:                pos = getFirstElementByTagName(location, "gml:pos");
396:
397:                assertEquals("3.0 3.0", pos.getFirstChild().getNodeValue());
398:            }
399:
400:            public void testInsertWithBoundedBy() throws Exception {
401:                String xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\" "
402:                        + " xmlns:wfs=\"http://www.opengis.net/wfs\" "
403:                        + " xmlns:gml=\"http://www.opengis.net/gml\" "
404:                        + " xmlns:cite=\"http://www.opengeospatial.org/cite\">"
405:                        + "<wfs:Insert>"
406:                        + " <cite:BasicPolygons>"
407:                        + " <gml:boundedBy>"
408:                        + "  <gml:Envelope>"
409:                        + "<gml:lowerCorner>-1.0 2.0</gml:lowerCorner>"
410:                        + "<gml:upperCorner>2.0 5.0</gml:upperCorner>"
411:                        + "  </gml:Envelope>"
412:                        + " </gml:boundedBy>"
413:                        + "  <cite:the_geom>"
414:                        + "    <gml:MultiPolygon>"
415:                        + "      <gml:polygonMember>"
416:                        + "         <gml:Polygon>"
417:                        + "<gml:exterior>"
418:                        + "<gml:LinearRing>"
419:                        + "<gml:posList>-1.0 5.0 2.0 5.0 2.0 2.0 -1.0 2.0 -1.0 5.0</gml:posList>"
420:                        + "</gml:LinearRing>"
421:                        + "</gml:exterior>"
422:                        + "         </gml:Polygon>"
423:                        + "      </gml:polygonMember>"
424:                        + "    </gml:MultiPolygon>"
425:                        + "  </cite:the_geom>"
426:                        + "  <cite:ID>foo</cite:ID>"
427:                        + " </cite:BasicPolygons>"
428:                        + "</wfs:Insert>" + "</wfs:Transaction>";
429:
430:                Document dom = postAsDOM("wfs", xml);
431:
432:                assertEquals("wfs:TransactionResponse", dom
433:                        .getDocumentElement().getNodeName());
434:
435:                assertEquals("1", getFirstElementByTagName(dom,
436:                        "wfs:totalInserted").getFirstChild().getNodeValue());
437:                assertTrue(dom.getElementsByTagName("ogc:FeatureId")
438:                        .getLength() > 0);
439:            }
440:
441:            public void testInsert2() throws Exception {
442:                String xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\" "
443:                        + " xmlns:wfs=\"http://www.opengis.net/wfs\" "
444:                        + " xmlns:gml=\"http://www.opengis.net/gml\" "
445:                        + " xmlns:cite=\"http://www.opengis.net/cite\">"
446:                        + "<wfs:Insert>"
447:                        + " <cite:RoadSegments>"
448:                        + "  <cite:the_geom>"
449:                        + "<gml:MultiLineString xmlns:gml=\"http://www.opengis.net/gml\""
450:                        + "    srsName=\"EPSG:4326\">"
451:                        + " <gml:lineStringMember>"
452:                        + "                  <gml:LineString>"
453:                        + "                   <gml:posList>4.2582 52.0643 4.2584 52.0648</gml:posList>"
454:                        + "                 </gml:LineString>"
455:                        + "               </gml:lineStringMember>"
456:                        + "             </gml:MultiLineString>"
457:                        + "  </cite:the_geom>"
458:                        + "  <cite:FID>foo</cite:FID>"
459:                        + "  <cite:NAME>bar</cite:NAME>"
460:                        + " </cite:RoadSegments>"
461:                        + "</wfs:Insert>"
462:                        + "</wfs:Transaction>";
463:
464:                Document dom = postAsDOM("wfs", xml);
465:                assertEquals("wfs:TransactionResponse", dom
466:                        .getDocumentElement().getNodeName());
467:
468:                assertEquals("1", getFirstElementByTagName(dom,
469:                        "wfs:totalInserted").getFirstChild().getNodeValue());
470:
471:                dom = getAsDOM("wfs?request=getfeature&typename=cite:RoadSegments&srsName=EPSG:4326&"
472:                        + "cql_filter=FID%3D'foo'");
473:                //        print(dom);
474:                assertEquals("wfs:FeatureCollection", dom.getDocumentElement()
475:                        .getNodeName());
476:
477:                assertEquals(1, dom.getElementsByTagName("cite:RoadSegments")
478:                        .getLength());
479:
480:                Element roadSegment = getFirstElementByTagName(dom,
481:                        "cite:RoadSegments");
482:                Element posList = getFirstElementByTagName(roadSegment,
483:                        "gml:posList");
484:                assertEquals("4.2582 52.0643 4.2584 52.0648", posList
485:                        .getFirstChild().getNodeValue());
486:            }
487:
488:            public void testUpdateForcedSRS() throws Exception {
489:                testUpdate("srsName=\"EPSG:4326\"");
490:            }
491:
492:            public void testUpdateNoSRS() throws Exception {
493:                testUpdate("");
494:            }
495:
496:            private void testUpdate(String srs) throws Exception {
497:                String xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\""
498:                        + " xmlns:cite=\"http://www.opengis.net/cite\""
499:                        + " xmlns:ogc=\"http://www.opengis.net/ogc\""
500:                        + " xmlns:gml=\"http://www.opengis.net/gml\""
501:                        + " xmlns:wfs=\"http://www.opengis.net/wfs\">"
502:                        + " <wfs:Update typeName=\"cite:RoadSegments\">"
503:                        + "   <wfs:Property>"
504:                        + "     <wfs:Name>cite:the_geom</wfs:Name>"
505:                        + "     <wfs:Value>"
506:                        + "      <gml:MultiLineString xmlns:gml=\"http://www.opengis.net/gml\" "
507:                        + srs
508:                        + ">"
509:                        + "       <gml:lineStringMember>"
510:                        + "         <gml:LineString>"
511:                        + "            <gml:posList>4.2582 52.0643 4.2584 52.0648</gml:posList>"
512:                        + "         </gml:LineString>"
513:                        + "       </gml:lineStringMember>"
514:                        + "      </gml:MultiLineString>"
515:                        + "     </wfs:Value>"
516:                        + "   </wfs:Property>"
517:                        + "   <ogc:Filter>"
518:                        + "     <ogc:PropertyIsEqualTo>"
519:                        + "       <ogc:PropertyName>FID</ogc:PropertyName>"
520:                        + "       <ogc:Literal>102</ogc:Literal>"
521:                        + "     </ogc:PropertyIsEqualTo>"
522:                        + "   </ogc:Filter>"
523:                        + " </wfs:Update>" + "</wfs:Transaction>";
524:
525:                Document dom = postAsDOM("wfs", xml);
526:                assertEquals("wfs:TransactionResponse", dom
527:                        .getDocumentElement().getNodeName());
528:
529:                assertEquals("1", getFirstElementByTagName(dom,
530:                        "wfs:totalUpdated").getFirstChild().getNodeValue());
531:
532:                String srsBlock = "".equals(srs) ? "" : "&"
533:                        + srs.replaceAll("\"", "");
534:                dom = getAsDOM("wfs?request=getfeature&typename=cite:RoadSegments"
535:                        + srsBlock + "&" + "cql_filter=FID%3D'102'");
536:                assertEquals("wfs:FeatureCollection", dom.getDocumentElement()
537:                        .getNodeName());
538:
539:                assertEquals(1, dom.getElementsByTagName("cite:RoadSegments")
540:                        .getLength());
541:
542:                Element roadSegment = getFirstElementByTagName(dom,
543:                        "cite:RoadSegments");
544:                Element posList = getFirstElementByTagName(roadSegment,
545:                        "gml:posList");
546:                assertEquals("4.2582 52.0643 4.2584 52.0648", posList
547:                        .getFirstChild().getNodeValue());
548:            }
549:
550:            public void testUpdateWithInvalidProperty() throws Exception {
551:                String xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\""
552:                        + " xmlns:cite=\"http://www.opengis.net/cite\""
553:                        + " xmlns:ogc=\"http://www.opengis.net/ogc\""
554:                        + " xmlns:gml=\"http://www.opengis.net/gml\""
555:                        + " xmlns:wfs=\"http://www.opengis.net/wfs\">"
556:                        + " <wfs:Update typeName=\"cite:RoadSegments\">"
557:                        + "   <wfs:Property>"
558:                        + "     <wfs:Name>INVALID</wfs:Name>"
559:                        + "     <wfs:Value>INVALID</wfs:Value>"
560:                        + "   </wfs:Property>"
561:                        + "   <ogc:Filter>"
562:                        + "     <ogc:PropertyIsEqualTo>"
563:                        + "       <ogc:PropertyName>FID</ogc:PropertyName>"
564:                        + "       <ogc:Literal>102</ogc:Literal>"
565:                        + "     </ogc:PropertyIsEqualTo>"
566:                        + "   </ogc:Filter>"
567:                        + " </wfs:Update>" + "</wfs:Transaction>";
568:
569:                Document dom = postAsDOM("wfs", xml);
570:                assertEquals("ows:ExceptionReport", dom.getDocumentElement()
571:                        .getNodeName());
572:
573:            }
574:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.