本文整理汇总了Java中org.dbunit.ext.mysql.MySqlMetadataHandler类的典型用法代码示例。如果您正苦于以下问题:Java MySqlMetadataHandler类的具体用法?Java MySqlMetadataHandler怎么用?Java MySqlMetadataHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySqlMetadataHandler类属于org.dbunit.ext.mysql包,在下文中一共展示了MySqlMetadataHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetCorrectDatabaseMetaHandler
import org.dbunit.ext.mysql.MySqlMetadataHandler; //导入依赖的package包/类
@Test
public void testGetCorrectDatabaseMetaHandler() {
Properties prop = new Properties();
prop.setProperty("org.dbunit.database.IMetadataHandler.implClassName", "org.dbunit.database.DefaultMetadataHandler");
sut.init(prop);
IMetadataHandler metaHandler1 = sut.getDefaultDatabaseMetaHandler();
Assert.assertNotNull(metaHandler1);
Assert.assertThat(metaHandler1, CoreMatchers.instanceOf(DefaultMetadataHandler.class));
prop = new Properties();
prop.setProperty("org.dbunit.database.IMetadataHandler.implClassName", "org.dbunit.ext.mysql.MySqlMetadataHandler");
sut.init(prop);
metaHandler1 = sut.getDefaultDatabaseMetaHandler();
Assert.assertNotNull(metaHandler1);
Assert.assertThat(metaHandler1, CoreMatchers.instanceOf(MySqlMetadataHandler.class));
}
示例2: testCreateDbUnitConnection
import org.dbunit.ext.mysql.MySqlMetadataHandler; //导入依赖的package包/类
/**
* Test method for {@link org.unitils.dbunit.DbUnitModule#createDbUnitConnection(java.lang.String)}.
*/
@Test
public void testCreateDbUnitConnection() {
Properties tempConfig = (Properties) configuration.clone();
tempConfig.setProperty("org.dbunit.database.IMetadataHandler.implClassName", "org.dbunit.ext.mysql.MySqlMetadataHandler");
sut.init(tempConfig);
DbUnitDatabaseConnection connection = sut.createDbUnitConnection(schema);
DatabaseConfig databaseConfig = connection.getConfig();
Object metaHandler = databaseConfig.getProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER);
Assert.assertNotNull(metaHandler);
Assert.assertThat(metaHandler, CoreMatchers.instanceOf(MySqlMetadataHandler.class));
}
示例3: init
import org.dbunit.ext.mysql.MySqlMetadataHandler; //导入依赖的package包/类
/**
* Method to insert data before test. throws Exception from DB.
*
* @throws Exception
* the exception
*/
public void init() throws Exception {
DatabaseLoader.logger.debug("DatabaseLoader.init()");
try {
DatabaseLoader.logger.debug("starting init() in DatabaseLoader...");
this.dbConn = new DatabaseConnection(DataSourceUtils.getConnection(dataSource), this.schema);
DatabaseConfig config = dbConn.getConfig();
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
config.setProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER, new MySqlMetadataHandler());
config.setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, Boolean.TRUE);
DatabaseLoader.logger.debug("DATASOURCE." + dataSource.toString());
this.loader = new FlatXmlDataSetBuilder();
dbConn.getConnection().createStatement().execute("DELETE FROM dbe_transaction");
deleteAll("dbunit/CREATE_DATATEST_III.xml", false);
deleteAll("dbunit/CREATE_DATATEST_II.xml", false);
deleteAll("dbunit/CREATE_DATATEST_I.xml", false);
cleanInsert("dbunit/CREATE_DATATEST_I.xml", false);
cleanInsert("dbunit/CREATE_DATATEST_II.xml", false);
cleanInsert("dbunit/CREATE_DATATEST_III.xml", true);
DatabaseLoader.logger.debug("ending init() in DatabaseLoader...");
} catch (Exception e) {
DatabaseLoader.logger.error("Error loading data init in DatabaseLoader");
dbConn.getConnection().rollback();
e.printStackTrace();
throw e;
}
}
示例4: dbUnitDatabaseConfig
import org.dbunit.ext.mysql.MySqlMetadataHandler; //导入依赖的package包/类
/**
* custom configuration since we have case-sensitive table names and requiring
* MySQL specifics
*/
@Bean
public DatabaseConfigBean dbUnitDatabaseConfig() {
DatabaseConfigBean config = new DatabaseConfigBean();
config.setDatatypeFactory(new MySqlDataTypeFactory());
config.setMetadataHandler(new MySqlMetadataHandler());
config.setCaseSensitiveTableNames(true);
config.setAllowEmptyFields(true);
return config;
}