本文整理汇总了Java中org.dbunit.dataset.IDataSet.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java IDataSet.iterator方法的具体用法?Java IDataSet.iterator怎么用?Java IDataSet.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dbunit.dataset.IDataSet
的用法示例。
在下文中一共展示了IDataSet.iterator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadDataSet_lessColumnsLast
import org.dbunit.dataset.IDataSet; //导入方法依赖的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"));
}
示例2: testLoadDataSet_lessColumnsFirst
import org.dbunit.dataset.IDataSet; //导入方法依赖的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"));
}