org.dbunit.dataset.datatype.DataTypeException Java Examples

The following examples show how to use org.dbunit.dataset.datatype.DataTypeException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KylinTestBase.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public DataType createDataType(int sqlType, String sqlTypeName, String tableName, String columnName)
        throws DataTypeException {

    if ((columnName.startsWith("COL") || columnName.startsWith("col")) && sqlType == Types.BIGINT) {
        return DataType.INTEGER;
    }
    return super.createDataType(sqlType, sqlTypeName);
}
 
Example #2
Source File: KylinTestBase.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public DataType createDataType(int sqlType, String sqlTypeName, String tableName, String columnName)
        throws DataTypeException {

    if ((columnName.startsWith("COL") || columnName.startsWith("col")) && sqlType == Types.BIGINT) {
        return DataType.INTEGER;
    }
    return super.createDataType(sqlType, sqlTypeName);
}
 
Example #3
Source File: KylinTestBase.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@Override
public DataType createDataType(int sqlType, String sqlTypeName, String tableName, String columnName) throws DataTypeException {

    if ((columnName.startsWith("COL") || columnName.startsWith("col")) && sqlType == Types.BIGINT) {
        return DataType.INTEGER;
    }
    return super.createDataType(sqlType, sqlTypeName);
}
 
Example #4
Source File: XlsTable.java    From Leo with Apache License 2.0 4 votes vote down vote up
public Object getValue(int row, String column) throws DataSetException {
    if (logger.isDebugEnabled())
        logger.debug("getValue(row={}, columnName={}) - start", Integer.toString(row), column);

    assertValidRowIndex(row);

    int columnIndex = getColumnIndex(column);
    HSSFCell cell = _sheet.getRow(row + 1).getCell(columnIndex);
    if (cell == null) {
        return null;
    }

    int type = cell.getCellType();
    switch (type) {
    case HSSFCell.CELL_TYPE_NUMERIC:
        HSSFCellStyle style = cell.getCellStyle();
        if (HSSFDateUtil.isCellDateFormatted(cell)) {
            return getDateValue(cell);
        } else if (XlsDataSetWriter.DATE_FORMAT_AS_NUMBER_DBUNIT.equals(style.getDataFormatString())) {
            // The special dbunit date format
            return getDateValueFromJavaNumber(cell);
        } else {
            return getNumericValue(cell);
            }

    case HSSFCell.CELL_TYPE_STRING:
        return cell.getRichStringCellValue().getString();

        case HSSFCell.CELL_TYPE_FORMULA:
        throw new DataTypeException("Formula not supported at row=" +
                row + ", column=" + column);

        case HSSFCell.CELL_TYPE_BLANK:
        return null;

        case HSSFCell.CELL_TYPE_BOOLEAN:
        return cell.getBooleanCellValue() ? Boolean.TRUE : Boolean.FALSE;

        case HSSFCell.CELL_TYPE_ERROR:
        throw new DataTypeException("Error at row=" + row +
                ", column=" + column);

        default:
        throw new DataTypeException("Unsupported type at row=" + row +
                ", column=" + column);
    }
}