Package com.asakusafw.testtools

Examples of com.asakusafw.testtools.ColumnInfo


                boolean pk = false;
                if (columnKeyStr != null && columnKeyStr.equals(MySQLConstants.STR_IS_PK)) {
                    pk = true;
                }

                ColumnInfo info = new ColumnInfo(tableName, columnName,
                        columnComment, dataType, characterMaximumLength,
                        numericPrecision, numericScale, nullable, pk, null, null);
                list.add(info);
            }
        } finally {
View Full Code Here


        ExcelUtils excelUtils =  new ExcelUtils(filename);
        List<ColumnInfo> list = excelUtils.getColumnInfos();
        // カラム数の確認
        assertEquals(37, list.size());
        // 最初のカラムの確認
        ColumnInfo info;
        info = list.get(0);
        assertEquals("FOO", info.getTableName());
        assertEquals("PK", info.getColumnName());
        assertEquals("", info.getColumnComment());
        assertEquals(MySqlDataType.LONG, info.getDataType());
        assertTrue(info.isKey());
        assertFalse(info.isNullable());
        assertEquals(ColumnMatchingCondition.NONE, info.getColumnMatchingCondition());
        assertEquals(NullValueCondition.NORMAL, info.getNullValueCondition());

        // VARCHARのカラム(2番目)を確認
        info = list.get(2 - 1); // カラム番号は1オリジンなので、-1する
        assertEquals("FOO", info.getTableName());
        assertEquals("DETAIL_GROUP_ID", info.getColumnName());
        assertEquals("", info.getColumnComment());
        assertEquals(MySqlDataType.VARCHAR, info.getDataType());
        assertEquals(256, info.getCharacterMaximumLength());
        assertFalse(info.isKey());
        assertFalse(info.isNullable());
        assertEquals(ColumnMatchingCondition.PARTIAL, info.getColumnMatchingCondition());
        assertEquals(NullValueCondition.NULL_IS_NG, info.getNullValueCondition());

        // DECIMALのカラム(29番目)を確認
        info = list.get(29 - 1); // カラム番号は1オリジンなので、-1する
        assertEquals("FOO", info.getTableName());
        assertEquals("DEC_COL", info.getColumnName());
        assertEquals("DEC_COL_C", info.getColumnComment());
        assertEquals(MySqlDataType.DECIMAL, info.getDataType());
        assertEquals(10, info.getNumericPrecision());
        assertEquals(4, info.getNumericScale());
        assertFalse(info.isKey());
        assertTrue(info.isNullable());
        assertEquals(ColumnMatchingCondition.EXACT, info.getColumnMatchingCondition());
        assertEquals(NullValueCondition.NULL_IS_OK, info.getNullValueCondition());
    }
View Full Code Here

        ExcelUtils excelUtils =  new ExcelUtils(filename);
        List<ColumnInfo> list = excelUtils.getColumnInfos();
        // カラム数の確認
        assertEquals(37, list.size());
        // 最初のカラムの確認
        ColumnInfo info;
        info = list.get(0);
        assertEquals("BAR", info.getTableName());
        assertEquals("PK", info.getColumnName());
        assertEquals("", info.getColumnComment());
        assertEquals(MySqlDataType.LONG, info.getDataType());
        assertTrue(info.isKey());
        assertFalse(info.isNullable());
        assertEquals(ColumnMatchingCondition.NONE, info.getColumnMatchingCondition());
        assertEquals(NullValueCondition.NORMAL, info.getNullValueCondition());

        // VARCHARのカラム(2番目)を確認
        info = list.get(2 - 1); // カラム番号は1オリジンなので、-1する
        assertEquals("BAR", info.getTableName());
        assertEquals("DETAIL_GROUP_ID", info.getColumnName());
        assertEquals("52", info.getColumnComment());
        assertEquals(MySqlDataType.VARCHAR, info.getDataType());
        assertEquals(256, info.getCharacterMaximumLength());
        assertFalse(info.isKey());
        assertFalse(info.isNullable());
        assertEquals(ColumnMatchingCondition.PARTIAL, info.getColumnMatchingCondition());
        assertEquals(NullValueCondition.NULL_IS_NG, info.getNullValueCondition());

        // DECIMALのカラム(29番目)を確認
        info = list.get(29 - 1); // カラム番号は1オリジンなので、-1する
        assertEquals("BAR", info.getTableName());
        assertEquals("DEC_COL", info.getColumnName());
        assertEquals("123456", info.getColumnComment());
        assertEquals(MySqlDataType.DECIMAL, info.getDataType());
        assertEquals(10, info.getNumericPrecision());
        assertEquals(4, info.getNumericScale());
        assertFalse(info.isKey());
        assertTrue(info.isNullable());
        assertEquals(ColumnMatchingCondition.EXACT, info.getColumnMatchingCondition());
        assertEquals(NullValueCondition.NULL_IS_OK, info.getNullValueCondition());
    }
View Full Code Here

            if (nullValueCondition == null) {
                String msg = creaetExceptionMessage(ConditionSheetItem.NULL_VALUE_CONDITION, row);
                throw new InvalidExcelBookException(msg);
            }

            ColumnInfo info = new ColumnInfo(tablename, columnName,
                    columnComment, dataType, characterMaximumLength,
                    numericPrecision, numericScale, nullable, key,
                    columnMatchingCondition, nullValueCondition);

            list.add(info);
View Full Code Here

            ps = conn.prepareStatement(sql);
            rs = ps.executeQuery();
            while (rs.next()) {
                row = sheet.createRow(row.getRowNum() + 1);
                for (int i = 0; i < columnInfos.length; i++) {
                    ColumnInfo info = columnInfos[i];
                    HSSFCell cell = row.createCell(i);
                    cell.setCellStyle(commonStyle);
                    switch (info.getDataType()) {
                    case CHAR:
                    case VARCHAR:
                        String str = rs.getString(info.getColumnName());
                        if (!rs.wasNull()) {
                            cell.setCellValue(str);
                        }
                        break;
                    case DATE:
                        Date date = rs.getDate(info.getColumnName());
                        if (!rs.wasNull()) {
                            cell.setCellValue(new java.util.Date(date.getTime()));
                            cell.setCellStyle(dateStyle);
                        }
                        break;
                    case DATETIME:
                    case TIMESTAMP:
                        Timestamp ts = rs.getTimestamp(info.getColumnName());
                        if (!rs.wasNull()) {
                            cell.setCellValue(new java.util.Date(ts.getTime()));
                            cell.setCellStyle(dateTimeStyle);
                        }
                        break;
                    case DECIMAL:
                        BigDecimal decimal = rs.getBigDecimal(info.getColumnName());
                        if (!rs.wasNull()) {
                            cell.setCellValue(decimal.toPlainString());
                        }
                        break;
                    case TINY_INT:
                    case SMALL_INT:
                    case INT:
                    case LONG:
                        long value = rs.getLong(info.getColumnName());
                        if (!rs.wasNull()) {
                            cell.setCellValue(Long.toString(value));
                        }
                        break;
                    default:
View Full Code Here

TOP

Related Classes of com.asakusafw.testtools.ColumnInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.