diff options
author | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
commit | ea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch) | |
tree | af67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/tests/WPSClient.html | |
parent | 59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff) | |
download | postrunner-fb1989bda5d3e0a5472ba7644d57cae197733a8f.zip |
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/tests/WPSClient.html')
-rw-r--r-- | misc/openlayers/tests/WPSClient.html | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/misc/openlayers/tests/WPSClient.html b/misc/openlayers/tests/WPSClient.html new file mode 100644 index 0000000..34b21f9 --- /dev/null +++ b/misc/openlayers/tests/WPSClient.html @@ -0,0 +1,108 @@ +<html> +<head> + <script src="OLLoader.js"></script> + <script type="text/javascript"> + + var client; + + function test_initialize(t) { + t.plan(3); + + client = new OpenLayers.WPSClient({ + servers: { + local: "/geoserver/wps" + } + }); + + t.ok(client instanceof OpenLayers.WPSClient, 'creates an instance'); + t.ok(client.events, 'has an events instance'); + t.eq(client.servers.local.url, '/geoserver/wps', 'servers stored on instance'); + } + + function test_getProcess(t) { + t.plan(4); + + client = new OpenLayers.WPSClient({ + servers: { + local: "/geoserver/wps" + }, + lazy: true + }); + + var process = client.getProcess('local', 'gs:splitPolygon'); + t.ok(process instanceof OpenLayers.WPSProcess, 'creates a process'); + t.ok(process.client === client, 'process knows about client'); + t.eq(process.server, 'local', 'process created with correct server'); + t.eq(process.identifier, 'gs:splitPolygon', 'process created with correct identifier'); + + } + + function test_describeProcess(t) { + t.plan(6); + var log = {request: [], event: []}; + var originalGET = OpenLayers.Request.GET; + OpenLayers.Request.GET = function(cfg) { + log.request.push(cfg); + } + function describe(evt) { + log.event.push(evt); + } + client.events.register('describeprocess', this, describe); + + process = client.getProcess('local', 'gs:splitPolygon'); + t.eq(client.servers.local.processDescription['gs:splitPolyon'], null, 'describeProcess pending'); + process.describe(); + t.eq(log.request.length, 1, 'describeProcess request only sent once'); + log.request[0].success.call(client, { + responseText: '<?xml version="1.0" encoding="UTF-8"?><wps:ProcessDescriptions xmlns:wps="http://www.opengis.net/wps/1.0.0"></wps:ProcessDescriptions>' + }); + t.eq(log.event[0].type, 'describeprocess', 'describeprocess event triggered'); + t.ok(client.servers.local.processDescription['gs:splitPolygon'], 'We have a process description!'); + process.describe(); + t.eq(log.request.length, 1, 'describeProcess request only sent once'); + t.eq(log.event.length, 1, 'describeprocess event only triggered once'); + + OpenLayers.Request.GET = originalGET; + client.events.unregister('describeprocess', this, describe); + } + + function test_execute(t) { + t.plan(1); + + client = new OpenLayers.WPSClient({ + servers: { + local: "/geoserver/wps" + }, + lazy: true + }); + var log = []; + client.getProcess = function() { + return { + execute: function(options) { + log.push(options); + } + } + } + + client.execute({inputs: 'a', success: 'b', scope: 'c'}); + t.eq(log[0], {inputs: 'a', success: 'b', scope: 'c'}, "process executed with correct options"); + } + + function test_destroy(t) { + t.plan(2); + client = new OpenLayers.WPSClient({ + servers: { + local: "/geoserver/wps" + }, + lazy: true + }); + client.destroy(); + t.eq(client.events, null, "Events nullified"); + t.eq(client.servers, null, "Servers nullified"); + } + + </script> +</head> +<body> +</body> +</html> |