/**
   * This test ensures that when a SLD parameter has been passed that refers to a SLD document with
   * multiple styles, the required one is choosed based on the LAYER parameter.
   *
   * <p>This is the case where a remote SLD document is used in "library" mode.
   *
   * @throws Exception
   */
  @org.junit.Test
  public void testRemoteSLDMultipleStyles() throws Exception {
    final URL remoteSldUrl = getClass().getResource("MultipleStyles.sld");
    this.allParameters.put("SLD", remoteSldUrl.toExternalForm());

    this.allParameters.put("LAYER", "cite:Ponds");
    this.allParameters.put("STYLE", "Ponds");

    GetLegendGraphicRequest request =
        requestReader.read(new GetLegendGraphicRequest(), allParameters, allParameters);

    // the style names Ponds is declared in third position on the sld doc
    Style selectedStyle = request.getStyles().get(0);
    assertNotNull(selectedStyle);
    assertEquals("Ponds", selectedStyle.getName());

    this.allParameters.put("LAYER", "cite:Lakes");
    this.allParameters.put("STYLE", "Lakes");

    request = requestReader.read(new GetLegendGraphicRequest(), allParameters, allParameters);

    // the style names Ponds is declared in third position on the sld doc
    selectedStyle = request.getStyles().get(0);
    assertNotNull(selectedStyle);
    assertEquals("Lakes", selectedStyle.getName());
  }
  @org.junit.Test
  public void testLanguage() throws Exception {
    GetLegendGraphicRequest request;

    request =
        requestReader.read(new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
    assertNull(request.getLocale());

    request = requestReader.read(new GetLegendGraphicRequest(), allParameters, allParameters);
    assertEquals(Locale.ENGLISH, request.getLocale());
  }
  @org.junit.Test
  public void testLayerGroup() throws Exception {
    GetLegendGraphicRequest request;

    request =
        requestReader.read(new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
    assertTrue(request.getLayers().size() == 1);

    requiredParameters.put("LAYER", NATURE_GROUP);
    request =
        requestReader.read(new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
    assertTrue(request.getLayers().size() > 1);
  }
  @org.junit.Test
  public void testStrictParameter() throws Exception {
    GetLegendGraphicRequest request;

    // default value
    request = requestReader.read(new GetLegendGraphicRequest(), allParameters, allParameters);
    assertTrue(request.isStrict());

    allParameters.put("STRICT", "false");
    allParameters.remove("LAYER");
    request = requestReader.read(new GetLegendGraphicRequest(), allParameters, allParameters);
    assertFalse(request.isStrict());
  }
  @org.junit.Test
  public void testLabelsForLayerGroup() throws Exception {
    GetLegendGraphicRequest request;

    requiredParameters.put("LAYER", NATURE_GROUP);
    request =
        requestReader.read(new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
    assertNotNull(request.getTitle(new NameImpl("http://www.opengis.net/cite", "Lakes")));
  }
 @org.junit.Test
 public void testMissingFormatParameter() throws Exception {
   requiredParameters.remove("FORMAT");
   try {
     requestReader.read(new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
     fail("Expected ServiceException");
   } catch (ServiceException e) {
     assertEquals("MissingFormat", e.getCode());
   }
 }
  @org.junit.Test
  public void testCascadingWMS() throws Exception {
    Catalog catalog = getCatalog();

    CatalogBuilder builder = new CatalogBuilder(catalog);
    WMSStoreInfo wmsStore = builder.buildWMSStore("cascadeWMS");
    wmsStore.setCapabilitiesURL(
        "http://wms.geonorge.no/skwms1/wms.toporaster2?service=WMS&version=1.1.1");
    catalog.add(wmsStore);

    builder.setStore(wmsStore);
    WMSLayerInfo wmsLayer = builder.buildWMSLayer("toporaster");
    catalog.add(wmsLayer);

    requiredParameters.put("LAYER", "toporaster");
    GetLegendGraphicRequest request =
        requestReader.read(new GetLegendGraphicRequest(), requiredParameters, requiredParameters);
    assertNotNull(request);
  }