### Question:
CoverageMonitor { void inspectQuery(String query) { Map<String, String> qryParams = new HashMap<String, String>(); for (String param : query.split("&")) { String[] nvp = param.split("="); if(nvp.length > 1){ qryParams.put(nvp[0].toLowerCase(), nvp[1]); }else{ qryParams.put(nvp[0].toLowerCase(), ""); } } String reqType = qryParams.get("request"); XPath xpath = XPathFactory.newInstance().newXPath(); for (Map.Entry<String, String> paramEntry : qryParams.entrySet()) { String[] paramValues = paramEntry.getValue().split(","); for (int i = 0; i < paramValues.length; i++) { String expr = String .format(" reqType, paramEntry.getKey(), paramValues[i]); NodeList result = null; try { result = (NodeList) xpath.evaluate(expr, this.coverageDoc, XPathConstants.NODESET); } catch (XPathExpressionException xpe) { LOGR.log(Level.WARNING, "Failed to evaluate expression " + expr, xpe); } if ((null != result) && (result.getLength() > 0)) { for (int j = 0; j < result.getLength(); j++) { Node value = result.item(j); Element param = (Element) value.getParentNode(); param.removeChild(value); if (param.getElementsByTagName("value").getLength() == 0) { Node request = param.getParentNode(); request.removeChild(param); } } } } } } CoverageMonitor(String uri); File getTestSessionDir(); void setTestSessionDir(File sessionDir); void writeCoverageResults();  }### Answer:
@Test public void testInspectQuery() throws SAXException, IOException, XPathExpressionException { CoverageMonitor monitor = new CoverageMonitor( "urn:wms_client_test_suite/GetMap"); monitor.setTestSessionDir(tempDir); String query = "REQUEST=GetMap&LAYERS=cite:BasicPolygons,cite:Terrain"; monitor.inspectQuery(query); monitor.writeCoverageResults(); File coverageFile = new File(tempDir, "WMS-GetMap.xml"); Document coverage = docBuilder.parse(coverageFile); String expr = String .format("not( "layers", "cite:Terrain"); assertXPath(expr, coverage); expr = String .format(" "layers", "cite:Lakes"); assertXPath(expr, coverage); }