add formats for CSW GetRecords and GetDomain requests, p=bbinet, r=me (closes #2132)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9699 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
81
tests/Format/CSWGetRecords/v2_0_2.html
Normal file
81
tests/Format/CSWGetRecords/v2_0_2.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../../lib/OpenLayers.js"></script>
|
||||
<script src="v2_0_2.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var format = new OpenLayers.Format.CSWGetRecords();
|
||||
|
||||
function test_write(t) {
|
||||
|
||||
t.plan(1);
|
||||
|
||||
var filter = new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.LIKE,
|
||||
property: "my_prop",
|
||||
value: "my_prop_value"
|
||||
});
|
||||
|
||||
var options = {
|
||||
"resultType": "results",
|
||||
"startPosition": "10",
|
||||
"maxRecords": "20",
|
||||
"Query": {
|
||||
"ElementSetName": {
|
||||
"value": "brief"
|
||||
},
|
||||
"Constraint": {
|
||||
"version": "1.1.0",
|
||||
"Filter": filter
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = format.write(options);
|
||||
|
||||
t.eq(result, csw_request, "check value returned by format " +
|
||||
"CSWGetRecords: write method");
|
||||
|
||||
}
|
||||
|
||||
|
||||
function test_read(t) {
|
||||
|
||||
t.plan(14);
|
||||
|
||||
var obj = format.read(csw_response);
|
||||
|
||||
var searchStatus = obj.SearchStatus;
|
||||
var searchResults = obj.SearchResults;
|
||||
var records = obj.records;
|
||||
// test getRecordsResponse object
|
||||
t.ok(searchStatus, "object contains SearchStatus property");
|
||||
t.ok(searchResults, "object contains SearchResults property");
|
||||
t.ok(records, "object contains records property");
|
||||
|
||||
// test SearchResults attributes
|
||||
t.eq(searchResults.numberOfRecordsMatched, 10, "check value for SearchResults.numberOfRecordsMatched");
|
||||
t.eq(searchResults.numberOfRecordsReturned, 2, "check value for SearchResults.numberOfRecordsReturned");
|
||||
t.eq(searchResults.elementSet, "brief", "check value for SearchResults.elementSet");
|
||||
t.eq(searchResults.nextRecord, 3, "check value for SearchResults.nextRecord");
|
||||
|
||||
// test records
|
||||
t.eq(records.length, 2, "object contains 10 records");
|
||||
var testRecord = records[0];
|
||||
t.eq(testRecord.type, "BriefRecord", "check value for record.type");
|
||||
t.eq(testRecord.title, [{value:"Sample title"}], "check value for record.title");
|
||||
|
||||
//test bbox
|
||||
t.eq(testRecord.BoundingBox.length, 1, "object contains 1 BoundingBox");
|
||||
var bbox = testRecord.BoundingBox[0];
|
||||
t.ok(bbox, "object contains BoundingBox properties");
|
||||
t.eq(bbox.crs, "::Lambert Azimuthal Projection", "check value for BoundingBox.crs");
|
||||
t.eq(bbox.value, [156, -3, 37, 83], "check value for record.BoundingBox");
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
40
tests/Format/CSWGetRecords/v2_0_2.js
Normal file
40
tests/Format/CSWGetRecords/v2_0_2.js
Normal file
@@ -0,0 +1,40 @@
|
||||
var csw_request =
|
||||
'<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" service="CSW" version="2.0.2" resultType="results" startPosition="10" maxRecords="20">' +
|
||||
'<csw:Query typeNames="csw:Record">' +
|
||||
'<csw:ElementSetName>brief</csw:ElementSetName>' +
|
||||
'<csw:Constraint version="1.1.0">' +
|
||||
'<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
|
||||
'<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">' +
|
||||
'<ogc:PropertyName>my_prop</ogc:PropertyName>' +
|
||||
'<ogc:Literal>my_prop_value</ogc:Literal>' +
|
||||
'</ogc:PropertyIsLike>' +
|
||||
'</ogc:Filter>' +
|
||||
'</csw:Constraint>' +
|
||||
'</csw:Query>' +
|
||||
'</csw:GetRecords>';
|
||||
|
||||
var csw_response =
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<csw:GetRecordsResponse xmlns:csw="http://www.opengis.net/cat/csw/2.0.2">' +
|
||||
'<csw:SearchStatus timestamp="2009-06-08T12:03:34" />' +
|
||||
'<csw:SearchResults numberOfRecordsMatched="10" numberOfRecordsReturned="2" elementSet="brief" nextRecord="3">' +
|
||||
'<csw:BriefRecord xmlns:geonet="http://www.fao.org/geonetwork" xmlns:ows="http://www.opengis.net/ows" xmlns:dc="http://purl.org/dc/elements/1.1/">' +
|
||||
'<dc:identifier>895ac38b-7aef-4a21-b593-b35a6fc7bba9</dc:identifier>' +
|
||||
'<dc:title>Sample title</dc:title>' +
|
||||
'<ows:BoundingBox crs="::Lambert Azimuthal Projection">' +
|
||||
'<ows:LowerCorner>156 -3</ows:LowerCorner>' +
|
||||
'<ows:UpperCorner>37 83</ows:UpperCorner>' +
|
||||
'</ows:BoundingBox>' +
|
||||
'</csw:BriefRecord>' +
|
||||
'<csw:BriefRecord xmlns:geonet="http://www.fao.org/geonetwork" xmlns:ows="http://www.opengis.net/ows" xmlns:dc="http://purl.org/dc/elements/1.1/">' +
|
||||
'<dc:identifier>8a7245c3-8546-42de-8e6f-8fb8b5fd1bc3</dc:identifier>' +
|
||||
'<dc:title>Second record : sample title</dc:title>' +
|
||||
'<ows:BoundingBox crs="::WGS 1984">' +
|
||||
'<ows:LowerCorner>51.1 -34.6</ows:LowerCorner>' +
|
||||
'<ows:UpperCorner>-17.3 38.2</ows:UpperCorner>' +
|
||||
'</ows:BoundingBox>' +
|
||||
'</csw:BriefRecord>' +
|
||||
'</csw:SearchResults>' +
|
||||
'</csw:GetRecordsResponse>'
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user