1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
<html>
<head>
<script src="../../OLLoader.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(17);
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 empty subject
t.eq(testRecord.subject, [], "Empty subject tags are ignored");
//test bbox
t.eq(testRecord.BoundingBox.length, 2, "object contains 2 BoundingBoxes");
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");
// test gninfo
testRecord = records[1];
t.ok(testRecord.gninfo, "object contains gninfo properties");
t.eq(testRecord.gninfo.schema, "iso19139", "check value for schema property in record.gninfo");
}
</script>
</head>
<body>
</body>
</html>
|