@Test
  public void testRenamedDefinition()
      throws DataStoreException, NoSuchAuthorityCodeException, FactoryException {

    final ExtendedDataStore store = new ExtendedDataStore(dataStore);
    final Name name = DefaultName.valueOf("{http://www.geotoolkit.org/test}extsql");
    assertFalse(store.getNames().contains(name));

    // add a new query
    final Query query =
        QueryBuilder.language(
            JDBCDataStore.CUSTOM_SQL,
            "SELECT geometry as geo ,\"intProperty\" as it FROM custom",
            name);
    store.addQuery(query);
    assertTrue(store.getNames().contains(name));

    final FeatureType ft = store.getFeatureType(name);
    assertEquals(name, ft.getName());
    assertEquals(2, ft.getDescriptors().size());
    assertTrue(ft.getDescriptor("geo") != null);
    assertTrue(ft.getDescriptor("it") != null);
    assertEquals(Point.class, ft.getDescriptor("geo").getType().getBinding());
    assertTrue(
        CRS.equalsIgnoreMetadata(
            CRS.decode("EPSG:4326", true),
            ((GeometryDescriptor) ft.getDescriptor("geo")).getCoordinateReferenceSystem()));
    assertEquals(Integer.class, ft.getDescriptor("it").getType().getBinding());
  }
  @Test
  public void testRead() throws DataStoreException, NoSuchAuthorityCodeException, FactoryException {

    final ExtendedDataStore store = new ExtendedDataStore(dataStore);
    final Name name = DefaultName.valueOf("{http://www.geotoolkit.org/test}extsql");
    assertFalse(store.getNames().contains(name));

    // add a new query
    final Query query =
        QueryBuilder.language(
            JDBCDataStore.CUSTOM_SQL,
            "SELECT geometry as geo ,\"intProperty\" as it FROM custom",
            name);
    store.addQuery(query);
    assertTrue(store.getNames().contains(name));

    final FeatureType ft = store.getFeatureType(name);

    final FeatureCollection col =
        store.createSession(true).getFeatureCollection(QueryBuilder.all(name));
    assertEquals(ft, col.getFeatureType());
    assertEquals(3, col.size());

    final FeatureIterator ite = col.iterator();
    try {
      while (ite.hasNext()) {
        final Feature f = ite.next();
        assertEquals(f.getType(), ft);
      }
    } finally {
      ite.close();
    }
  }