01: package liquibase.database.sql;
02:
03: import liquibase.database.Database;
04: import liquibase.database.structure.DatabaseSnapshot;
05: import liquibase.test.DatabaseTestTemplate;
06: import liquibase.test.SqlStatementDatabaseTest;
07: import org.junit.Test;
08:
09: public class DropUniqueConstraintStatementTest extends
10: AbstractSqlStatementTest {
11: private static final String TABLE_NAME = "DropUQConstTest";
12: private static final String COL_NAME = "colName";
13: private static final String CONSTRAINT_NAME = "UQ_dropUQ";
14:
15: protected void setupDatabase(Database database) throws Exception {
16: dropAndCreateTable(new CreateTableStatement(null, TABLE_NAME)
17: .addPrimaryKeyColumn("id", "int").addColumn(COL_NAME,
18: "varchar(50)", new NotNullConstraint(),
19: new UniqueConstraint(CONSTRAINT_NAME)),
20: database);
21: }
22:
23: protected SqlStatement generateTestStatement() {
24: return new DropUniqueConstraintStatement(null, null, null);
25: }
26:
27: @Test
28: public void execute_defaultSchema() throws Exception {
29: new DatabaseTestTemplate()
30: .testOnAvailableDatabases(new SqlStatementDatabaseTest(
31: null, new DropUniqueConstraintStatement(null,
32: TABLE_NAME, CONSTRAINT_NAME)) {
33:
34: protected void preExecuteAssert(
35: DatabaseSnapshot snapshot) {
36: //todo: assert when isUnique works: assertTrue(snapshot.getTable(TABLE_NAME).getColumn(COL_NAME).isUnique());
37: }
38:
39: protected void postExecuteAssert(
40: DatabaseSnapshot snapshot) {
41: //todo: assert when isUnique works: assertFalse(snapshot.getTable(TABLE_NAME).getColumn(COL_NAME).isUnique());
42: }
43:
44: });
45: }
46:
47: }
|