示例#1
0
  /**
   * Tests the {@lik FormatTable#find} method.
   *
   * @throws SQLException If the test can't connect to the database.
   */
  @Test
  public void testFind() throws SQLException {
    final Category[] categories = {
      new Category("No data", null, 0), new Category("Temperature", null, 1, 256, 0.15, -3)
    };
    final FormatTable table = getDatabase().getTable(FormatTable.class);
    /*
     * Following entry should be found for the PNG format only.
     */
    GridSampleDimension search = new GridSampleDimension("Temperature", categories, Units.CELSIUS);
    FormatEntry found = table.find("NetCDF", Arrays.asList(search));
    assertNull("Should be defined for the PNG format, not NetCDF.", found);
    found = table.find("PNG", Arrays.asList(search));
    assertNotNull("Should be defined for the PNG format.", found);
    assertEquals(TEMPERATURE, found.getIdentifier());
    /*
     * Replace the category by a different one.
     * The entry should not be found anymore.
     */
    categories[1] = new Category("Temperature", null, 1, 256, 0.15, -4);
    search = new GridSampleDimension("Temperature", categories, Units.CELSIUS);
    found = table.find("PNG", Arrays.asList(search));
    assertNull("Should not found because the transfer function is different.", found);

    categories[1] = new Category("Temperature", null, 1, 255, 0.15, -3);
    search = new GridSampleDimension("Temperature", categories, Units.CELSIUS);
    found = table.find("PNG", Arrays.asList(search));
    assertNull("Should not found because the range is different.", found);

    categories[1] = new Category("Temperature", null, 1, 256, 0.15, -3);
    search = new GridSampleDimension("Temperature", categories, Units.CELSIUS);
    found = table.find("PNG", Arrays.asList(search));
    assertNotNull("Should found since the category has been restored.", found);
    assertEquals(TEMPERATURE, found.getIdentifier());
    table.release();
  }