当前位置: 首页>>代码示例>>Java>>正文


Java DataSetFactory类代码示例

本文整理汇总了Java中org.unitils.dbunit.datasetfactory.DataSetFactory的典型用法代码示例。如果您正苦于以下问题:Java DataSetFactory类的具体用法?Java DataSetFactory怎么用?Java DataSetFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataSetFactory类属于org.unitils.dbunit.datasetfactory包,在下文中一共展示了DataSetFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertExpectedDataSet

import org.unitils.dbunit.datasetfactory.DataSetFactory; //导入依赖的package包/类
public static void assertExpectedDataSet(final String... datasetFile) {
    TestContext testContext = Unitils.getInstance().getTestContext();
    ExpectedDataSet expectedDataSetAnnotation = new ExpectedDataSet() {

        @Override
        public Class<? extends Annotation> annotationType() {
            return ExpectedDataSet.class;
        }

        @Override
        public String[] value() {
            return datasetFile;
        }

        @Override
        public Class<? extends DataSetFactory> factory() {
            return null;
        }

        @Override
        public String databaseName() {
            return null;
        }
    };
    getDbUnitModule().assertExpectedDataSets(expectedDataSetAnnotation , testContext.getTestObject(), testContext.getTestMethod());
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:27,代码来源:DbUnitUnitils.java

示例2: getExpectedDataSet

import org.unitils.dbunit.datasetfactory.DataSetFactory; //导入依赖的package包/类
/**
 * Returns the {@link MultiSchemaDataSet} that represents the state of a number of database tables after the given <code>Method</code>
 * has been executed.
 *
 * @param testMethod The test method, not null
 * @param testObject The test object, not null
 * @return The dataset, null if there is no data set
 */
public MultiSchemaDataSet getExpectedDataSet(ExpectedDataSet expectedDataSetAnnotation, Method testMethod, Object testObject) {


    databaseName = expectedDataSetAnnotation.databaseName();

    // Create configured factory for data sets
    DataSetFactory dataSetFactory = getDataSetFactory(ExpectedDataSet.class, testMethod, testObject.getClass());

    // Get the dataset file name
    String[] dataSetFileNames = expectedDataSetAnnotation.value();
    if (dataSetFileNames.length == 0) {
        // empty means use default file name
        dataSetFileNames = new String[]{
            createDataSetFileNamesHandler().getDefaultExpectedDataSetFileName(testMethod, testObject.getClass(), dataSetFactory.getDataSetFileExtension())
        };
    }

    return getDataSet(testMethod.getDeclaringClass(), dataSetFileNames, dataSetFactory);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:28,代码来源:DbUnitModule.java

示例3: getDataSet

import org.unitils.dbunit.datasetfactory.DataSetFactory; //导入依赖的package包/类
/**
 * Creates the dataset for the given file. Filenames that start with '/' are treated absolute. Filenames that do not start with '/', are
 * relative to the current class.
 *
 * @param testClass The test class, not null
 * @param dataSetFileNames The names of the files, (start with '/' for absolute names), not null, not empty
 * @param dataSetFactory DataSetFactory responsible for creating the dataset file
 * @return The data set, null if the file does not exist
 */
protected MultiSchemaDataSet getDataSet(Class<?> testClass, String[] dataSetFileNames, DataSetFactory dataSetFactory) {
    List<File> dataSetFiles = new ArrayList<File>();

    ResourcePickingStrategie resourcePickingStrategie = getResourcePickingStrategie();

    for (String dataSetFileName : dataSetFileNames) {
        File dataSetFile = createDataSetFileNamesHandler().locateResource(new ClassPathDataLocator(), dataSetFileName, resourcePickingStrategie, testClass);
        dataSetFiles.add(dataSetFile);
    }

    logger.info("Loading DbUnit data set. File names: " + dataSetFiles);
    MultiSchemaDataSet dataSet = dataSetFactory.createDataSet(dataSetFiles.toArray(new File[dataSetFiles.size()]));
    getFileHandler().deleteFiles(dataSetFiles);
    return dataSet;
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:25,代码来源:DbUnitModule.java

示例4: insertDefaultDataSet

import org.unitils.dbunit.datasetfactory.DataSetFactory; //导入依赖的package包/类
/**
 * Inserts the default dataset for the given test class into the database
 *
 * @param testClass The test class for which the default dataset must be loaded
 */
public void insertDefaultDataSet(Class<?> testClass) {
    DataSetFactory dataSetFactory = getDefaultDataSetFactory();
    String[] dataSetFileNames = new String[]{
        createDataSetFileNamesHandler().getDefaultDataSetFileNameClassLevel(testClass, dataSetFactory.getDataSetFileExtension())
    };
    insertDataSet(testClass, dataSetFileNames);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:13,代码来源:DbUnitModule.java

示例5: insertDataSet

import org.unitils.dbunit.datasetfactory.DataSetFactory; //导入依赖的package包/类
/**
 * Inserts the dataset consisting of the given list of files into the database
 *
 * @param testClass The test class for which the dataset must be loaded
 * @param dataSetFileNames The names of the files that define the test data
 */
public void insertDataSet(Class<?> testClass, String... dataSetFileNames) {
    DataSetFactory dataSetFactory = getDefaultDataSetFactory();
    DataSetLoadStrategy dataSetLoadStrategy = getDefaultDataSetLoadStrategy();
    MultiSchemaDataSet dataSet = getDataSet(testClass, dataSetFileNames, dataSetFactory);
    insertDataSet(dataSet, dataSetLoadStrategy);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:13,代码来源:DbUnitModule.java

示例6: insertDataSets

import org.unitils.dbunit.datasetfactory.DataSetFactory; //导入依赖的package包/类
public void insertDataSets(DataSets dataSets, Object testObject, Method testMethod) {
    Map<String, List<DataSet>> sortedDataSets = getDataSetsSorted(dataSets);
    for (List<DataSet> tempDataSets : sortedDataSets.values()) {
        boolean cleanLoadStrategy = false;
        for (final DataSet dataSet : tempDataSets) {
            DataSetLoadStrategy loadStrategy = getDataSetLoadStrategy(testMethod, testObject.getClass(), dataSet);
            if (loadStrategy instanceof CleanInsertLoadStrategy && !cleanLoadStrategy) {
                cleanLoadStrategy = true;
                insertDataSet(dataSet, testObject, testMethod);
            } else if (loadStrategy instanceof CleanInsertLoadStrategy && cleanLoadStrategy) {
                DataSet newDataSet = new DataSet() {

                    @Override
                    public Class<? extends Annotation> annotationType() {
                        return dataSet.annotationType();
                    }

                    @Override
                    public String[] value() {
                        return dataSet.value();
                    }

                    @Override
                    public Class<? extends DataSetLoadStrategy> loadStrategy() {
                        return InsertLoadStrategy.class;
                    }

                    @Override
                    public Class<? extends DataSetFactory> factory() {
                        return dataSet.factory();
                    }

                    @Override
                    public String databaseName() {
                        return dataSet.databaseName();
                    }
                };
                insertDataSet(newDataSet, testObject, testMethod);
            } else {
                insertDataSet(dataSet, testObject, testMethod);
            }
        }
    }


}
 
开发者ID:linux-china,项目名称:unitils,代码行数:47,代码来源:DbUnitModule.java

示例7: getDefaultDataSetFactory

import org.unitils.dbunit.datasetfactory.DataSetFactory; //导入依赖的package包/类
/**
 * @return The default {@link DataSetFactory} class as configured in unitils
 */
protected DataSetFactory getDefaultDataSetFactory() {
    Class<? extends DataSetFactory> dataSetFactoryClass = getClassWithName(getAnnotationPropertyDefault(DbUnitModule.class, DataSet.class, "factory", configuration));
    return getDataSetFactory(dataSetFactoryClass);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:8,代码来源:DbUnitModule.java

示例8: getDataSetFactory

import org.unitils.dbunit.datasetfactory.DataSetFactory; //导入依赖的package包/类
/**
 * Get the configured DataSetFactory for the given method
 *
 * @param annotationClass The class of the annotation, i.e. DataSet.class or ExpectedDataSet.class
 * @param testMethod The method for which we need the configured DataSetFactory
 * @param testClass The class that is looked for class-level annotations
 * @return The configured DataSetFactory
 */
@SuppressWarnings("unchecked")
protected DataSetFactory getDataSetFactory(Class<? extends Annotation> annotationClass, Method testMethod, Class<?> testClass) {
    Class<? extends DataSetFactory> dataSetFactoryClass = getMethodOrClassLevelAnnotationProperty(annotationClass, "factory", DataSetFactory.class, testMethod, testClass);
    dataSetFactoryClass = (Class<? extends DataSetFactory>) getClassValueReplaceDefault(annotationClass, "factory", dataSetFactoryClass, defaultAnnotationPropertyValues, DataSetFactory.class);
    return getDataSetFactory(dataSetFactoryClass);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:15,代码来源:DbUnitModule.java

示例9: insertDataSet

import org.unitils.dbunit.datasetfactory.DataSetFactory; //导入依赖的package包/类
/**
 * Inserts the test data coming from the given DbUnit dataset file.
 *
 * @param dataSetFile              The test data set, not null
 * @param dataSetFactoryClass      The class of the factory that must be used to read this dataset
 * @param dataSetLoadStrategyClass The class of the load strategy that must be used to load this dataset
 */
public static void insertDataSet(File dataSetFile, Class<? extends DataSetFactory> dataSetFactoryClass, Class<? extends DataSetLoadStrategy> dataSetLoadStrategyClass) {
    getDbUnitModule().insertDataSet(dataSetFile, dataSetFactoryClass, dataSetLoadStrategyClass);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:11,代码来源:DbUnitUnitils.java


注:本文中的org.unitils.dbunit.datasetfactory.DataSetFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。