source: branches/geomap/gui/test/geomapdataproviderwfs.test

Last change on this file was 5949, checked in by dkearney, 9 years ago

adding data provider and layer objects, updating mapviewer to remove layers from client and server.

File size: 8.0 KB
Line 
1# Commands covered:
2#   Rappture::GeoMapDataProviderWFS
3#
4# This file contains a collection of tests for one of the Rappture Tcl
5# commands.  Sourcing this file into Tcl runs the tests and
6# generates output for errors.  No output means no errors were found.
7#
8# ======================================================================
9# AUTHOR:  Derrick Kearney, Purdue University
10# Copyright (c) 2004-2015  HUBzero Foundation, LLC
11#
12# See the file "license.terms" for information on usage and redistribution
13# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14
15
16if {[lsearch [namespace children] ::tcltest] == -1} {
17    package require tcltest
18    package require RapptureGUI
19    namespace import -force ::tcltest::*
20}
21catch {unset lib}
22
23proc check {var size} {
24    set l [llength $var]
25    if {$l != $size} {
26        return "length mismatch: should have been $size, was $l"
27    }
28    for {set i 0} {$i < $size} {set i [expr $i+1]} {
29        set j [lindex $var $i]
30        if {$j != "item $i"} {
31            return "element $i should have been \"item $i\", was \"$j\""
32        }
33    }
34    return ok
35}
36
37# temporary class for testing protected methods
38itcl::class TestDataProviderWFS {
39    inherit Rappture::GeoMapDataProviderWFS
40
41    constructor {type url typename format args} {
42        Rappture::GeoMapDataProviderWFS::constructor $type $url $typename $format
43    } {
44        eval configure $args
45    }
46    destructor {
47        # empty
48    }
49    public method do { args } {eval $args}
50}
51
52#----------------------------------------------------------
53#----------------------------------------------------------
54# constructor command
55# Rappture::GeoMapDataProviderWFS <name> <type> <url> <typename> <format>
56#----------------------------------------------------------
57test geomapdataproviderwfs-1.1 {Rappture::GeoMapDataProviderWFS, 0 arguments} {
58    list [catch {Rappture::GeoMapDataProviderWFS} msg] $msg
59} {0 {}}
60
61
62test geomapdataproviderwfs-1.2 {Rappture::GeoMapDataProviderWFS, 1 arguments} {
63    list [catch {Rappture::GeoMapDataProviderWFS name "line"} msg] $msg
64} {1 {wrong # args: should be "::Rappture::GeoMapDataProviderWFS name type url typename format ?arg arg ...?"}}
65
66
67test geomapdataproviderwfs-1.3 {Rappture::GeoMapDataProviderWFS, 2 arguments} {
68    list [catch {Rappture::GeoMapDataProviderWFS name "line" "http://myurl.com/"} msg] $msg
69} {1 {wrong # args: should be "::Rappture::GeoMapDataProviderWFS name type url typename format ?arg arg ...?"}}
70
71
72test geomapdataproviderwfs-1.4 {Rappture::GeoMapDataProviderWFS, 2 arguments} {
73    list [catch {Rappture::GeoMapDataProviderWFS name "line" "http://myurl.com/" "ns:fn"} msg] $msg
74} {1 {wrong # args: should be "::Rappture::GeoMapDataProviderWFS name type url typename format ?arg arg ...?"}}
75
76
77test geomapdataproviderwfs-1.5 {
78    Rappture::GeoMapDataProviderWFS, name type url typename format
79} -body {
80    list [catch {Rappture::GeoMapDataProviderWFS name "line" "http://myurl.com/" "ns:fn" "json"} msg] $msg
81} -cleanup {
82    catch {itcl::delete object name} err
83} -result {0 name}
84
85
86#----------------------------------------------------------
87# Type command
88# $dp Type
89# $dp Type <type>
90#----------------------------------------------------------
91test geomapdataproviderwfs-2.1 {Type, 0 arguments} {
92    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
93    list [catch {$dp do Type} msg] $msg
94} {0 line}
95
96test geomapdataproviderwfs-2.2 {Type, set type to "icon"} {
97    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
98    list [catch {$dp do Type "icon"} msg] $msg
99} {0 icon}
100
101test geomapdataproviderwfs-2.3 {Type, set type to "line"} {
102    set dp [TestDataProviderWFS #auto "icon" {http://myurl.com/} "ns:fs" "json"]
103    list [catch {$dp do Type "line"} msg] $msg
104} {0 line}
105
106test geomapdataproviderwfs-2.4 {Type, set type to "point"} {
107    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
108    list [catch {$dp do Type "point"} msg] $msg
109} {0 point}
110
111test geomapdataproviderwfs-2.5 {Type, set type to "polygon"} {
112    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
113    list [catch {$dp do Type "polygon"} msg] $msg
114} {0 polygon}
115
116test geomapdataproviderwfs-2.6 {Type, set type to "text"} {
117    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
118    list [catch {$dp do Type "text"} msg] $msg
119} {0 text}
120
121test geomapdataproviderwfs-2.7 {Type, set type to "image"} {
122    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
123    list [catch {$dp do Type "image"} msg] $msg
124} {1 {bad value "image": should be one of "icon line point polygon text"}}
125
126test geomapdataproviderwfs-2.8 {Type, set type to "elevation"} {
127    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
128    list [catch {$dp do Type "elevation"} msg] $msg
129} {1 {bad value "elevation": should be one of "icon line point polygon text"}}
130
131test geomapdataproviderwfs-2.9 {Type, set type to "feature"} {
132    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
133    list [catch {$dp do Type "feature"} msg] $msg
134} {1 {bad value "feature": should be one of "icon line point polygon text"}}
135
136test geomapdataproviderwfs-2.10 {Type, set type to "badname"} {
137    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
138    list [catch {$dp do Type "badname"} msg] $msg
139} {1 {bad value "badname": should be one of "icon line point polygon text"}}
140
141test geomapdataproviderwfs-2.11 {Type, set type to ""} {
142    set dp [TestDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
143    list [catch {$dp do Type ""} msg] $msg
144} {1 {bad value "": should be a non-empty string}}
145
146test geomapdataproviderwfs-2.12 {Type, set type to "line" and retrieve type} {
147    set dp [TestDataProviderWFS #auto "icon" {http://myurl.com/} "ns:fs" "json"]
148    $dp do Type "line"
149    list [catch {$dp do Type} msg] $msg
150} {0 line}
151
152
153#----------------------------------------------------------
154# format command
155# $dp format
156# $dp format <name>
157#----------------------------------------------------------
158test geomapdataproviderwfs-3.1 {format, 0 arguments} {
159    set dp [Rappture::GeoMapDataProviderWFS #auto "line" "http://myurl.com/" "ns:fs" "json"]
160    list [catch {$dp format} msg] $msg
161} {0 json}
162
163test geomapdataproviderwfs-3.2 {format, 1 arguments} {
164    set dp [Rappture::GeoMapDataProviderWFS #auto "line" "http://myurl.com/" "ns:fs" "json"]
165    list [catch {$dp format "gml"} msg] $msg
166} {0 gml}
167
168test geomapdataproviderwfs-3.3 {format, empty string} {
169    set dp [Rappture::GeoMapDataProviderWFS #auto "line" "http://myurl.com/" "ns:fs" "json"]
170    list [catch {$dp format ""} msg] $msg
171} {1 {bad value "": should be a non-empty string}}
172
173
174#----------------------------------------------------------
175# typename command
176# $dp typename
177# $dp typename <name>
178#----------------------------------------------------------
179test geomapdataproviderwfs-4.1 {typename, 0 arguments} {
180    set dp [Rappture::GeoMapDataProviderWFS #auto "line" "http://myurl.com/" "ns:fs" "json"]
181    list [catch {$dp typename} msg] $msg
182} {0 ns:fs}
183
184test geomapdataproviderwfs-4.2 {typename, 1 arguments} {
185    set dp [Rappture::GeoMapDataProviderWFS #auto "line" "http://myurl.com/" "ns:fs" "json"]
186    list [catch {$dp typename "ns1:fs1"} msg] $msg
187} {0 ns1:fs1}
188
189test geomapdataproviderwfs-4.3 {typename, empty string} {
190    set dp [Rappture::GeoMapDataProviderWFS #auto "line" "http://myurl.com/" "ns:fs" "json"]
191    list [catch {$dp typename ""} msg] $msg
192} {1 {bad value "": should be a non-empty string}}
193
194
195#----------------------------------------------------------
196# exportToBltTree
197# $dp exportToBltTree $tree
198#----------------------------------------------------------
199
200test geomapdataproviderwfs-3.1 {exportToBltTree, } {
201    set dp [Rappture::GeoMapDataProviderWFS #auto "line" {http://myurl.com/} "ns:fs" "json"]
202    set tree [blt::tree create]
203    $dp exportToBltTree $tree
204    $tree dump root
205} {-1 0 ::tree0 {type line driver wfs cache true attribution {} wfs.url http://myurl.com/ wfs.typename ns:fs wfs.format json} {}
206}
207
208
209# TODO:
210
211::tcltest::cleanupTests
212return
Note: See TracBrowser for help on using the repository browser.