/**
* Tests that application identity classes are returned correctly.
*/
public void testSchemaGeneration() {
JDBCConfiguration conf = new JDBCConfigurationImpl();
DBDictionary dict = conf.getDBDictionaryInstance();
MappingRepository repos = conf.getMappingRepositoryInstance();
repos.setStrategyInstaller(new RefreshStrategyInstaller(repos));
ClassMapping mapping = repos.getMapping(Column.class, null, true);
Class cls;
if (dict.getPreferredType(JavaSQLTypes.CLOB) == JavaSQLTypes.CLOB) {
if (dict.maxEmbeddedClobSize > 0) {
cls = mapping.getFieldMapping("toClob").getStrategy().
getClass();
assertTrue(cls.getName(),
MaxEmbeddedClobFieldStrategy.class.isAssignableFrom(cls));
} else {
cls = mapping.getFieldMapping("toClob").getHandler().
getClass();
assertTrue(cls.getName(),
ClobValueHandler.class.isAssignableFrom(cls));
}
} else
assertTrue(mapping.getFieldMapping("toClob").getStrategy()
instanceof StringFieldStrategy);
cls = mapping.getFieldMapping("toBlob").getHandler().getClass();
assertTrue(cls.getName(),
BlobValueHandler.class.isAssignableFrom(cls));
SchemaGroup schema = repos.getSchemaGroup();
Table table = schema.getSchemas()[0].getTables()[0];
Column[] cols = table.getColumns();
for (int i = 0; i < cols.length; i++) {
if (cols[i].getName().equalsIgnoreCase("id")
|| cols[i].getName().equalsIgnoreCase("versn")
|| cols[i].getName().equalsIgnoreCase("typ"))
continue;
if ("longToInt".equalsIgnoreCase(cols[i].getName()))
assertEquals(dict.getPreferredType(JavaSQLTypes.INT),
cols[i].getType());
else if ("longToSQL".equalsIgnoreCase(cols[i].getName()))
assertEquals("varchar", cols[i].getTypeName());
else if ("toClob".equalsIgnoreCase(cols[i].getName()))
assertEquals(dict.getPreferredType(JavaSQLTypes.CLOB),
cols[i].getType());
else if ("toBlob".equalsIgnoreCase(cols[i].getName()))
assertEquals(dict.getPreferredType(JavaSQLTypes.BLOB),
cols[i].getType());
else
fail("Unknown column:" + cols[i].getName());
}
}