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


Java ITableIterator类代码示例

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


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

示例1: testLoadDataSet_lessColumnsLast

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
/**
   * Test the loading of a data set with 2 rows for a table, but the second
   * row has less columns than the first one.
   */
  @Test
  public void testLoadDataSet_lessColumnsLast() throws Exception {
      MultiSchemaDataSet result = multiSchemaXmlDataSetReader.readDataSetXml(toFile(getClass().getResource("LessColumnsLastDataSet.xml")));

      // there should be 1 dataset for the default schema A
      assertLenientEquals(new String[]{"SCHEMA_A"}, result.getSchemaNames());

      // the dataset should contain 2 tables with the same name
      IDataSet dataSet = result.getDataSetForSchema("SCHEMA_A");
      assertLenientEquals(new String[]{"TABLE_A"}, dataSet.getTableNames());
      assertEquals(2, dataSet.getTable("TABLE_A").getRowCount());
      ITableIterator tableIterator = dataSet.iterator();

      // first table TABLE_A row should contain 3 columns
      assertTrue(tableIterator.next());
      ITable table = tableIterator.getTable();
      assertEquals(2, table.getRowCount());
      assertPropertyLenientEquals("columnName", asList("COLUMN_1", "COLUMN_2", "COLUMN_3"), asList(table.getTableMetaData().getColumns()));
      assertEquals("1", table.getValue(0, "COLUMN_1"));
      assertEquals("2", table.getValue(0, "COLUMN_2"));
      assertEquals("3", table.getValue(0, "COLUMN_3"));
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:27,代码来源:MultiSchemaXmlDataSetReaderTest.java

示例2: testLoadDataSet_lessColumnsFirst

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
/**
 * Test the loading of a data set with 2 rows for a table, but the first
 * row has less columns than the second one.
 */
@Test
public void testLoadDataSet_lessColumnsFirst() throws Exception {
    MultiSchemaDataSet result = multiSchemaXmlDataSetReader.readDataSetXml(toFile(getClass().getResource("LessColumnsFirstDataSet.xml")));

    // there should be 1 dataset for the default schema A
    assertLenientEquals(new String[]{"SCHEMA_A"}, result.getSchemaNames());

    // the dataset should contain 2 tables with the same name
    IDataSet dataSet = result.getDataSetForSchema("SCHEMA_A");
    assertLenientEquals(new String[]{"TABLE_A"}, dataSet.getTableNames());
    assertEquals(2, dataSet.getTable("TABLE_A").getRowCount());
    ITableIterator tableIterator = dataSet.iterator();

    // first table TABLE_A row should contain 1 column
    assertTrue(tableIterator.next());
    ITable table = tableIterator.getTable();
    assertPropertyLenientEquals("columnName", asList("COLUMN_1", "COLUMN_2", "COLUMN_3"), asList(table.getTableMetaData().getColumns()));
    assertEquals(2, table.getRowCount());
    assertEquals("4", table.getValue(0, "COLUMN_2"));
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:25,代码来源:MultiSchemaXmlDataSetReaderTest.java

示例3: compareDbToDataSet

import org.dbunit.dataset.ITableIterator; //导入依赖的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

示例4: createIterator

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected ITableIterator createIterator(boolean reversed)
        throws DataSetException {
    if (logger.isDebugEnabled())
        logger.debug("createIterator(reversed={}) - start", String.valueOf(reversed));

    ITable[] tables = (ITable[]) _tables.orderedValues().toArray(new ITable[0]);
    return new DefaultTableIterator(tables, reversed);
}
 
开发者ID:sapientTest,项目名称:Sapient,代码行数:11,代码来源:XlsDataSet.java

示例5: execute

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
@Override
public void execute(IDatabaseConnection connection, IDataSet dataSet) throws DatabaseUnitException, SQLException {
    DatabaseConfig databaseConfig = connection.getConfig();
    IStatementFactory statementFactory = (IStatementFactory) databaseConfig.getProperty(DatabaseConfig.PROPERTY_STATEMENT_FACTORY);

    IBatchStatement statement = statementFactory.createBatchStatement(connection);
    try {
        int count = 0;

        ITableIterator iterator = dataSet.iterator();
        while (iterator.next()) {
            String tableName = iterator.getTableMetaData().getTableName();

            StringBuilder sql = new StringBuilder();
            sql.append("delete from ");
            sql.append(this.getQualifiedName(this.schema, tableName, connection));
            statement.addBatch(sql.toString());

            count++;
        }

        if (count > 0) {
            statement.executeBatch();
            statement.clearBatch();
        }
    } finally {
        statement.close();
    }
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:30,代码来源:SchemaSpecificDeleteAllOperation.java

示例6: verify

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
static void verify(ITableIterator actual, List<ITable> expected) throws Exception {
    List<ITable> actualTables = new LinkedList<>();
    while (actual.next()) {
        actualTables.add(actual.getTable());
    }
    new IterableVerifier<ITable>().verify(actualTables, expected);
}
 
开发者ID:classmethod,项目名称:cmtest,代码行数:8,代码来源:YamlDataSetTest.java

示例7: checkResult

import org.dbunit.dataset.ITableIterator; //导入依赖的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

示例8: printTableNames

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
/**
 * Print the tables in the order of the dependencies.
 *
 * @param conn the database-connection.
 * @throws DataSetException error in the dataset.
 * @throws SQLException error communicate with db.
 */
// //CSOFF: RegexpSinglelineJava It's only helper to dump something to
// console.
public static void printTableNames(IDatabaseConnection conn)
        throws DataSetException, SQLException {
    final ITableFilter filter = new DatabaseSequenceFilter(conn);
    final ITableIterator tables =
            filter.iterator(conn.createDataSet(), false);
    System.out.println("########### Database tables");
    while (tables.next()) {
        System.out.print("\"" + tables.getTableMetaData().getTableName()
                + "\", ");
    }
    System.out.println();
}
 
开发者ID:opensource21,项目名称:fuwesta,代码行数:22,代码来源:FuWeStaSampleDataSet.java

示例9: createIterator

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
@Override
protected ITableIterator createIterator(boolean reversed) throws DataSetException {
    return new ScriptableDataSetIterator(reversed ? delegate.reverseIterator() : delegate.iterator());
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:5,代码来源:ScriptableDataSet.java

示例10: ScriptableDataSetIterator

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
public ScriptableDataSetIterator(ITableIterator delegate) {
    this.delegate = delegate;
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:4,代码来源:ScriptableDataSetIterator.java

示例11: iterator

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
@Override
public ITableIterator iterator() throws DataSetException {
    return new DefaultTableIterator(getTables());
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:5,代码来源:YamlDataSet.java

示例12: reverseIterator

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
@Override
public ITableIterator reverseIterator() throws DataSetException {
    return new DefaultTableIterator(getTables(), true);
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:5,代码来源:YamlDataSet.java

示例13: createIterator

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
@Override
protected ITableIterator createIterator(boolean reversed) throws DataSetException {
    ITable[] t = new ITable[0];
    return new DefaultTableIterator(t, reversed);
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:6,代码来源:EmptyDataSet.java

示例14: createIterator

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected ITableIterator createIterator(boolean reversed) throws DataSetException {
    ITable[] t = (ITable[]) this.tables.orderedValues().toArray(new ITable[0]);
    return new DefaultTableIterator(t, reversed);
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:7,代码来源:BeanDataSet.java

示例15: createIterator

import org.dbunit.dataset.ITableIterator; //导入依赖的package包/类
@Override
protected ITableIterator createIterator(boolean reverse) throws DataSetException {
    return new DefaultTableIterator(tables.toArray(new ITable[tables.size()]));
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:5,代码来源:JSONDataSet.java


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