public void testGridCS() throws Exception {
    Map<String, Object> raw = baseMap();
    final String layerId = getLayerId(TASMANIA_BM);
    raw.put("identifier", layerId);
    raw.put("format", "image/tiff");
    raw.put("BoundingBox", "-45,146,-42,147");

    raw.put("GridCS", GridCS.GCSGrid2dSquare.getXmlConstant());
    GetCoverageType getCoverage =
        (GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw);
    assertEquals(
        GridCS.GCSGrid2dSquare.getXmlConstant(), getCoverage.getOutput().getGridCRS().getGridCS());

    raw.put("GridCS", GridCS.GCSGrid2dSquare.getXmlConstant().toUpperCase());
    getCoverage = (GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw);
    assertEquals(
        GridCS.GCSGrid2dSquare.getXmlConstant(), getCoverage.getOutput().getGridCRS().getGridCS());

    raw.put("GridCS", "Hoolabaloola");
    try {
      reader.read(reader.createRequest(), parseKvp(raw), raw);
      fail("We should have had a WcsException here?");
    } catch (WcsException e) {
      assertEquals(InvalidParameterValue.name(), e.getCode());
      assertEquals("GridCS", e.getLocator());
    }
  }
 public void testUnknownCoverageParams() throws Exception {
   Map<String, Object> raw = baseMap();
   final String layerId = "fairyTales:rumpelstilskin";
   raw.put("identifier", layerId);
   raw.put("format", "SuperCoolFormat");
   raw.put("BoundingBox", "-45,146,-42,147");
   try {
     reader.read(reader.createRequest(), parseKvp(raw), raw);
     fail("That coverage is not registered???");
   } catch (WcsException e) {
     assertEquals(InvalidParameterValue.toString(), e.getCode());
     assertEquals("identifier", e.getLocator());
   }
 }
  public void testMissingParams() throws Exception {
    Map<String, Object> raw = baseMap();

    try {
      reader.read(reader.createRequest(), parseKvp(raw), raw);
      fail("Hey, format is missing, this should have failed");
    } catch (WcsException e) {
      assertEquals("MissingParameterValue", e.getCode());
    }

    final String layerId = getLayerId(TASMANIA_BM);
    raw.put("identifier", layerId);
    try {
      reader.read(reader.createRequest(), parseKvp(raw), raw);
      fail("Hey, format is missing, this should have failed");
    } catch (WcsException e) {
      assertEquals("MissingParameterValue", e.getCode());
    }

    raw.put("format", "image/tiff");
    try {
      reader.read(reader.createRequest(), parseKvp(raw), raw);
      fail("Hey, boundingBox is missing, this should have failed");
    } catch (WcsException e) {
      assertEquals("MissingParameterValue", e.getCode());
    }

    raw.put("BoundingBox", "-45,146,-42,147");
    try {
      reader.read(reader.createRequest(), parseKvp(raw), raw);
    } catch (WcsException e) {
      fail("This time all mandatory params where provided?");
      assertEquals("MissingParameterValue", e.getCode());
    }
  }
  public void testUnsupportedCRS() throws Exception {
    Map<String, Object> raw = baseMap();
    final String layerId = getLayerId(TASMANIA_BM);
    raw.put("identifier", layerId);
    raw.put("format", "image/tiff");
    raw.put("GridBaseCRS", "urn:ogc:def:crs:EPSG:6.6:-1000");

    try {
      reader.read(reader.createRequest(), parseKvp(raw), raw);
      fail("We should have had a WcsException here?");
    } catch (WcsException e) {
      assertEquals("GridBaseCRS", e.getLocator());
      assertEquals("InvalidParameterValue", e.getCode());
    }
  }
  public void testGridOffsets() throws Exception {
    Map<String, Object> raw = baseMap();

    final String layerId = getLayerId(TASMANIA_BM);
    raw.put("identifier", layerId);
    raw.put("format", "image/tiff");
    raw.put("BoundingBox", "-45,146,-42,147");

    raw.put("GridOffsets", "10.5,-30.2");
    raw.put("GridType", GridType.GT2dSimpleGrid.getXmlConstant());
    GetCoverageType getCoverage =
        (GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw);
    Double[] offsets = (Double[]) getCoverage.getOutput().getGridCRS().getGridOffsets();
    assertEquals(2, offsets.length);
    assertEquals(10.5, offsets[0]);
    assertEquals(-30.2, offsets[1]);

    raw.put("GridOffsets", "12");
    try {
      reader.read(reader.createRequest(), parseKvp(raw), raw);
      fail("We should have had a WcsException here?");
    } catch (WcsException e) {
      assertEquals(InvalidParameterValue.name(), e.getCode());
      assertEquals("GridOffsets", e.getLocator());
    }

    raw.put("GridOffsets", "12,a");
    try {
      reader.read(reader.createRequest(), parseKvp(raw), raw);
      fail("We should have had a WcsException here?");
    } catch (WcsException e) {
      assertEquals(InvalidParameterValue.name(), e.getCode());
      assertEquals("GridOffsets", e.getLocator());
    }
  }