public void testUserSpecifiedRule() throws Exception {
//load a style with 3 rules
Style multipleRulesStyle = getCatalog().getStyleByName(MockData.ROAD_SEGMENTS.getLocalPart()).getStyle();
assertNotNull(multipleRulesStyle);
Rule rule = multipleRulesStyle.getFeatureTypeStyles()[0].getRules()[0];
LOGGER.info("testing single rule " + rule.getName() + " from style "
+ multipleRulesStyle.getName());
GetLegendGraphicRequest req = new GetLegendGraphicRequest(getWMS());
FeatureTypeInfo ftInfo = getCatalog().getFeatureTypeByName(MockData.ROAD_SEGMENTS.getNamespaceURI(), MockData.ROAD_SEGMENTS.getLocalPart());
req.setLayer(ftInfo.getFeatureType());
req.setStyle(multipleRulesStyle);
req.setRule(rule);
req.setLegendOptions(new HashMap());
final int HEIGHT_HINT = 30;
req.setHeight(HEIGHT_HINT);
//use default values for the rest of parameters
this.legendProducer.produceLegendGraphic(req);
BufferedImage legend = this.legendProducer.getLegendGraphic();
//was the legend painted?
assertNotBlank("testUserSpecifiedRule", legend, LegendUtils.DEFAULT_BG_COLOR);
//was created only one rule?
String errMsg = "expected just one legend of height " + HEIGHT_HINT + ", for the rule "
+ rule.getName();
int resultLegendCount = legend.getHeight() / HEIGHT_HINT;
assertEquals(errMsg, 1, resultLegendCount);
}