Java Code Examples for org.dbunit.dataset.xml.FlatXmlDataSetBuilder#build()

The following examples show how to use org.dbunit.dataset.xml.FlatXmlDataSetBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractRuleImplementationTestCase.java    From Asqatasun with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 2
Source File: SchemaUpgradeTestBase.java    From development with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: AbstractDaoTestCase.java    From Asqatasun with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Charge le jeu de données à partir d'un fichier XML d'import
 * @return 
 * @throws java.lang.Exception 
 */
@Override
protected IDataSet getDataSet() throws Exception {
    FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
    builder.setColumnSensing(true);
    ReplacementDataSet dataSet = new ReplacementDataSet(builder.build(new FileInputStream(
            getInputDataFileName())));
    dataSet.addReplacementObject("[NULL]", null);
    return dataSet;
}
 
Example 4
Source File: AbstractDaoTestCase.java    From Asqatasun with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Charge le jeu de données à partir d'un fichier XML d'import
 */
@Override
protected IDataSet getDataSet() throws Exception {
    FlatXmlDataSetBuilder flatXmlDataSetBuilder = new FlatXmlDataSetBuilder();
    FlatXmlDataSet loadedDataSet = flatXmlDataSetBuilder.build(new FileInputStream(
            getInputDataFileName()));
    return loadedDataSet;

}
 
Example 5
Source File: DbUnitSupport.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public IDataSet loadFlatXmlDataStream(Class<?> c, String resource, boolean resetDtdSchema) throws Exception {
        FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
        builder.setMetaDataSetFromDtd(getDtdSchema(resetDtdSchema));
//        builder.setMetaDataSet(getConnection().createDataSet());
        FlatXmlDataSet fds = builder.build(getResourceStream(c, resource));
        return fds;
    }
 
Example 6
Source File: AbstractModelTest.java    From pnc with Apache License 2.0 5 votes vote down vote up
/**
 * Inserts data into database from the dbunit XML file
 * 
 * @param em Entity manager
 * @param datasetPath Path to DBunit dataset file
 * @throws Exception Thrown in case of any error during the operation
 */
protected void initDatabaseUsingDataset(EntityManager em, String datasetPath) throws Exception {
    IDatabaseConnection connection = new DatabaseConnection(em.unwrap(SessionImpl.class).connection());
    connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
    FlatXmlDataSetBuilder flatXmlDataSetBuilder = new FlatXmlDataSetBuilder();
    flatXmlDataSetBuilder.setColumnSensing(true);
    InputStream dataSetStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(datasetPath);
    IDataSet dataSet = flatXmlDataSetBuilder.build(dataSetStream);
    DatabaseOperation.INSERT.execute(connection, dataSet);
}
 
Example 7
Source File: ColumnDetectorXmlDataSetLoader.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected IDataSet createDataSet(Resource resource) throws Exception {
    FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
    builder.setColumnSensing(true);
    InputStream inputStream = resource.getInputStream();
    try {
        return builder.build(inputStream);
    } finally {
        inputStream.close();
    }
}
 
Example 8
Source File: DBUnitTestExecutionListener.java    From flyway-test-extensions with Apache License 2.0 4 votes vote down vote up
private FlatXmlDataSet getFileDataSet(final InputStream is)
		throws Exception {

	final FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
	return builder.build(is);
}