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


Java SortedTable类代码示例

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


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

示例1: compareDbToDataSet

import org.dbunit.dataset.SortedTable; //导入依赖的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); 
	}
}
 
开发者ID:daniel-a-melo,项目名称:jorm-unit,代码行数:24,代码来源:JPATest.java

示例2: assertDatabaseState

import org.dbunit.dataset.SortedTable; //导入依赖的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));
       }
}
 
开发者ID:P15,项目名称:jailer,代码行数:20,代码来源:DbmsAwareTestCase.java

示例3: assertEqualDatasets

import org.dbunit.dataset.SortedTable; //导入依赖的package包/类
/**
    * Asserts that the two database states are equal.
    * 
    * @param expectedState file name of dataset holding the expected state
    * @param actualState file name of dataset holding the actual state
    */
   @SuppressWarnings("deprecation")
protected void assertEqualDatasets(File expectedState, File actualState) throws Exception {
       IDataSet expected = new FlatXmlDataSet(expectedState, false, true);
       IDataSet actual = new FlatXmlDataSet(actualState, false, true);
       
       // compare tables
       for (ITable table: expected.getTables()) {
       	ITable actualTable = actual.getTable(table.getTableMetaData().getTableName());
       	Assertion.assertEquals(new SortedTable(table), new SortedTable(actualTable));
       }
}
 
开发者ID:P15,项目名称:jailer,代码行数:18,代码来源:DbmsAwareTestCase.java

示例4: checkResult

import org.dbunit.dataset.SortedTable; //导入依赖的package包/类
/**
 * Check if the content of the database as expected.
 *
 * @param expected the expected dataset.
 */
public void checkResult(final IDataSet expected) {
    try {
        final IDataSet actual =
                databaseTester.getConnection().createDataSet();
        final ITableIterator expectdTables = expected.iterator();
        while (expectdTables.next()) {
            final String tableName =
                    expectdTables.getTable().getTableMetaData()
                            .getTableName();
            final String[] uk = tableToUniqueKey.get(tableName);
            if (uk == null) {
                throw new IllegalStateException(
                        "You must define a unique-key for each table.");
            }
            final ITable expectedTable =
                    new SortedTable(expected.getTable(tableName), uk);
            final ITable actualTable =
                    new SortedTable(actual.getTable(tableName), uk);
            Assertion.assertEquals(expectedTable, actualTable,
                    new ValidatorFailureHandler());
        }
    } catch (Exception e) {
        throw new IllegalStateException("Error during checkResult", e);
    }

}
 
开发者ID:opensource21,项目名称:fuwesta,代码行数:32,代码来源:FuWeStaSampleDatabase.java

示例5: compareExpectedWithActual

import org.dbunit.dataset.SortedTable; //导入依赖的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();
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:72,代码来源:AbstractDBUnitUtil.java

示例6: sort

import org.dbunit.dataset.SortedTable; //导入依赖的package包/类
private ITable sort(final ITable table, final List<String> columnsForSorting) throws DataSetException {
    final SortedTable sortedTable = new SortedTable(table, columnsForSorting.toArray(new String[columnsForSorting.size()]));
    sortedTable.setUseComparable(true);
    return sortedTable;
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:6,代码来源:DataSetComparator.java


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