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


Java ITable类代码示例

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


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

示例1: testLoadDataSet_lessColumnsLast

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

import org.dbunit.dataset.ITable; //导入依赖的package包/类
private List<String> extractColumnsToBeIgnored(final ITable expectedTableState, final ITable currentTableState)
        throws DataSetException {
    final List<String> columnsToIgnore = extractNotExpectedColumnNames(expectedTableState, currentTableState);
    final String tableName = expectedTableState.getTableMetaData().getTableName();

    columnsToIgnore.addAll(toExclude.getColumns(tableName));

    final List<String> nonExistingColumns = new ArrayList<>(columnsToIgnore);
    nonExistingColumns.removeAll(extractColumnNames(currentTableState.getTableMetaData().getColumns()));

    if (!nonExistingColumns.isEmpty()) {
        LOG.debug("Columns which are specified to be filtered out {} are not existing in the table {}",
                Arrays.toString(nonExistingColumns.toArray()), tableName);
    }
    return columnsToIgnore;
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:17,代码来源:DataSetComparator.java

示例4: testJsonLoaderLoadUsingProperResource

import org.dbunit.dataset.ITable; //导入依赖的package包/类
@Test
public void testJsonLoaderLoadUsingProperResource() throws Exception {
    // WHEN
    final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.jsonLoader();

    // THEN
    assertThat(loader, notNullValue());

    // WHEN
    final IDataSet dataSet = loader.load(getFile("test-data.json"));

    // THEN
    assertThat(dataSet, notNullValue());

    final List<String> tableNames = Arrays.asList(dataSet.getTableNames());
    assertThat(tableNames.size(), equalTo(2));
    assertThat(tableNames, hasItems("JSON_TABLE_1", "JSON_TABLE_2"));

    final ITable table1 = dataSet.getTable("JSON_TABLE_1");
    assertThat(table1.getRowCount(), equalTo(3));

    final ITable table2 = dataSet.getTable("JSON_TABLE_2");
    assertThat(table2.getRowCount(), equalTo(1));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:25,代码来源:DataSetLoaderProviderTest.java

示例5: testYamlLoaderLoadUsingProperResource

import org.dbunit.dataset.ITable; //导入依赖的package包/类
@Test
public void testYamlLoaderLoadUsingProperResource() throws Exception {
    // WHEN
    final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.yamlLoader();

    // THEN
    assertThat(loader, notNullValue());

    // WHEN
    final IDataSet dataSet = loader.load(getFile("test-data.yaml"));

    // THEN
    assertThat(dataSet, notNullValue());

    final List<String> tableNames = Arrays.asList(dataSet.getTableNames());
    assertThat(tableNames.size(), equalTo(2));
    assertThat(tableNames, hasItems("YAML_TABLE_1", "YAML_TABLE_2"));

    final ITable table1 = dataSet.getTable("YAML_TABLE_1");
    assertThat(table1.getRowCount(), equalTo(3));

    final ITable table2 = dataSet.getTable("YAML_TABLE_2");
    assertThat(table2.getRowCount(), equalTo(1));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:25,代码来源:DataSetLoaderProviderTest.java

示例6: testXmlLoaderLoadUsingProperResource

import org.dbunit.dataset.ITable; //导入依赖的package包/类
@Test
public void testXmlLoaderLoadUsingProperResource() throws Exception {
    // WHEN
    final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.xmlLoader();

    // THEN
    assertThat(loader, notNullValue());

    // WHEN
    final IDataSet dataSet = loader.load(getFile("test-data.xml"));

    // THEN
    assertThat(dataSet, notNullValue());

    final List<String> tableNames = Arrays.asList(dataSet.getTableNames());
    assertThat(tableNames.size(), equalTo(2));
    assertThat(tableNames, hasItems("XML_TABLE_1", "XML_TABLE_2"));

    final ITable table1 = dataSet.getTable("XML_TABLE_1");
    assertThat(table1.getRowCount(), equalTo(3));

    final ITable table2 = dataSet.getTable("XML_TABLE_2");
    assertThat(table2.getRowCount(), equalTo(1));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:25,代码来源:DataSetLoaderProviderTest.java

示例7: file

import org.dbunit.dataset.ITable; //导入依赖的package包/类
@Test
@Ignore("Somehow the given zip file (xlsx) is invalid, even Excel opens it without issues")
public void testXlsxLoaderLoadUsingProperResource() throws Exception {
    // WHEN
    final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.xlsLoader();

    // THEN
    assertThat(loader, notNullValue());

    // WHEN
    final IDataSet dataSet = loader.load(getFile("test-data.xlsx"));

    // THEN
    assertThat(dataSet, notNullValue());

    final List<String> tableNames = Arrays.asList(dataSet.getTableNames());
    assertThat(tableNames.size(), equalTo(2));
    assertThat(tableNames, hasItems("XLS_TABLE_1", "XLS_TABLE_2"));

    final ITable table1 = dataSet.getTable("XLS_TABLE_1");
    assertThat(table1.getRowCount(), equalTo(3));

    final ITable table2 = dataSet.getTable("XLS_TABLE_2");
    assertThat(table2.getRowCount(), equalTo(1));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:26,代码来源:DataSetLoaderProviderTest.java

示例8: testCsvLoaderLoadUsingProperResource

import org.dbunit.dataset.ITable; //导入依赖的package包/类
@Test
public void testCsvLoaderLoadUsingProperResource() throws Exception {
    // WHEN
    final DataSetLoader<IDataSet> loader = LOADER_PROVIDER.csvLoader();

    // THEN
    assertThat(loader, notNullValue());

    // WHEN
    final IDataSet dataSet = loader.load(getFile("test-data"));

    // THEN
    assertThat(dataSet, notNullValue());

    final List<String> tableNames = Arrays.asList(dataSet.getTableNames());
    assertThat(tableNames.size(), equalTo(2));
    assertThat(tableNames, hasItems("CSV_TABLE_1", "CSV_TABLE_2"));

    final ITable table1 = dataSet.getTable("CSV_TABLE_1");
    assertThat(table1.getRowCount(), equalTo(3));

    final ITable table2 = dataSet.getTable("CSV_TABLE_2");
    assertThat(table2.getRowCount(), equalTo(1));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:25,代码来源:DataSetLoaderProviderTest.java

示例9: getTables

import org.dbunit.dataset.ITable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public List<ITable> getTables(InputStream jsonStream) {
    List<ITable> rtables = new ArrayList<ITable>();

    Map<String, Object> dataset = mapper.fromJson(new InputStreamReader(jsonStream), Map.class);

    for (Map.Entry<String, Object> entry : dataset.entrySet()) {
        List<Map<String, Object>> rows = (List<Map<String, Object>>) entry.getValue();
        ITableMetaData meta = getMetaData(entry.getKey(), rows);
        DefaultTable table = new DefaultTable(meta);
        int rowIndex = 0;
        for (Map<String, Object> row : rows) {
            fillRow(table, row, rowIndex++);
        }
        rtables.add(table);
    }

    return rtables;
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:20,代码来源:JSONDataSet.java

示例10: commonTest

import org.dbunit.dataset.ITable; //导入依赖的package包/类
private void commonTest() throws Exception {
    assertFalse(DATABASE.getConnection().isClosed());

    ResultSet rs = DATABASE.executeQuery("select * from `customer` where id = 325");
    assertTrue(rs.next());
    assertEquals(null, rs.getString("initial"));

    DATABASE.executeUpdate("update customer set last_name='Bloggs' where id=325");

    ResultSet rs2 = DATABASE.executeQuery("select * from `customer` where id = 325");
    assertTrue(rs2.next());
    assertEquals(null, rs2.getString("initial"));
    assertEquals("Bloggs", rs2.getString("last_name"));

    ITable actualTable =
            DATABASE.createQueryTable("customer", "select * from customer order by id");

    ITable expectedTable = DATABASE.readFileToDataSet(
            new File(this.getClass().getResource("customer-updated.flat.xml").getFile())
            ).getTable("customer");
    Assertion.assertEquals(expectedTable, actualTable);
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:23,代码来源:TestH2DBMock.java

示例11: testVersionQuery

import org.dbunit.dataset.ITable; //导入依赖的package包/类
@Test
public void testVersionQuery() throws Exception {
    String expectVersion = KylinVersion.getCurrentVersion().toString();
    logger.info("---------- verify expect version: " + expectVersion);

    String queryName = "QueryKylinVersion";
    String sql = "SELECT VERSION() AS version";

    // execute Kylin
    logger.info("Query Result from Kylin - " + queryName);
    IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection);
    ITable kylinTable = executeQuery(kylinConn, queryName, sql, false);
    String queriedVersion = String.valueOf(kylinTable.getValue(0, "version"));

    // compare the result
    Assert.assertEquals(expectVersion, queriedVersion);
}
 
开发者ID:apache,项目名称:kylin,代码行数:18,代码来源:ITKylinQueryTest.java

示例12: run

import org.dbunit.dataset.ITable; //导入依赖的package包/类
protected void run(String queryFolder, String[] exclusiveQuerys, boolean needSort) throws Exception {
    logger.info("---------- test folder: " + queryFolder);
    Set<String> exclusiveSet = buildExclusiveSet(exclusiveQuerys);

    List<File> sqlFiles = getFilesFromFolder(new File(queryFolder), ".sql");
    for (File sqlFile : sqlFiles) {
        String queryName = StringUtils.split(sqlFile.getName(), '.')[0];
        if (exclusiveSet.contains(queryName)) {
            continue;
        }
        String sql = getTextFromFile(sqlFile);

        // execute Kylin
        logger.info("Query Result from Kylin - " + queryName + "  (" + queryFolder + ")");
        IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection);
        ITable kylinTable = executeQuery(kylinConn, queryName, sql, needSort);
        printResult(kylinTable);

    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:21,代码来源:ITMassInQueryTest.java

示例13: printResult

import org.dbunit.dataset.ITable; //导入依赖的package包/类
protected static void printResult(ITable resultTable) throws DataSetException {
    StringBuilder sb = new StringBuilder();

    int columnCount = resultTable.getTableMetaData().getColumns().length;
    String[] columns = new String[columnCount];

    for (int i = 0; i < columnCount; i++) {
        sb.append(resultTable.getTableMetaData().getColumns()[i].getColumnName());
        sb.append("-");
        sb.append(resultTable.getTableMetaData().getColumns()[i].getDataType());
        sb.append("\t");
        columns[i] = resultTable.getTableMetaData().getColumns()[i].getColumnName();
    }
    sb.append("\n");

    for (int i = 0; i < resultTable.getRowCount(); i++) {
        for (int j = 0; j < columns.length; j++) {
            sb.append(resultTable.getValue(i, columns[j]));
            sb.append("\t");
        }
        sb.append("\n");
    }
    System.out.println(sb.toString());
}
 
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:KylinTestBase.java

示例14: verifyResultContent

import org.dbunit.dataset.ITable; //导入依赖的package包/类
protected void verifyResultContent(String queryFolder) throws Exception {
    logger.info("---------- verify result content in folder: " + queryFolder);

    List<File> sqlFiles = getFilesFromFolder(new File(queryFolder), ".sql");
    for (File sqlFile : sqlFiles) {
        String queryName = StringUtils.split(sqlFile.getName(), '.')[0];
        String sql = getTextFromFile(sqlFile);

        File expectResultFile = new File(sqlFile.getParent(), sqlFile.getName() + ".expected.xml");
        IDataSet expect = new FlatXmlDataSetBuilder().build(expectResultFile);
        // Get expected table named "expect". FIXME Only support default table name
        ITable expectTable = expect.getTable("expect");

        // execute Kylin
        logger.info("Query Result from Kylin - " + queryName + "  (" + queryFolder + ")");
        IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection);
        ITable kylinTable = executeQuery(kylinConn, queryName, sql, false);

        // compare the result
        assertTableEquals(expectTable, kylinTable);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:23,代码来源:KylinTestBase.java

示例15: execAndCompColumnCount

import org.dbunit.dataset.ITable; //导入依赖的package包/类
protected void execAndCompColumnCount(String input, int expectedColumnCount) throws Exception {
    logger.info("---------- test column count: " + input);
    Set<String> sqlSet = ImmutableSet.of(input);

    for (String sql : sqlSet) {
        // execute Kylin
        logger.info("Query Result from Kylin - " + sql);
        IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection);
        ITable kylinTable = executeQuery(kylinConn, sql, sql, false);

        try {
            // compare the result
            Assert.assertEquals(expectedColumnCount, kylinTable.getTableMetaData().getColumns().length);
        } catch (Throwable t) {
            logger.info("execAndCompColumnCount failed on: " + sql);
            throw t;
        }
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:20,代码来源:KylinTestBase.java


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