The WMSDescribeLayer format currently differs from other formats that inhreit from VersionedOGC by having an array instead of an object as return type. This especially bad since the VersionedOGC superclass sets a version property on the array. With this change, the WMSDescribeLayer format will also be compatible with GeoServer's new JSON response type for DescribeLayer - see http://sourceforge.net/mailarchive/message.php?msg_id=29912776. Another change included here is the removal of the WMSDescribeLayer format's getVersion hack, which was replaced by a generic fallback to less generic parsers, e.g. from a v1_1_1 parser to a v1_1 parser if v1_1_1 is not implemented.
54 lines
1.9 KiB
HTML
54 lines
1.9 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../OLLoader.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
function test_read_WMSDescribeLayer(t) {
|
|
t.plan(5);
|
|
|
|
var parser = new OpenLayers.Format.WMSDescribeLayer();
|
|
|
|
var text =
|
|
'<WMS_DescribeLayerResponse version="1.1.1">' +
|
|
' <LayerDescription name="topp:states" wfs="http://geo.openplans.org:80/geoserver/wfs/WfsDispatcher?">' +
|
|
' <Query typeName="topp:states"/>' +
|
|
' </LayerDescription>' +
|
|
'</WMS_DescribeLayerResponse>';
|
|
|
|
var res = parser.read(text);
|
|
|
|
t.eq(res.layerDescriptions.length, 1,
|
|
"Only one LayerDescription in data, so only one parsed");
|
|
|
|
t.eq(res.layerDescriptions[0].owsType, "WFS",
|
|
"Properly parses owsType as WFS");
|
|
|
|
t.eq(res.layerDescriptions[0].owsURL, "http://geo.openplans.org:80/geoserver/wfs/WfsDispatcher?",
|
|
"Properly parses owsURL");
|
|
|
|
t.eq(res.layerDescriptions[0].typeName, "topp:states",
|
|
"Properly parses typeName");
|
|
|
|
t.eq(res.layerDescriptions[0].layerName, "topp:states",
|
|
"Properly parses name");
|
|
|
|
}
|
|
|
|
function test_read_exception(t) {
|
|
t.plan(1);
|
|
var text = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' +
|
|
'<!DOCTYPE ServiceExceptionReport SYSTEM "http://mapstory.dev.opengeo.org:80/geoserver/schemas/wms/1.1.1/WMS_exception_1_1_1.dtd">' +
|
|
'<ServiceExceptionReport version="1.1.1" > <ServiceException code="LayerNotDefined" locator="MapLayerInfoKvpParser">' +
|
|
'geonode:_map_107_annotations: no such layer on this server' +
|
|
'</ServiceException></ServiceExceptionReport>';
|
|
var format = new OpenLayers.Format.WMSDescribeLayer();
|
|
var obj = format.read(text);
|
|
t.ok(!!obj.error, "Error reported correctly");
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html>
|