~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/openlayers/tests/Format/Filter/v1_0_0.html

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html> 
 
2
<head> 
 
3
    <script src="../../../lib/OpenLayers.js"></script>
 
4
    <script type="text/javascript">
 
5
    
 
6
    var test_xml =
 
7
        '<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
 
8
            '<ogc:Or>' +
 
9
                '<ogc:PropertyIsBetween>' +
 
10
                    '<ogc:PropertyName>number</ogc:PropertyName>' +
 
11
                    '<ogc:LowerBoundary>' +
 
12
                        '<ogc:Literal>1064866676</ogc:Literal>' +
 
13
                    '</ogc:LowerBoundary>' +
 
14
                    '<ogc:UpperBoundary>' +
 
15
                        '<ogc:Literal>1065512599</ogc:Literal>' +
 
16
                    '</ogc:UpperBoundary>' +
 
17
                '</ogc:PropertyIsBetween>' +
 
18
                '<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">' +
 
19
                    '<ogc:PropertyName>cat</ogc:PropertyName>' +
 
20
                    '<ogc:Literal>*dog.food!*good</ogc:Literal>' +
 
21
                '</ogc:PropertyIsLike>' +
 
22
                '<ogc:Not>' +
 
23
                    '<ogc:PropertyIsLessThanOrEqualTo>' +
 
24
                        '<ogc:PropertyName>FOO</ogc:PropertyName>' +
 
25
                        '<ogc:Literal>5000</ogc:Literal>' +
 
26
                    '</ogc:PropertyIsLessThanOrEqualTo>' +
 
27
                '</ogc:Not>' +
 
28
            '</ogc:Or>' +
 
29
        '</ogc:Filter>';
 
30
 
 
31
    function test_read(t) {
 
32
        t.plan(3);
 
33
 
 
34
        var parser = new OpenLayers.Format.Filter.v1_0_0();
 
35
        var xml = new OpenLayers.Format.XML();
 
36
        var filter = parser.read(xml.read(test_xml).documentElement);
 
37
 
 
38
        t.ok(filter instanceof OpenLayers.Filter.Logical, "instance of correct class");
 
39
        t.eq(filter.type, OpenLayers.Filter.Logical.OR, "correct type");
 
40
        t.eq(filter.filters.length, 3, "correct number of child filters");
 
41
    }
 
42
    
 
43
    function test_write(t) {
 
44
        t.plan(1);
 
45
 
 
46
        // read first - testing that write produces the ogc:Filter element above
 
47
        var parser = new OpenLayers.Format.Filter.v1_0_0();
 
48
        var xml = new OpenLayers.Format.XML();
 
49
        var filter = parser.read(xml.read(test_xml).documentElement);
 
50
        
 
51
        var node = parser.write(filter);
 
52
        t.xml_eq(node, test_xml, "filter correctly written");
 
53
        
 
54
    }
 
55
    
 
56
 
 
57
    </script> 
 
58
</head> 
 
59
<body>
 
60
</body> 
 
61
</html>