本文整理汇总了Java中org.dbunit.dataset.xml.FlatXmlDataSetBuilder.setColumnSensing方法的典型用法代码示例。如果您正苦于以下问题:Java FlatXmlDataSetBuilder.setColumnSensing方法的具体用法?Java FlatXmlDataSetBuilder.setColumnSensing怎么用?Java FlatXmlDataSetBuilder.setColumnSensing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dbunit.dataset.xml.FlatXmlDataSetBuilder
的用法示例。
在下文中一共展示了FlatXmlDataSetBuilder.setColumnSensing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initEntityManager
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
/**
* Set up memory database and insert data from test-dataset.xml
*
* @throws DatabaseUnitException
* @throws HibernateException
* @throws SQLException
*/
@BeforeClass
public static void initEntityManager() throws HibernateException, DatabaseUnitException, SQLException {
entityManagerFactory = Persistence.createEntityManagerFactory("listing-test-db");
entityManager = entityManagerFactory.createEntityManager();
connection = new DatabaseConnection(((SessionImpl) (entityManager.getDelegate())).connection());
connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(datasetXml);
if (inputStream != null) {
FlatXmlDataSetBuilder flatXmlDataSetBuilder = new FlatXmlDataSetBuilder();
flatXmlDataSetBuilder.setColumnSensing(true);
dataset = flatXmlDataSetBuilder.build(inputStream);
DatabaseOperation.CLEAN_INSERT.execute(connection, dataset);
}
}
示例2: from
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
/**
* @author Wasiq B
* @since 24-Nov-2015 8:10:47 pm
* @param file
* @return {@link DataSetBuilder}
* @throws FrameworkException
*/
public DataSetBuilder from (final String file) throws FrameworkException {
log.entry ();
try {
final FlatXmlDataSetBuilder build = new FlatXmlDataSetBuilder ();
build.setColumnSensing (true);
final IDataSet dataSet = build
.build (new File (FileUtils.getResource (file).getPath ()));
setDataSet (dataSet);
return this;
}
catch (final Exception e) {
log.catching (e);
throw new FrameworkException ("from", e);
}
finally {
log.exit ();
}
}
示例3: setupDB
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void setupDB() throws Exception {
ds = UnitTestDSProvider.getDataSource();
//clean any existing records and load some records into the database.
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setColumnSensing(true);
Connection setup = ds.getConnection();
IDatabaseConnection con = new DatabaseConnection(setup);
{
InputStream xmlInput = DeviceDAOImplTest.class.getResourceAsStream("/data/app-data-1.xml");
IDataSet dataSet = builder.build(xmlInput);
DatabaseOperation.CLEAN_INSERT.execute(con, dataSet);
}
// load test encryptor class
Class.forName(EncryptorForTest.class.getName());
}
示例4: loadDatasource
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
private void loadDatasource(DBUnitDataSet annotation, TestContext testContext) throws Exception{
DataSource dataSource = testContext.getApplicationContext().getBean(DataSource.class);
IDatabaseTester databaseTester = new DataSourceDatabaseTester(dataSource, "PUBLIC");
//Ignore referential integrity so DBUnit can correctly delete rows related to the data set
dataSource.getConnection().createStatement().execute("SET DATABASE REFERENTIAL INTEGRITY FALSE;");
for(String sourceFile : annotation.value()){
InputStream input = this.getClass().getResourceAsStream(sourceFile);
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setColumnSensing(true);
IDataSet ds = builder.build(input);
databaseTester.setDataSet(ds);
databaseTester.onSetup();
}
//Add Referential constraints back in, now that the dbunit setup is complete
dataSource.getConnection().createStatement().execute("SET DATABASE REFERENTIAL INTEGRITY TRUE;");
}
示例5: initializeGlobalDataFile
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
/**
* Initialize.
*
* @param context
* the context
* @param dataSource
* the data source
* @throws DatabaseUnitException
* the database unit exception
* @throws SQLException
* the SQL exception
* @throws MalformedURLException
* the malformed url exception
*/
public void initializeGlobalDataFile(ApplicationContext context)
throws DatabaseUnitException, SQLException, MalformedURLException {
DataSource datas = GlobalUtils.findDataSourceBean(context);
IDatabaseConnection con = new DatabaseConnection(datas.getConnection()); // Create
// DBUnit
// Database
// connection
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setColumnSensing(true);
datasets = new IDataSet[] { builder.build(singleInitXmlFile) };
DatabaseOperation.REFRESH.execute(con, new CompositeDataSet(datasets)); // Import
// your
// data
// TODO handle the empty data file case.
con.close();
}
示例6: getDataSet
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
/**
* Charge le jeu de données à partir d'un fichier XML d'import
* @return
* @throws java.lang.Exception
*/
@Override
protected IDataSet getDataSet() throws Exception {
if (dataset != null) {
return dataset;
}
if (!getInputDataFileName().isEmpty()) {
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setColumnSensing(true);
dataset = builder.build(new File(
getInputDataFileName()));
return dataset;
} else {
return null;
}
}
示例7: getBuilder
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
/**
* Permet de créer un dataSet pouvant parser un fichier xml.
* @return {@link IDataSet}
* @throws SaladiumException
*/
private IDataSet getBuilder(File file) throws SaladiumException {
FlatXmlDataSetBuilder dataSetBuilder = new FlatXmlDataSetBuilder();
dataSetBuilder.setColumnSensing(true);
dataSetBuilder.setCaseSensitiveTableNames(true);
dataSetBuilder.setDtdMetadata(false);
try {
// FileInputStream xmlInputFile = new FileInputStream(file);
FlatXmlDataSet dataSet = dataSetBuilder.build(file);
// xmlInputFile.close();
return dataSet;
} catch (Exception e) {
throw new SaladiumException(e);
}
}
示例8: loadDataSet
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
protected IDataSet loadDataSet(URL source) throws Exception {
final FlatXmlDataSetBuilder xmlData = new FlatXmlDataSetBuilder();
xmlData.setColumnSensing(true);
final ReplacementDataSet set = new ReplacementDataSet(
xmlData.build(source));
set.addReplacementObject("[NULL]", null);
return set;
}
示例9: xmlLoader
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
@Override
public DataSetLoader<IDataSet> xmlLoader() {
return (final File path) -> {
try (InputStream in = new FileInputStream(path)) {
final FlatXmlDataSetBuilder flatXmlDataSetBuilder = new FlatXmlDataSetBuilder();
flatXmlDataSetBuilder.setColumnSensing(true);
return defineReplaceableExpressions(flatXmlDataSetBuilder.build(in));
} catch (final DataSetException e) {
throw new IOException(e);
}
};
}
示例10: initEntityManager
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void initEntityManager() throws HibernateException, DatabaseUnitException {
entityManagerFactory = Persistence.createEntityManagerFactory("com.infinities.keystone4j.jpa.test");
entityManager = entityManagerFactory.createEntityManager();
connection = new DatabaseConnection(((SessionImpl) (entityManager.getDelegate())).connection());
connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
FlatXmlDataSetBuilder flatXmlDataSetBuilder = new FlatXmlDataSetBuilder();
flatXmlDataSetBuilder.setColumnSensing(true);
InputStream dataSet = Thread.currentThread().getContextClassLoader().getResourceAsStream("test-data.xml");
dataset = flatXmlDataSetBuilder.build(dataSet);
EntityManagerListener.setEntityManagerFactory(entityManagerFactory);
}
示例11: createDataSet
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
@Override
protected IDataSet createDataSet(Resource resource) throws Exception {
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setColumnSensing(true);
try (InputStream inputStream = resource.getInputStream()) {
return builder.build(inputStream);
}
}
示例12: getDataSet
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
/**
* Load in a set of data from a (fixed for now) XML file
*
* @return data set to be provided to database tester (or used for
* comparison)
*/
public IDataSet getDataSet() throws DataSetException, IOException {
URL url = LoginDatabaseHandler.class.getClassLoader().getResource("LoginDatabaseHandlerTest.xml");
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setColumnSensing(true);
return builder.build(url);
}
示例13: getDataSet
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
/**
* Load in a set of data from a (fixed for now) XML file
*
* @return data set to be provided to database tester (or used for
* comparison)
*/
private IDataSet getDataSet() throws DataSetException, IOException {
URL url = DatabaseHandler.class.getClassLoader().getResource("DatabaseHandlerTest.xml");
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setColumnSensing(true);
return builder.build(url);
}
示例14: setUp
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
ds = UnitTestDSProvider.getDataSource();
//clean any existing records and load some records into the database.
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setColumnSensing(true);
Connection setup = ds.getConnection();
IDatabaseConnection con = new DatabaseConnection(setup);
{
InputStream xmlInput = DeviceDAOImplTest.class.getResourceAsStream("/data/pushmessage-data-1.xml");
IDataSet dataSet = builder.build(xmlInput);
DatabaseOperation.CLEAN_INSERT.execute(con, dataSet);
}
}
示例15: setupDB
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; //导入方法依赖的package包/类
@BeforeClass
public static void setupDB() throws Exception {
ds = UnitTestDSProvider.getDataSource();
//clean any existing records and load some records into the database.
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setColumnSensing(true);
Connection setup = ds.getConnection();
IDatabaseConnection con = new DatabaseConnection(setup);
{
InputStream xmlInput = DeviceDAOImplTest.class.getResourceAsStream("/data/app-data-1.xml");
IDataSet dataSet = builder.build(xmlInput);
DatabaseOperation.CLEAN_INSERT.execute(con, dataSet);
}
}