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


Java ITableMetaData类代码示例

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


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

示例1: createTableMetaData

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
private ITableMetaData createTableMetaData() throws DataSetException {
    if (beans.isEmpty()) {
        return new DefaultTableMetaData(tableName, new Column[0]);
    } else {
        try {
            List<Column> columns = new ArrayList<Column>();
            BeanInfo info = Introspector.getBeanInfo(beans.get(0).getClass());
            PropertyDescriptor[] descs = info.getPropertyDescriptors();
            for (PropertyDescriptor desc : descs) {
                if (!isIgnoreProperty(desc)) {
                    System.out.println(desc.getName());
                    columns.add(new Column(desc.getName(), DataType.UNKNOWN));
                }
            }

            Column[] c = (Column[]) columns.toArray(new Column[columns.size()]);
            return new DefaultTableMetaData(tableName, c);
        } catch (IntrospectionException e) {
            throw new DataSetException(e);
        }
    }
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:23,代码来源:BeanTable.java

示例2: testProduceDataSetFromEmptyFile

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
@Test
public void testProduceDataSetFromEmptyFile() throws DataSetException {
    // GIVEN
    final IDataSetConsumer consumer = mock(IDataSetConsumer.class);
    final IDataSetProducer producer = new YamlDataSetProducer(emptyStream);
    producer.setConsumer(consumer);

    // WHEN
    producer.produce();

    // THEN
    verify(consumer).startDataSet();

    verify(consumer, times(0)).startTable(any(ITableMetaData.class));
    verify(consumer, times(0)).row(any(Object[].class));
    verify(consumer, times(0)).endTable();

    verify(consumer).endDataSet();
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:20,代码来源:YamlDataSetProducerTest.java

示例3: getValue

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
@Override
public Object getValue(int row, String column) throws DataSetException {
    if (row < table.getRowCount()) {
        return table.getValue(row, column);
    } else {
        if (columnToBeReplaced.equalsIgnoreCase(column)) {
            Column c = null;
            ITableMetaData metaData = table.getTableMetaData();
            for (Column cl : metaData.getColumns()) {
                if (cl.getColumnName().equalsIgnoreCase(column)) {
                    c = cl;
                }
            }
            return c.getDataType().typeCast(valueToBeReplaced);
        }

        return table.getValue(row - table.getRowCount(), column);
    }

}
 
开发者ID:Hippoom,项目名称:spring-test-dbunit-template,代码行数:21,代码来源:CreateTemplateTable.java

示例4: getTables

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

示例5: startTable

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
@Override
public void startTable(ITableMetaData metaData) throws DataSetException {
    // Формируем целевой файл
    currentFile = new File(targetDirectory, String.format("%s.%s", metaData.getTableName(), extension));
    try {
        // Формируем сервис записи файла
        currentWriter = createWriter();
        // Формируем название колонок
        Column[] columns = metaData.getColumns();
        currentHeaders = new String[columns.length];
        for (int i = 0; i < currentHeaders.length; i++) {
            currentHeaders[i] = columns[i].getColumnName();
        }
        // Записываем название колонок
        writeHeader();
    } catch (IOException ex) {
        throw new DataSetException(ex);
    }
}
 
开发者ID:hflabs,项目名称:perecoder,代码行数:20,代码来源:FilesConsumer.java

示例6: testConvert

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
public void testConvert() throws Exception {
    ITableMetaData tableMetaData = new DefaultTableMetaData(
            "testDictionary",
            new Column[]{new Column("column1", DataType.UNKNOWN), new Column("column2", DataType.UNKNOWN)}
    );

    Dictionary dictionary = converter.convert(tableMetaData);
    assertNotNull(dictionary);
    assertEquals(dictionary.getName(), "testDictionary");
    // check META-fields
    List<MetaField> metaFields = ModelUtils.sortMetaFieldsByOrdinal(dictionary.getDescendants());
    assertEquals(metaFields.size(), 2);
    for (int i = 0; i < metaFields.size(); i++) {
        assertMetaField(metaFields.get(i), tableMetaData.getColumns(), i, i == 0);
    }
    // check serialize
    assertObjectSerialization(dictionary);
}
 
开发者ID:hflabs,项目名称:perecoder,代码行数:19,代码来源:DictionaryStructureConverterTest.java

示例7: startTable

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
@Override
public void startTable(ITableMetaData metaData) throws DataSetException {
	this.metaData = metaData;
	rowCount = 0;
	try {
		out.write(DOUBLE_SPACES+"\""+metaData.getTableName() + "\": [" + NEW_LINE);
	} catch (IOException e) {
		logger.warn("Could not start table.", e);
	}
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:11,代码来源:JSONWriter.java

示例8: startTable

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
@Override
public void startTable(ITableMetaData metaData) throws DataSetException {
    this.metaData = metaData;
    try {
        out.write(metaData.getTableName()+":"+NEW_LINE);
    } catch (IOException e) {
    	logger.warn("Could not start table.", e);
    }
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:10,代码来源:YMLWriter.java

示例9: createMeta

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
ITableMetaData createMeta(String name, List<String> columnNames) {
    Column[] columns = null;
    if (columnNames != null) {
        columns = new Column[columnNames.size()];
        for (int i = 0; i < columnNames.size(); i++)
            columns[i] = new Column(columnNames.get(i), DataType.UNKNOWN);
    } else {
        columns = new Column[0];
    }
    return new DefaultTableMetaData(name, columns);
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:12,代码来源:YamlDataSet.java

示例10: getTableMetaData

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
@Override
public ITableMetaData getTableMetaData(final String tableName) throws DataSetException {
    MyTable myTable = tables.get(tableName.toUpperCase());
    if (myTable != null) {
        return myTable.getTableMetaData();
    }
    return null;
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:9,代码来源:YamlDataSet.java

示例11: BeanDataSet

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
public BeanDataSet(String tableName, List<?> beans, ITableMetaData metaData)
throws DataSetException {
    tables = createTableNameMap();

    ITable table = new BeanTable(tableName, beans, metaData);
    tables.add(tableName, table);
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:8,代码来源:BeanDataSet.java

示例12: assertDataSetEquals

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
public void assertDataSetEquals(IDataSet expected, List<?>...actuals) throws DatabaseUnitException {
    BeanDataSet actualDataSet = new BeanDataSet();
    for (List<?> actual : actuals) {
        String tableName = null;
        if (actual.size() > 0 ) {
            tableName = actual.get(0).getClass().getSimpleName();
        }
        ITableMetaData metaData = expected.getTableMetaData(tableName);
        BeanTable table = new BeanTable(tableName, actual, metaData);
        actualDataSet.addTable(table);
    }
    Assertion.assertEquals(expected, actualDataSet);
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:14,代码来源:AbstractDaoTestCase.java

示例13: produce

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
@Override
public void produce() throws DataSetException {

    consumer.startDataSet();

    final Map<String, List<Map<String, String>>> dataset = loadDataSet();

    for (final Map.Entry<String, List<Map<String, String>>> entry : dataset.entrySet()) {
        // an entry represents a table
        final List<Map<String, String>> rows = entry.getValue();
        // each row represents a record in a table
        final Collection<String> columnNames = extractColumnNames(rows);
        final ITableMetaData tableMetaData = new DefaultTableMetaData(entry.getKey(), createColumns(columnNames));

        consumer.startTable(tableMetaData);

        for (final Map<String, String> row : rows) {
            final List<String> values = new ArrayList<>();
            for (final Column column : tableMetaData.getColumns()) {
                final Object rawValue = row.get(column.getColumnName());
                final String value = rawValue == null ? null : String.valueOf(rawValue);
                values.add(value);
            }
            consumer.row(values.toArray());
        }

        consumer.endTable();

    }

    consumer.endDataSet();
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:33,代码来源:DataSetProducer.java

示例14: getColumnsToIgnore

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
protected String[] getColumnsToIgnore(ITableMetaData expectedMetaData, ITableMetaData actualMetaData)
		throws DataSetException {
	Column[] notSpecifiedInExpected = Columns.getColumnDiff(expectedMetaData, actualMetaData).getActual();
	List<String> result = new LinkedList<String>();
	for (Column column : notSpecifiedInExpected) {
		result.add(column.getColumnName());
	}
	return result.toArray(new String[result.size()]);
}
 
开发者ID:lbitonti,项目名称:deltaspike-dbunit,代码行数:10,代码来源:NonStrictDatabaseAssertion.java

示例15: getTableMetaData

import org.dbunit.dataset.ITableMetaData; //导入依赖的package包/类
public ITableMetaData getTableMetaData() {
    ITableMetaData meta = delegate.getTableMetaData();
    try {
        return new DefaultTableMetaData(tableName, meta.getColumns(), meta.getPrimaryKeys());
    } catch (DataSetException e) {
        throw new QtafException("Don't get the meta info from  " + meta, e);
    }
}
 
开发者ID:sapientTest,项目名称:Sapient,代码行数:9,代码来源:XlsTableWrapper.java


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