public void testGetPrimaryKeysColumnDontMatch() throws Exception { Column[] columns = new Column[] { new Column("numberColumn", DataType.NUMERIC), new Column("stringColumn", DataType.VARCHAR), new Column("booleanColumn", DataType.BOOLEAN), }; String[] keyNames = new String[] {"invalidColumn"}; ITableMetaData metaData = createMetaData("toto", columns, keyNames); Column[] keys = metaData.getPrimaryKeys(); assertEquals("key count", 0, keys.length); }
public void testGetColumns() throws Exception { Column[] columns = new Column[] { new Column("numberColumn", DataType.NUMERIC), new Column("stringColumn", DataType.VARCHAR), new Column("booleanColumn", DataType.BOOLEAN), }; ITableMetaData metaData = createMetaData("toto", columns, null); assertEquals("column count", columns.length, metaData.getColumns().length); for (int i = 0; i < columns.length; i++) { Column column = columns[i]; assertEquals("columns" + i, column, metaData.getColumns()[i]); } assertEquals("key count", 0, metaData.getPrimaryKeys().length); }
public void testGetPrimaryKeys() throws Exception { Column[] columns = new Column[] { new Column("numberColumn", DataType.NUMERIC), new Column("stringColumn", DataType.VARCHAR), new Column("booleanColumn", DataType.BOOLEAN), }; String[] keyNames = new String[] {"booleanColumn", "numberColumn"}; ITableMetaData metaData = createMetaData("toto", columns, keyNames); Column[] keys = metaData.getPrimaryKeys(); assertEquals("key count", keyNames.length, keys.length); for (int i = 0; i < keys.length; i++) { assertEquals("key name", keyNames[i], keys[i].getColumnName()); } }
public void testGetTableName() throws Exception { String expected = "tableName"; ITableMetaData metaData = createMetaData(expected, null, null); assertEquals("table name", expected, metaData.getTableName()); }