]> dev.renevier.net Git - syp.git/blob - openlayers/tests/Format/WFST/v1_1_0.html
initial commit
[syp.git] / openlayers / tests / Format / WFST / v1_1_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_1_0({});
10         t.ok(format instanceof OpenLayers.Format.WFST.v1_1_0, "constructor returns instance");
11     }
12     
13     function test_read(t) {
14         t.plan(2);
15         
16         var data = readXML("TransactionResponse");        
17         var format = new OpenLayers.Format.WFST.v1_1_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_1_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     var xmlFormat = new OpenLayers.Format.XML();
64     function readXML(id) {
65         var xml = document.getElementById(id).firstChild.nodeValue;
66         return xmlFormat.read(xml).documentElement;        
67     }
68
69   </script>
70 </head>
71 <body>
72 <div id="map" style="width:512px; height:256px"> </div>
73 <div id="TransactionResponse"><!--
74 <wfs:TransactionResponse version="1.1.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:tiger="http://www.census.gov" xmlns:wfs="http://www.opengis.net/wfs" xmlns:topp="http://www.openplans.org/topp" xmlns:sf="http://www.openplans.org/spearfish" xmlns:ows="http://www.opengis.net/ows" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
75     <wfs:TransactionSummary>
76         <wfs:totalInserted>0</wfs:totalInserted>
77         <wfs:totalUpdated>1</wfs:totalUpdated>
78         <wfs:totalDeleted>0</wfs:totalDeleted>
79     </wfs:TransactionSummary>
80     <wfs:TransactionResults/>
81     <wfs:InsertResults>
82         <wfs:Feature>
83             <ogc:FeatureId fid="none"/>
84         </wfs:Feature>
85     </wfs:InsertResults>
86 </wfs:TransactionResponse>
87 --></div>
88 <div id="query0"><!--
89 <wfs:Query xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
90     <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
91         <ogc:BBOX>
92             <ogc:PropertyName>the_geom</ogc:PropertyName>
93             <gml:Envelope xmlns:gml="http://www.opengis.net/gml">
94                 <gml:lowerCorner>1 2</gml:lowerCorner>
95                 <gml:upperCorner>3 4</gml:upperCorner>
96             </gml:Envelope>
97         </ogc:BBOX>
98     </ogc:Filter>
99 </wfs:Query>
100 --></div>
101 <div id="getfeature0"><!--
102 <wfs:GetFeature service="WFS" version="1.1.0" xmlns:topp="http://www.openplans.org/topp"
103                 xmlns:wfs="http://www.opengis.net/wfs"
104                 xmlns:ogc="http://www.opengis.net/ogc"
105                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
106                 xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
107     <wfs:Query xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
108         <wfs:PropertyName>STATE_NAME</wfs:PropertyName>
109         <wfs:PropertyName>STATE_FIPS</wfs:PropertyName>
110         <wfs:PropertyName>STATE_ABBR</wfs:PropertyName>
111     </wfs:Query>
112 </wfs:GetFeature>
113 --></div>
114 </body>
115 </html>