Package org.databene.jdbacl.model

Examples of org.databene.jdbacl.model.DBTable


  }
 
  @Test
  public void testIndexCreated() {
    // given a table of which an index was added
    DBTable table1 = createTableWithColumns("tbl", 2);
    DBTable table2 = createTableWithColumns("tbl", 2);
    new DBNonUniqueIndex("idx", true, table2, "col1");
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be an index creation
View Full Code Here


  }
 
  @Test
  public void testIndexDeleted() {
    // given a table of which an index was deleted
    DBTable table1 = createTableWithColumns("tbl", 2);
    new DBNonUniqueIndex("idx", true, table1, "col1");
    DBTable table2 = createTableWithColumns("tbl", 2);
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be an index deletion
    System.out.println(schemaChange);
View Full Code Here

    assertChange(IndexDeletion.class, DBIndex.class, "idx", ChangeSeverity.REORGANIZATION, tableChanges.get(0));
  }
 
  public void testIndexOnDifferentColumn() {
    // given a table of which an index was redefined to another column
    DBTable table1 = createTableWithColumns("tbl", 2);
    new DBNonUniqueIndex("idx", true, table1, "col1");
    DBTable table2 = createTableWithColumns("tbl", 2);
    new DBNonUniqueIndex("idx", true, table1, "col2");
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be an index deletion and an index creation
View Full Code Here

*/
public class ChangeByAffectedObjectFilterTest {
 
  @Test
  public void testNotNullConstraintCreation() {
    DBTable oldTable = new DBTable("T");
    DBColumn oldColumn = new DBColumn("C1", oldTable, DBDataType.getInstance("INTEGER"));
    DBColumn oldColumn2 = new DBColumn("C2", oldTable, DBDataType.getInstance("INTEGER"));
   
    DBTable newTable = new DBTable("T");
    DBColumn newColumn = new DBColumn("C1", newTable, DBDataType.getInstance("INTEGER"));
    DBColumn newColumn2 = new DBColumn("C2", newTable, DBDataType.getInstance("INTEGER"));
    DBNotNullConstraint constraint = new DBNotNullConstraint(newTable, "T_C1_NOT_NULL", true, "C1");
    newColumn.setNotNullConstraint(constraint);
   
View Full Code Here

    this.catalog = new DBCatalog("catalog", this.db);
    this.schema = new DBSchema("schema", this.catalog);
  }
 
  protected DBTable createTableWithColumns(String tableName, int columnCount) {
    DBTable table = new DBTable(tableName, TableType.TABLE, schema);
    for (int i = 1; i <= columnCount; i++)
      createIntColumn("col" + i, table);
    return table;
  }
View Full Code Here

      createIntColumn("col" + i, table);
    return table;
  }

  protected DBTable createTableWithColumns(String tableName, String... columnNames) {
    DBTable table = new DBTable(tableName, TableType.TABLE, schema);
    for (int i = 0; i < columnNames.length; i++)
      createIntColumn(columnNames[i], table);
    return table;
  }
View Full Code Here

public class IndexComparatorTest extends AbstractComparatorTest {

  @Test
  public void testUnchanged() {
    // given a table of which the index has not changed
    DBTable table = createTableWithColumns("tbl", 3);
    DBIndex index1 = new DBNonUniqueIndex("idx", true, table, "col1");
    DBIndex index2 = new DBNonUniqueIndex("idx", true, table, "col1");
    // when performing a comparison
    TableChange tableChange = new TableChange(table, null);
    new IndexComparator(new ComparisonConfig("db1", "db2", null)).compareObjects(index1, index2, tableChange);
View Full Code Here

  }

  @Test
  public void testIndexMadeUnique() {
    // given an index which only changed by becoming unique
    DBTable table = createTableWithColumns("tbl", 3);
    DBIndex index1 = new DBNonUniqueIndex("idx", true, table, "col1");
    DBIndex index2 = new DBUniqueIndex("idx", true, new DBUniqueConstraint(table, "uk1", false, "col1"));
    TableChange tableChange = new TableChange(table, null);
    // when performing a comparison
    new IndexComparator(config).compareObjects(index1, index2, tableChange);
View Full Code Here

  }

  @Test
  public void testIndexMadeNonUnique() {
    // given an index which was unique before but is not now
    DBTable table = createTableWithColumns("tbl", 3);
    DBIndex index1 = new DBUniqueIndex("idx", true, new DBUniqueConstraint(table, "uk1", false, "col1"));
    DBIndex index2 = new DBNonUniqueIndex("idx", true, table, "col1");
    TableChange tableChange = new TableChange(table, null);
    // when performing a comparison
    new IndexComparator(config).compareObjects(index1, index2, tableChange);
View Full Code Here

  }

  @Test
  public void testColumnOrderChanged() {
    // given a table with an index of which the column order changed
    DBTable table = createTableWithColumns("tbl", 2);
    DBIndex index1 = new DBNonUniqueIndex("idx", true, table, "col1", "col2");
    DBIndex index2 = new DBNonUniqueIndex("idx", true, table, "col2", "col1");
    TableChange tableChange = new TableChange(table, null);
    // when performing a comparison
    new IndexComparator(config).compareObjects(index1, index2, tableChange);
View Full Code Here

TOP

Related Classes of org.databene.jdbacl.model.DBTable

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.