當前位置: 首頁>>代碼示例>>Java>>正文


Java IDataSet.iterator方法代碼示例

本文整理匯總了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"));
}
 
開發者ID:linux-china,項目名稱:unitils,代碼行數:27,代碼來源:MultiSchemaXmlDataSetReaderTest.java

示例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"));
}
 
開發者ID:linux-china,項目名稱:unitils,代碼行數:25,代碼來源:MultiSchemaXmlDataSetReaderTest.java


注:本文中的org.dbunit.dataset.IDataSet.iterator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。