@Test
  public void testSetters() throws Exception {
    DataSource d = dsf.getDataSource("alltypes");
    d.open();
    d.setBinary(0, 0, d.getFieldValue(1, 0).getAsBinary());
    d.setBinary(0, "binary", d.getFieldValue(1, 0).getAsBinary());
    d.setBoolean(0, 1, d.getFieldValue(1, 1).getAsBoolean());
    d.setBoolean(0, "boolean", d.getFieldValue(1, 1).getAsBoolean());
    d.setByte(0, 2, d.getFieldValue(1, 2).getAsByte());
    d.setByte(0, "byte", d.getFieldValue(1, 2).getAsByte());
    d.setDate(0, 3, d.getFieldValue(1, 3).getAsDate());
    d.setDate(0, "date", d.getFieldValue(1, 3).getAsDate());
    d.setDouble(0, 4, d.getFieldValue(1, 4).getAsDouble());
    d.setDouble(0, "double", d.getFieldValue(1, 4).getAsDouble());
    d.setFloat(0, 5, d.getFieldValue(1, 5).getAsFloat());
    d.setFloat(0, "float", d.getFieldValue(1, 5).getAsFloat());
    d.setInt(0, 6, d.getFieldValue(1, 6).getAsInt());
    d.setInt(0, "int", d.getFieldValue(1, 6).getAsInt());
    d.setLong(0, 7, d.getFieldValue(1, 7).getAsLong());
    d.setLong(0, "long", d.getFieldValue(1, 7).getAsLong());
    d.setShort(0, 8, d.getFieldValue(1, 8).getAsShort());
    d.setShort(0, "short", d.getFieldValue(1, 8).getAsShort());
    d.setString(0, 9, d.getFieldValue(1, 9).getAsString());
    d.setString(0, "string", d.getFieldValue(1, 9).getAsString());
    d.setTimestamp(0, "timestamp", d.getFieldValue(1, 10).getAsTimestamp());
    d.setTime(0, 11, d.getFieldValue(1, 11).getAsTime());
    d.setTime(0, "time", d.getFieldValue(1, 11).getAsTime());

    for (int i = 0; i < d.getMetadata().getFieldCount(); i++) {
      assertEquals(d.getFieldValue(0, i), d.getFieldValue(1, i));
    }
    d.close();
  }
示例#2
0
 @Test
 public void testSecondNameWorksWithIndexes() throws Exception {
   String dsName = "test8";
   sm.register(dsName, super.getAnySpatialResource());
   String secondName = "secondName";
   DataSource ds = dsf.getDataSource(dsName);
   ds.open();
   String spatialFieldName =
       ds.getMetadata().getFieldName(MetadataUtilities.getSpatialFieldIndex(ds.getMetadata()));
   ds.close();
   sm.addName(dsName, secondName);
   dsf.getIndexManager()
       .buildIndex(dsName, spatialFieldName, IndexManager.RTREE_SPATIAL_INDEX, null);
   SpatialIndexQuery query =
       new DefaultSpatialIndexQuery(spatialFieldName, new Envelope(0, 0, 0, 0));
   assertNotNull(dsf.getIndexManager().getIndex(dsName, spatialFieldName));
   assertNotNull(dsf.getIndexManager().getIndexedFieldNames(dsName));
   assertNotNull(dsf.getIndexManager().queryIndex(dsName, query));
   assertNotNull(dsf.getIndexManager().getIndex(secondName, spatialFieldName));
   assertNotNull(dsf.getIndexManager().getIndexedFieldNames(secondName));
   assertNotNull(dsf.getIndexManager().queryIndex(secondName, query));
 }