本文整理汇总了Java中org.dbunit.dataset.filter.DefaultColumnFilter类的典型用法代码示例。如果您正苦于以下问题:Java DefaultColumnFilter类的具体用法?Java DefaultColumnFilter怎么用?Java DefaultColumnFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultColumnFilter类属于org.dbunit.dataset.filter包,在下文中一共展示了DefaultColumnFilter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareDbToDataSet
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入依赖的package包/类
private void compareDbToDataSet(String filename) throws Exception
{
IDataSet afterActualDataSet = getDbUnitconnection().createDataSet();
IDataSet afterExpectedDataSet = loadDataSet(filename);
ITableIterator iter = afterActualDataSet.iterator();
while (iter.next()) {
ITable actualTable = iter.getTable();
ITable expectedTable = afterExpectedDataSet.getTable(actualTable.getTableMetaData().getTableName());
Column[] expectedColumns = expectedTable.getTableMetaData().getColumns();
//Expected table will be sorted by the columns present on expected file
ITable sortedExpectedTable = new SortedTable(expectedTable, expectedColumns);
//Actual table will be sorted by the columns present on *expected* file.
//It will be also filtered to only include tables present on expected file
ITable filteredActualTable = DefaultColumnFilter.includedColumnsTable(actualTable, expectedColumns);
ITable sortedFilteredActualTable = new SortedTable(filteredActualTable, expectedColumns);
Assertion.assertEquals(sortedExpectedTable, sortedFilteredActualTable);
}
}
示例2: assertDatabaseState
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入依赖的package包/类
/**
* Asserts that the database is in a given state.
*
* @param expectedState file name of dataset holding the expected state
*/
@SuppressWarnings("deprecation")
protected void assertDatabaseState(String expectedState) throws Exception {
// Fetch database data after executing your code
IDataSet databaseDataSet = getConnection().createDataSet();
IDataSet initialDataSet = new FlatXmlDataSet(new File(expectedState), false, true);
// compare tables
for (ITable table: initialDataSet.getTables()) {
ITable actualTable = databaseDataSet.getTable(table.getTableMetaData().getTableName());
ITable filteredTable = DefaultColumnFilter.includedColumnsTable(actualTable,
table.getTableMetaData().getColumns());
Assertion.assertEquals(new SortedTable(table), new SortedTable(filteredTable));
}
}
示例3: assertTableEquals
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入依赖的package包/类
protected void assertTableEquals( Class peristentClass, String[] includedFields, IDataSet dataset ) throws Exception
{
// Fetch database data after executing your code
IDataSet databaseDataSet = getConnection().createDataSet();
ITable actualTable = databaseDataSet.getTable( getTableName( peristentClass ) );
ITable actualData = DefaultColumnFilter.includedColumnsTable( actualTable, getColumnNames( peristentClass, includedFields ) );
// Load expected data from an XML dataset
ITable expectedTable = dataset.getTable( getTableName( peristentClass ) );
ITable expectedData = DefaultColumnFilter.includedColumnsTable( expectedTable, getColumnNames( peristentClass, includedFields ) );
// Assert actual database table match expected table
Assertion.assertEquals( expectedData, actualData );
}
示例4: assertTableEquals
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入依赖的package包/类
protected void assertTableEquals(Class<?> peristentClass, String[] includedFields, IDataSet dataset) throws Exception {
// Fetch database data after executing your code
IDataSet databaseDataSet = getConnection().createDataSet();
ITable actualTable = databaseDataSet.getTable(getTableName(peristentClass));
ITable actualData =
DefaultColumnFilter.includedColumnsTable(actualTable, getColumnNames(peristentClass, includedFields));
// Load expected data from an XML dataset
ITable expectedTable = dataset.getTable(getTableName(peristentClass));
ITable expectedData =
DefaultColumnFilter.includedColumnsTable(expectedTable, getColumnNames(peristentClass, includedFields));
// Assert actual database table match expected table
Assertion.assertEquals(expectedData, actualData);
}
开发者ID:testIT-LivingDoc,项目名称:livingdoc-confluence,代码行数:16,代码来源:AbstractDBUnitHibernateMemoryTest.java
示例5: assertTableContent
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入依赖的package包/类
protected void assertTableContent(IDataSet expectedDataSet, String tableName, String[] excludedColumns) throws SQLException, Exception {
IDataSet actualDataSet = getConnection().createDataSet();
ITable expectedTable = expectedDataSet.getTable(tableName);
ITable actualTable = actualDataSet.getTable(tableName);
if (excludedColumns != null) {
expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, excludedColumns);
actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, excludedColumns);
}
Assertion.assertEquals(expectedTable, actualTable);
}
示例6: compareExpectedWithActual
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入依赖的package包/类
/**
* Vergelijkt een actuele dataset met de verwachte dataset. Alle records in de verwachte dataset dienen ook voor te
* komen in de actuele dataset. Tabellen die niet in de expected set voorkomen worden genegeerd.
* <p>
* @param expected De expected dataset.
* @throws DatabaseUnitException on error
* @throws SQLException on error
*/
protected void compareExpectedWithActual(final IDataSet expected) throws SQLException, DatabaseUnitException {
if (expected == null) {
throw new IllegalArgumentException("Argument 'expected' is null");
}
final IDatabaseConnection connection = createConnection();
try {
final IDataSet actual = createActualSet(connection);
final String[] expTableNames = expected.getTableNames();
for (final String currentTableName : expTableNames) {
// prepareer verwachtte tabel
final ITable expTable = expected.getTable(currentTableName);
final Column[] columnsExp = expTable.getTableMetaData().getColumns();
// Zoek naar kolommen met waarde: [NOTNULLCHECK] zodat deze geexclude worden. Deze worden later per rij
// gecontroleerd
final Set<String> excludeButNotEmptyColumnsSet = new HashSet<>();
final Map<Integer, String> excludeButNotEmptyColumns = new HashMap<>();
for (final Column column : columnsExp) {
for (int i = 0; i < expTable.getRowCount(); i++) {
final Object value = expTable.getValue(i, column.getColumnName());
if (value != null && value.toString().equals("[NOTNULLCHECK]")) {
excludeButNotEmptyColumnsSet.add(column.getColumnName());
excludeButNotEmptyColumns.put(i, column.getColumnName());
}
}
}
final String[] excludeButNotEmptyColumnsArray = excludeButNotEmptyColumnsSet.toArray(new String[0]);
final ITable filteredTableExp = DefaultColumnFilter.excludedColumnsTable(expTable, excludeButNotEmptyColumnsArray);
final ITable sortedExp = new SortedTable(filteredTableExp);
final ITable currentTimestampColumnFilteredExp = new ColumnFilterTable(sortedExp, new CurrentTimestampColumnFilter());
// prepareer actuele tabel
final ITable actTable = actual.getTable(currentTableName);
final ITable filteredTable = DefaultColumnFilter.excludedColumnsTable(actTable, excludeButNotEmptyColumnsArray);
final ITable sortedActTable = new SortedTable(filteredTable);
final ITable primaryKeyFilteredActTable = new RowFilterTable(sortedActTable, new PrimaryKeyRowFilter(expTable));
final ITable currentTimestampRowFilteredActTable = new RowFilterTable(primaryKeyFilteredActTable, new CurrentTimestampRowFilter(expTable));
final ITable currentTimestampColumnFilteredActTable =
new ColumnFilterTable(currentTimestampRowFilteredActTable, new CurrentTimestampColumnFilter());
try {
ASSERT.assertEquals(currentTimestampColumnFilteredExp, currentTimestampColumnFilteredActTable);
if (excludeButNotEmptyColumns.size() > 0) {
for (int rij = 0; rij < actTable.getRowCount(); rij++) {
final String excludeColumName = excludeButNotEmptyColumns.get(rij);
if (excludeColumName != null && actTable.getValue(rij, excludeColumName) == null) {
LOG.error("****** NotNullCheck column was leeg in actual result: " + excludeColumName);
throw new AssertionFailedError();
}
}
}
} catch (final AssertionFailedError assertionError) {
LOG.error("****** De volgende records zijn aangetroffen in de database:");
LOG.error(FORMATTER.format(sortedActTable));
LOG.error("****** Terwijl minimaal de volgende EXPECTED records verwacht worden:");
LOG.error(FORMATTER.format(sortedExp));
throw assertionError;
}
}
} finally {
connection.close();
}
}
示例7: filter
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入依赖的package包/类
private ITable filter(final ITable table, final String[] columnsToFilter) throws DataSetException {
final ITable filteredTable = DefaultColumnFilter.excludedColumnsTable(table, columnsToFilter);
return applyCustomFilters(filteredTable);
}
示例8: assertEquals
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入依赖的package包/类
/**
* Convenience method for asserting equality between two tables, only considering the columns in the expected
* dataset.
*
* @param expected
* the expected dataset
* @param actual
* the actual dataset
* @throws DatabaseUnitException
* on DbUnit exceptions
*/
public void assertEquals(ITable expected, ITable actual) throws DatabaseUnitException {
ITable actualFiltered = DefaultColumnFilter.includedColumnsTable(actual, expected.getTableMetaData().getColumns());
Assertion.assertEquals(expected, actualFiltered);
}