import com.hardcode.driverManager.DriverManager;
public class DriverMetadataTest extends DataSourceTestCase {
public void testAddField() throws Exception {
DataSource d = ds.getDataSource("sort");
d.beginTrans();
int fc = d.getDataSourceMetadata().getFieldCount();
d.addField("nuevo", "STRING");
assertTrue(d.getDataSourceMetadata().getFieldType(fc) == Value.STRING);
assertTrue(d.getDriverMetadata().getFieldType(fc) == "STRING");
d.commitTrans();
d = ds.getDataSource("sort");
d.start();
assertTrue(d.getDataSourceMetadata().getFieldCount() == fc + 1);
assertTrue(d.getDriverMetadata().getFieldCount() == fc + 1);
assertTrue(d.getDriverMetadata().getFieldType(fc) == "STRING");
assertTrue(d.getDataSourceMetadata().getFieldType(fc) == Value.STRING);
d.stop();
d = ds.getDataSource("hsqldbpersona");
d.beginTrans();
fc = d.getDataSourceMetadata().getFieldCount();
d.addField("nuevo", "BIT");
assertTrue(d.getDataSourceMetadata().getFieldType(fc) == Value.BOOLEAN);
assertTrue(d.getDriverMetadata().getFieldType(fc).equals("BIT"));
d.commitTrans();
d = ds.getDataSource("hsqldbpersona");
d.start();
assertTrue(d.getDataSourceMetadata().getFieldCount() == fc + 1);
assertTrue(d.getDriverMetadata().getFieldCount() == fc + 1);
assertTrue(d.getDriverMetadata().getFieldType(fc).equals("BOOLEAN"));
assertTrue(d.getDataSourceMetadata().getFieldType(fc) == Value.BOOLEAN);
d.stop();
d = ds.getDataSource("hsqldbpersona");
d.beginTrans();
fc = d.getDataSourceMetadata().getFieldCount();
d.addField("nuevo2", "CHAR");
assertTrue(d.getDataSourceMetadata().getFieldType(fc) == Value.STRING);
assertTrue(d.getDriverMetadata().getFieldType(fc).equals("CHAR"));
assertTrue(d.getDriverMetadata().getFieldParam(fc, "LENGTH") == null);
d.commitTrans();
d = ds.getDataSource("hsqldbpersona");
d.start();
assertTrue(d.getDataSourceMetadata().getFieldCount() == fc + 1);
assertTrue(d.getDriverMetadata().getFieldCount() == fc + 1);
assertTrue(d.getDriverMetadata().getFieldType(fc).equals("CHAR"));
assertTrue(d.getDriverMetadata().getFieldParam(fc, "LENGTH") != null);
assertTrue(d.getDataSourceMetadata().getFieldType(fc) == Value.STRING);
d.stop();
}