/** * As per section 7.4.1, a client shall not issue a GetFeatureInfo request for non queryable * layers; yet that section is not too clear with regard to whether an exception should be thrown. * I read it like an exception with OperationNotSupported code should be thrown. The full text is: * * <p><i> GetFeatureInfo is an optional operation. It is only supported for those Layers for which * the attribute queryable="1" (true) has been defined or inherited. A client shall not issue a * GetFeatureInfo request for other layers. A WMS shall respond with a properly formatted service * exception (XML) response (code = OperationNotSupported) if it receives a GetFeatureInfo request * but does not support it. </i> */ public void testQueryNonQueryableLayer() throws Exception { // HACK: fake the WMS facade to inform the layer is non queryable. Looks like we would need // a LayerInfo.isQueryable() property final WMS wms = (WMS) applicationContext.getBean("wms"); GetFeatureInfoKvpReader reader = (GetFeatureInfoKvpReader) applicationContext.getBean("getFeatureInfoKvpReader"); try { WMS fakeWMS = new WMS(wms.getGeoServer()) { @Override public boolean isQueryable(LayerInfo layer) { if ("Forests".equals(layer.getName())) { return false; } return super.isQueryable(layer); } }; reader.setWMS(fakeWMS); String layer = getLayerId(MockData.FORESTS); String request = "wms?version=1.3.0&bbox=-0.002,-0.002,0.002,0.002&styles=&format=jpeg&info_format=text/plain&request=GetFeatureInfo&layers=" + layer + "&query_layers=" + layer + "&width=20&height=20&i=10&j=10"; Document doc = dom(get(request), true); assertXpathEvaluatesTo( "LayerNotQueryable", "/ogc:ServiceExceptionReport/ogc:ServiceException/@code", doc); } finally { // restore the original wms reader.setWMS(wms); } }
public GetFeatureInfoKvpReader(WMS wms) { super(GetFeatureInfoRequest.class); getMapReader = new GetMapKvpRequestReader(wms); setWMS(wms); }