1 21 22 package org.dbunit.dataset; 23 24 import org.dbunit.dataset.datatype.DataType; 25 26 31 public class DefaultTableTest extends AbstractTableTest 32 { 33 public DefaultTableTest(String s) 34 { 35 super(s); 36 } 37 38 protected ITable createTable() throws Exception 39 { 40 return createTable(COLUMN_COUNT, ROW_COUNT, 0); 41 } 42 43 protected ITable createTable(int columnCount, int rowCount, int startRow) 44 throws Exception 45 { 46 DefaultTable table = new DefaultTable(createTableMetaData(columnCount)); 47 for (int i = 0; i < rowCount; i++) 48 { 49 Object [] rowValues = new Object [columnCount]; 50 for (int j = 0; j < rowValues.length; j++) 51 { 52 rowValues[j] = "row " + (i + startRow) + " col " + j; 53 } 54 table.addRow(rowValues); 55 } 56 return table; 57 } 58 59 protected ITableMetaData createTableMetaData(int columnCount) throws Exception 60 { 61 Column[] columns = new Column[columnCount]; 62 for (int i = 0; i < columns.length; i++) 63 { 64 columns[i] = new Column("COLUMN" + i, DataType.UNKNOWN); 65 } 66 67 return new DefaultTableMetaData("myTable", columns); 68 } 69 70 public void testGetMissingValue() throws Exception 71 { 72 String columnName = "COLUMN0"; 73 Object expected = ITable.NO_VALUE; 74 75 DefaultTable table = new DefaultTable(createTableMetaData(COLUMN_COUNT)); 76 table.addRow(new Object []{ITable.NO_VALUE, ITable.NO_VALUE, ITable.NO_VALUE, 77 ITable.NO_VALUE, ITable.NO_VALUE, ITable.NO_VALUE}); 78 Column[] columns = table.getTableMetaData().getColumns(); 79 assertNotNull(DataSetUtils.getColumn(columnName, columns)); 80 assertEquals("no value", expected, table.getValue(0, columnName)); 81 } 82 83 } 84 85 86 87 88 | Popular Tags |