*/
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);
}
}