minor doc adjustments and a bit more test coverage

This commit is contained in:
Bart van den Eijnden
2012-01-09 10:27:44 +01:00
parent ab49a195e3
commit 476d438578
3 changed files with 13 additions and 18 deletions
+1 -4
View File
@@ -9,10 +9,7 @@
/** /**
* Class: OpenLayers.Protocol.CSW * Class: OpenLayers.Protocol.CSW
* Used to create a versioned CSW protocol. Default version is 2.0.2. * Used to create a versioned CSW protocol. Default version is 2.0.2.
*
* Inherits from:
* - <OpenLayers.Protocol>
*/ */
OpenLayers.Protocol.CSW = function(options) { OpenLayers.Protocol.CSW = function(options) {
options = OpenLayers.Util.applyDefaults( options = OpenLayers.Util.applyDefaults(
+6 -12
View File
@@ -5,11 +5,12 @@
/** /**
* @requires OpenLayers/Protocol/CSW.js * @requires OpenLayers/Protocol/CSW.js
* @requires OpenLayers/Format/CSWGetRecords/v2_0_2.js
*/ */
/** /**
* Class: OpenLayers.Protocol.CSW.v2_0_2 * Class: OpenLayers.Protocol.CSW.v2_0_2
* Abstract class for for v2_0_2 protocol. * CS-W (Catalogue services for the Web) version 2.0.2 protocol.
* *
* Inherits from: * Inherits from:
* - <OpenLayers.Protocol> * - <OpenLayers.Protocol>
@@ -24,8 +25,8 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
formatOptions: null, formatOptions: null,
/** /**
* Constructor: OpenLayers.Protocol.CSW * Constructor: OpenLayers.Protocol.CSW.v2_0_2
* A class for CSW protocol management. * A class for CSW version 2.0.2 protocol management.
* *
* Parameters: * Parameters:
* options - {Object} Optional object whose properties will be set on the * options - {Object} Optional object whose properties will be set on the
@@ -34,7 +35,6 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
initialize: function(options) { initialize: function(options) {
OpenLayers.Protocol.prototype.initialize.apply(this, [options]); OpenLayers.Protocol.prototype.initialize.apply(this, [options]);
if(!options.format) { if(!options.format) {
/* not tested */
this.format = new OpenLayers.Format.CSWGetRecords.v2_0_2(OpenLayers.Util.extend({ this.format = new OpenLayers.Format.CSWGetRecords.v2_0_2(OpenLayers.Util.extend({
}, this.formatOptions)); }, this.formatOptions));
} }
@@ -71,11 +71,7 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
/** /**
* Method: read * Method: read
* Construct a request for reading new features. Since WFS splits the * Construct a request for reading new records from the Catalogue.
* basic CRUD operations into GetFeature requests (for read) and
* Transactions (for all others), this method does not make use of the
* format's read method (that is only about reading transaction
* responses).
*/ */
read: function(options) { read: function(options) {
options = OpenLayers.Util.extend({}, options); options = OpenLayers.Util.extend({}, options);
@@ -102,7 +98,7 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
* Parameters: * Parameters:
* response - {<OpenLayers.Protocol.Response>} The response object to pass * response - {<OpenLayers.Protocol.Response>} The response object to pass
* to the user callback. * to the user callback.
* This response is given a code property, and optionally a records one. * This response is given a code property, and optionally a data property.
* The latter represents the CSW records as returned by the call to * The latter represents the CSW records as returned by the call to
* the CSW format read method. * the CSW format read method.
* options - {Object} The user options passed to the read call. * options - {Object} The user options passed to the read call.
@@ -118,7 +114,6 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
// failure // failure
response.code = OpenLayers.Protocol.Response.FAILURE; response.code = OpenLayers.Protocol.Response.FAILURE;
} }
options.callback.call(options.scope, response); options.callback.call(options.scope, response);
} }
}, },
@@ -141,7 +136,6 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, {
if(!doc || doc.length <= 0) { if(!doc || doc.length <= 0) {
return null; return null;
} }
return this.format.read(doc); return this.format.read(doc);
}, },
+6 -2
View File
@@ -4,11 +4,15 @@
<script type="text/javascript"> <script type="text/javascript">
function test_initialize(t) { function test_initialize(t) {
t.plan(1); t.plan(3);
var protocol = new OpenLayers.Protocol.CSW({}); var protocol = new OpenLayers.Protocol.CSW({formatOptions: {foo: "bar"},});
t.ok(protocol instanceof OpenLayers.Protocol.CSW.v2_0_2, t.ok(protocol instanceof OpenLayers.Protocol.CSW.v2_0_2,
"initialize returns instance of default versioned protocol"); "initialize returns instance of default versioned protocol");
var format = protocol.format;
t.ok(format instanceof OpenLayers.Format.CSWGetRecords.v2_0_2, "Default format created");
t.ok(format.foo, "bar", "formatOptions set correctly");
protocol.destroy();
} }
function test_read(t) { function test_read(t) {