Hi,
I believe I’ve spotted a couple of tests in WMS that are working by accident, and have
to do with the local catalog functionality.
The two tests are here:
https://github.com/geoserver/geoserver/blob/master/src/wms/src/test/java/org/geoserver/wms/wms_1_1_1/CapabilitiesTest.java#L140
In both cases we are working against a local workspace service, so layers should not be workspace qualified,
and indeed the output is not, but the XPath used is invalid and the tests pass just by accident:
assertTrue(xpath.getMatchingNodes(“//Layer/Name[starts-with(., cite:Forests)]”, dom)
.getLength() == 1);
The intention of the test as written would be to check that there is one layer named cite:Forests, there
are two issues:
- the xpath is invalid, it should be //Layer/Name[starts-with(., ‘cite:Forests’)] (strings are always between ’ ’ in xpath)
- once fixed, the result is 0, because we are in a workspace local service so the name is just Forest
The testWorkspaceQualified xpaths are affected the same way.
Here is a patch to fix those:
diff --git a/src/wms/src/test/java/org/geoserver/wms/wms_1_1_1/CapabilitiesTest.java b/src/wms/src/test/java/org/geoserver/wms/wms_1_1_1/CapabilitiesTest.java
index f7f8573…4799b89 100644
— a/src/wms/src/test/java/org/geoserver/wms/wms_1_1_1/CapabilitiesTest.java
+++ b/src/wms/src/test/java/org/geoserver/wms/wms_1_1_1/CapabilitiesTest.java
@@ -142,9 +142,9 @@
Element e = dom.getDocumentElement();
assertEquals(“WMT_MS_Capabilities”, e.getLocalName());
XpathEngine xpath = XMLUnit.newXpathEngine();
- assertTrue(xpath.getMatchingNodes(“//Layer/Name[starts-with(., cite)]”, dom).getLength() > 0);
- assertEquals(0, xpath.getMatchingNodes(“//Layer/Name[not(starts-with(., cite))]”, dom)
- .getLength());
- assertEquals(0, xpath.getMatchingNodes(“//Layer/Name[starts-with(., ‘cite’)]”, dom).getLength());
- assertTrue (xpath.getMatchingNodes(“//Layer/Name[not(starts-with(., ‘cite’))]”, dom)
- .getLength() > 0 );
NodeList nodes = xpath.getMatchingNodes(“//Layer//OnlineResource”, dom);
assertTrue(nodes.getLength() > 0);
@@ -162,8 +162,10 @@
Element e = dom.getDocumentElement();
assertEquals(“WMT_MS_Capabilities”, e.getLocalName());
XpathEngine xpath = XMLUnit.newXpathEngine();
- assertTrue(xpath.getMatchingNodes(“//Layer/Name[starts-with(., cite:Forests)]”, dom)
- .getLength() == 1);
- assertEquals(0, xpath.getMatchingNodes(“//Layer/Name[starts-with(., ‘cite:Forests’)]”, dom)
- .getLength());
- assertEquals(1, xpath.getMatchingNodes(“//Layer[Name = ‘Forests’]”, dom)
- .getLength());
assertEquals(1, xpath.getMatchingNodes(“//Layer//Layer”, dom).getLength());
NodeList nodes = xpath.getMatchingNodes(“//Layer//OnlineResource”, dom);
Ok to go and fix?
Cheers
Andrea
–
==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it