@Test public void testValidateGet() throws Exception { String request = "csw?service=CSW&version=2.0.2&request=GetRecords&typeNames=csw:Record&resultType=validate"; Document d = getAsDOM(request); checkValidationErrors(d, new CSWConfiguration()); // print(d); XpathEngine xpath = XMLUnit.newXpathEngine(); assertXpathEvaluatesTo("http://localhost:8080/geoserver/" + request, "/csw:Acknowledgement/csw:EchoedRequest/ows:Get/@xlink:href", d); String timeStamp = xpath.evaluate("/csw:Acknowledgement/@timeStamp", d); assertGMLTimestamp(timeStamp); }
@Test public void testValidatePost() throws Exception { String request = getResourceAsString("GetRecordsValidate.xml"); Document d = postAsDOM("csw", request); checkValidationErrors(d, new CSWConfiguration()); // print(d); XpathEngine xpath = XMLUnit.newXpathEngine(); String timeStamp = xpath.evaluate("/csw:Acknowledgement/@timeStamp", d); assertGMLTimestamp(timeStamp); assertXpathEvaluatesTo("*lorem*", "/csw:Acknowledgement/csw:EchoedRequest/csw:GetRecords/csw:Query/" + "csw:Constraint/ogc:Filter/ogc:PropertyIsLike/ogc:Literal", d); }
@Test public void testHitRequest() throws Exception { String request = "csw?service=CSW&version=2.0.2&request=GetRecords&typeNames=csw:Record"; Document d = getAsDOM(request); checkValidationErrors(d, new CSWConfiguration()); // print(d); // we have the right kind of document assertXpathEvaluatesTo("1", "count(/csw:GetRecordsResponse)", d); XpathEngine xpath = XMLUnit.newXpathEngine(); // check we have a timestamp that is a valid XML date, and it's GMT (we don't // test parts of the date since we are bound to fail even the year if the test is run // across midnight of String timestampPath = "/csw:GetRecordsResponse/csw:SearchStatus/@timestamp"; String timeStamp = xpath.evaluate(timestampPath, d); assertGMLTimestamp(timeStamp); // check we have the expected results assertXpathEvaluatesTo("summary", "//csw:SearchResults/@elementSet", d); assertXpathEvaluatesTo("12", "//csw:SearchResults/@numberOfRecordsMatched", d); assertXpathEvaluatesTo("0", "//csw:SearchResults/@numberOfRecordsReturned", d); assertXpathEvaluatesTo("11", "//csw:SearchResults/@nextRecord", d); // check we have no results assertXpathEvaluatesTo("0", "count(//csw:SearchResults/*)", d); }