Пример #1
0
 @Test
 public void testFieldDeletionEditionWhileEdition() throws Exception {
   sm.register("toto", super.getAnyNonSpatialResource());
   DataSource d = dsf.getDataSource("toto");
   d.open();
   Value[][] content = super.getDataSourceContents(d);
   d.deleteRow(0);
   d.setFieldValue(0, 2, d.getFieldValue(1, 2));
   d.removeField(1);
   assertTrue(equals(d.getFieldValue(0, 1), content[2][2]));
   d.setFieldValue(0, 0, d.getFieldValue(1, 0));
   assertTrue(equals(d.getFieldValue(0, 0), content[2][0]));
   d.close();
 }
Пример #2
0
  private void testMetadataEditionListenerTest(String dsName, Type type) throws Exception {
    DataSource d = dsf.getDataSource(dsName);

    d.open();
    ListenerCounter elc = new ListenerCounter();
    d.addMetadataEditionListener(elc);
    d.removeField(1);
    d.addField("nuevo", type);
    d.setFieldName(1, "jjjj");
    assertEquals(elc.fieldDeletions, 1);
    assertEquals(elc.fieldInsertions, 1);
    assertEquals(elc.fieldModifications, 1);
    assertEquals(elc.total, 3);
    d.close();
  }
Пример #3
0
  @Test
  public void testDeleteField() throws Exception {
    sm.register(
        "big", getTempCopyOf(new File(TestResourceHandler.TESTRESOURCES, "landcover2000.shp")));
    DataSource d = dsf.getDataSource("big");

    d.open();
    Metadata m = d.getMetadata();
    int fc = m.getFieldCount();
    d.removeField(1);
    d.commit();
    d.close();
    d.open();
    assertEquals(fc - 1, m.getFieldCount());
    d.close();
  }
Пример #4
0
  @Test
  public void testEditionWithFieldRemoved() throws Exception {
    sm.register("ile", getTempCopyOf(super.getAnyNonSpatialResource()));
    DataSource d = dsf.getDataSource("ile", DataSourceFactory.EDITABLE);
    d.open();
    String fieldName = d.getFieldName(1);
    Value testValue = d.getFieldValue(0, 2);
    d.removeField(1);
    assertTrue(equals(testValue, d.getFieldValue(0, 1)));
    new UndoRedoTest().testAlphanumericEditionUndoRedo(d);
    d.commit();
    d.close();

    d.open();
    assertEquals(d.getFieldIndexByName(fieldName), -1);
    d.close();
  }