]> dev.renevier.net Git - syp.git/blob - openlayers/tests/Format/WFST/v1_0_0.html
initial commit
[syp.git] / openlayers / tests / Format / WFST / v1_0_0.html
1 <html>
2 <head>
3   <script src="../../../lib/OpenLayers.js"></script>
4   <script type="text/javascript">
5
6     function test_initialize(t) {
7         t.plan(1);
8
9         var format = new OpenLayers.Format.WFST.v1_0_0({});
10         t.ok(format instanceof OpenLayers.Format.WFST.v1_0_0, "constructor returns instance");
11     }
12     
13     function test_read(t) {
14         t.plan(2);
15         
16         var data = readXML("Transaction_Response");        
17         var format = new OpenLayers.Format.WFST.v1_0_0({
18             featureNS: "http://www.openplans.org/topp",
19             featureType: "states"
20         });
21         var result = format.read(data);
22         t.eq(result.insertIds[0], "none", "InsertIds read correctly");
23         t.eq(result.success, true, "Success read correctly");
24     }
25     
26     function test_write(t) {
27
28         var format = new OpenLayers.Format.WFST.v1_0_0({
29             featureNS: "http://www.openplans.org/topp",
30             featureType: "states",
31             featurePrefix: "topp",
32             geometryName: "the_geom"
33         });
34
35         var cases = [{
36             id: "query0",
37             writer: "wfs:Query",
38             arg: {
39                 filter: new OpenLayers.Filter.Spatial({
40                     type: OpenLayers.Filter.Spatial.BBOX,
41                     value: new OpenLayers.Bounds (1,2,3,4)
42                 })
43             }
44         }, {
45             id: "getfeature0",
46             writer: "wfs:GetFeature",
47             arg: {
48                 propertyNames: ["STATE_NAME", "STATE_FIPS", "STATE_ABBR"]
49             }
50         }];
51         
52         t.plan(cases.length);
53         
54         var test, got, exp;
55         for(var i=0; i<cases.length; ++i) {
56             test = cases[i];
57             exp = readXML(test.id);
58             got = format.writeNode(test.writer, test.arg);
59             t.xml_eq(got, exp, test.id + ": correct request");
60         }
61
62     }
63
64     var xmlFormat = new OpenLayers.Format.XML();
65     function readXML(id) {
66         var xml = document.getElementById(id).firstChild.nodeValue;
67         return xmlFormat.read(xml).documentElement;        
68     }
69
70   </script>
71 </head>
72 <body>
73 <div id="Transaction_Response"><!--
74 <wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc">
75     <wfs:InsertResult>
76         <ogc:FeatureId fid="none"/>
77     </wfs:InsertResult>
78     <wfs:TransactionResult>
79         <wfs:Status>
80             <wfs:SUCCESS/>
81         </wfs:Status>
82     </wfs:TransactionResult>
83 </wfs:WFS_TransactionResponse>
84 --></div>
85 <div id="query0"><!--
86 <wfs:Query xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
87     <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
88         <ogc:BBOX>
89             <ogc:PropertyName>the_geom</ogc:PropertyName>
90             <gml:Box xmlns:gml="http://www.opengis.net/gml">
91                 <gml:coordinates decimal="." cs="," ts=" ">1,2 3,4</gml:coordinates>
92             </gml:Box>
93         </ogc:BBOX>
94     </ogc:Filter>
95 </wfs:Query>
96 --></div>
97 <div id="getfeature0"><!--
98 <wfs:GetFeature service="WFS" version="1.0.0" xmlns:topp="http://www.openplans.org/topp"
99                 xmlns:wfs="http://www.opengis.net/wfs"
100                 xmlns:ogc="http://www.opengis.net/ogc"
101                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
102                 xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">
103     <wfs:Query xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
104         <ogc:PropertyName>STATE_NAME</ogc:PropertyName>
105         <ogc:PropertyName>STATE_FIPS</ogc:PropertyName>
106         <ogc:PropertyName>STATE_ABBR</ogc:PropertyName>
107     </wfs:Query>
108 </wfs:GetFeature>
109 --></div>
110 </body>
111 </html>