本文整理汇总了Java中org.dbunit.dataset.xml.FlatXmlProducer类的典型用法代码示例。如果您正苦于以下问题:Java FlatXmlProducer类的具体用法?Java FlatXmlProducer怎么用?Java FlatXmlProducer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlatXmlProducer类属于org.dbunit.dataset.xml包,在下文中一共展示了FlatXmlProducer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertDbUnitTestdata
import org.dbunit.dataset.xml.FlatXmlProducer; //导入依赖的package包/类
/**
* Inserts test data in DbUnit XML format.
*
* @param entityManager
* the EntityManager
* @param dbUnitTestdata
* test file stream
*/
public static void insertDbUnitTestdata(EntityManager entityManager, final InputStream dbUnitTestdata) {
entityManager.unwrap(Session.class).doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
// Insert Testdata
try {
LOGGER.debug("INSERTing testdata");
DatabaseConnection databaseConnection = new DatabaseConnection(connection);
databaseConnection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
new MySqlDataTypeFactory());
FlatXmlDataSet dataSet = new FlatXmlDataSet(
new FlatXmlProducer(new InputSource(dbUnitTestdata), false, true));
DatabaseOperation.CLEAN_INSERT.execute(databaseConnection, dataSet);
LOGGER.debug("INSERTing testdata ... done");
} catch (DatabaseUnitException e) {
throw new SQLException(e);
}
}
});
}
示例2: truncate
import org.dbunit.dataset.xml.FlatXmlProducer; //导入依赖的package包/类
/**
* Truncate tables specified in the datafile
* @param connection database connection
* @param clazz class from which the datafile resource is retrieved
* @param datafile datafile specifying tables to be truncated
* @throws DatabaseUnitException on error
*/
public void truncate(final IDatabaseConnection connection, final Class<?> clazz, final String datafile) throws DatabaseUnitException {
try {
DatabaseOperation.TRUNCATE_TABLE.execute(connection, new CachedDataSet(new FlatXmlProducer(new InputSource(getResource(clazz, datafile)))));
} catch (final SQLException e) {
throw new DatabaseUnitException(e);
}
}
示例3: createDateSet
import org.dbunit.dataset.xml.FlatXmlProducer; //导入依赖的package包/类
/**
* 根据配置文件的名称创建DateSet
* @param tname配置文件的名称
* @return
* @throws DataSetException
*/
protected IDataSet createDateSet(String tname) throws DataSetException {
//配置文件在classes的根目录下
InputStream is = AbstractDbUnitTestCase
.class
.getClassLoader().getResourceAsStream(tname+".xml");
Assert.assertNotNull("dbunit的基本数据文件不存在",is);
//创建DataSet
return new FlatXmlDataSet(new FlatXmlProducer(new InputSource(is)));
}
示例4: resumeTable
import org.dbunit.dataset.xml.FlatXmlProducer; //导入依赖的package包/类
protected void resumeTable() throws FileNotFoundException, DatabaseUnitException, SQLException {
IDataSet ds = new FlatXmlDataSet(new FlatXmlProducer(new InputSource(new FileInputStream(tempFile))));
DatabaseOperation.CLEAN_INSERT.execute(dbunitCon, ds);
}
示例5: getDataSet
import org.dbunit.dataset.xml.FlatXmlProducer; //导入依赖的package包/类
public FlatXmlDataSet getDataSet(String fileName) throws DataSetException {
return new FlatXmlDataSet(new FlatXmlProducer(new InputSource(getClass().getResourceAsStream(fileName))));
}