request.setLocale(new Locale(language));
/** Tests that minSymbolSize legend option is respected. */ @org.junit.Test public void testInternationalizedLabels() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); Map<String, String> options = new HashMap<String, String>(); options.put("forceLabels", "on"); req.setLegendOptions(options); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("Internationalized.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); int noLocalizedWidth = image.getWidth(); req.setLocale(Locale.ITALIAN); image = this.legendProducer.buildLegendGraphic(req); // test that using localized labels we get a different label than when not using it int itWidth = image.getWidth(); assertTrue(itWidth != noLocalizedWidth); req.setLocale(Locale.ENGLISH); image = this.legendProducer.buildLegendGraphic(req); // test that using localized labels we get a different label than when not using it int enWidth = image.getWidth(); assertTrue(enWidth != noLocalizedWidth); assertTrue(enWidth != itWidth); }