本文整理汇总了Java中org.unitils.dbunit.annotation.DataSet.databaseName方法的典型用法代码示例。如果您正苦于以下问题:Java DataSet.databaseName方法的具体用法?Java DataSet.databaseName怎么用?Java DataSet.databaseName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.unitils.dbunit.annotation.DataSet
的用法示例。
在下文中一共展示了DataSet.databaseName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertDataSets
import org.unitils.dbunit.annotation.DataSet; //导入方法依赖的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);
}
}
}
}
示例2: getDataSet
import org.unitils.dbunit.annotation.DataSet; //导入方法依赖的package包/类
/**
* Using the values of the method-level or class-level {@link DataSet} annotations, returns the data set for the given test method. If
* no method-level or class-level {@link DataSet} annotation is found, null is returned. If a method-level {@link DataSet} annotation is
* found this will be used, else the class-level will be used.
* <p/>
* The value of the found annotation determines which files need to be used for the dataset. If one or more filenames are explicitly
* specified, these names will be used. Filenames that start with '/' are treated absolute. Filenames that do not start with '/', are
* relative to the current class. If an empty filename ("") is specified, this method will look for a file named 'classname'.xml.
* {@link #getDefaultDataSetFileName}).
* <p/>
* If a file is not found or could not be loaded (but was requested, because there is an annotation), an exception is thrown.
*
* @param testMethod The test method, not null
* @param testObject The test object, not null
* @return The dataset, null if no {@link DataSet} annotation is found.
*/
public MultiSchemaDataSet getDataSet(DataSet dataSet, Method testMethod, Class<?> testClass) {
databaseName = dataSet.databaseName();
// Create configured factory for data sets
DataSetFactory dataSetFactory = getDataSetFactory(DataSet.class, testMethod, testClass);
// Get the dataset file name
String[] dataSetFileNames = dataSet.value();
if (dataSetFileNames.length == 0) {
// empty means, use default file name, which is the name of the class + extension
dataSetFileNames = new String[]{
createDataSetFileNamesHandler().getDefaultDatasetBasedOnFilename(testClass, testMethod, dataSetFactory.getDataSetFileExtension())
};
}
return getDataSet(testClass, dataSetFileNames, dataSetFactory);
}