我正在使用DBUnit进行集成测试,在执行测试代码之前,我遇到了这个错误:
badges.track_types data type (2003, '_text') not recognized and will be ignored. See FAQ for more information.
org.dbunit.dataset.NoSuchColumnException: badges.TRACK_TYPES - (Non-uppercase input column: track_types) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive.
Run Code Online (Sandbox Code Playgroud)
被忽略的列是枚举列表.在数据集中,它是这样编写的:
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
// More info ...
<badges name="30'000" description="30k a day" image_name="30000.png" threshold_val="30000.00000000" has_many="true" id="45" track_types="{TRACK_GENERIC}" "/>
</dataset>
Run Code Online (Sandbox Code Playgroud)
我查看了DBUnit FAQ并看到了这个问题,说我必须覆盖isEnumType()方法来支持我的枚举是Postgresql,所以我这样做了:
/**
* Override method to set custom properties/features
*/
protected void setUpDatabaseConfig(DatabaseConfig config) {
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory(){ …Run Code Online (Sandbox Code Playgroud)