Search in sources :

Example 16 with PreconditionFailedException

use of liquibase.exception.PreconditionFailedException in project liquibase by liquibase.

the class ValidatingVisitorPreConditionsTest method testPreConditionsForOracleOnMSSQLWithPreconditionTag.

/**
 * Test only the precondition tag with a precondition requiring oracle but
 * giving a MSSQL database.
 */
@Test
public void testPreConditionsForOracleOnMSSQLWithPreconditionTag() {
    // create the pre condition
    PreconditionContainer preCondition = new PreconditionContainer();
    preCondition.setOnFail(PreconditionContainer.FailOption.MARK_RAN.toString());
    DBMSPrecondition dbmsPrecondition = new DBMSPrecondition();
    dbmsPrecondition.setType("oracle");
    preCondition.addNestedPrecondition(dbmsPrecondition);
    changeSet1.setPreconditions(preCondition);
    MSSQLDatabase mssqlDb = new MSSQLDatabase() {

        @Override
        public List<RanChangeSet> getRanChangeSetList() throws DatabaseException {
            return new ArrayList<RanChangeSet>();
        }

        @Override
        public void rollback() throws DatabaseException {
        // super.rollback();
        }
    };
    boolean failedExceptionThrown = false;
    boolean errorExceptionThrown = false;
    try {
        preCondition.check(mssqlDb, changeLog, changeSet1, null);
    } catch (PreconditionFailedException ex) {
        failedExceptionThrown = true;
    } catch (PreconditionErrorException ex) {
        errorExceptionThrown = true;
    }
    assertTrue(failedExceptionThrown);
    assertFalse(errorExceptionThrown);
}
Also used : PreconditionContainer(liquibase.precondition.core.PreconditionContainer) DBMSPrecondition(liquibase.precondition.core.DBMSPrecondition) ArrayList(java.util.ArrayList) PreconditionFailedException(liquibase.exception.PreconditionFailedException) MSSQLDatabase(liquibase.database.core.MSSQLDatabase) RanChangeSet(liquibase.changelog.RanChangeSet) PreconditionErrorException(liquibase.exception.PreconditionErrorException) Test(org.junit.Test)

Aggregations

PreconditionFailedException (liquibase.exception.PreconditionFailedException)16 PreconditionErrorException (liquibase.exception.PreconditionErrorException)10 ArrayList (java.util.ArrayList)5 FailedPrecondition (liquibase.precondition.FailedPrecondition)5 Precondition (liquibase.precondition.Precondition)4 Schema (liquibase.structure.core.Schema)4 RanChangeSet (liquibase.changelog.RanChangeSet)3 Table (liquibase.structure.core.Table)3 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)2 ChangeSet (liquibase.changelog.ChangeSet)2 ObjectQuotingStrategy (liquibase.database.ObjectQuotingStrategy)2 TableRowCountStatement (liquibase.statement.core.TableRowCountStatement)2 MSSQLDatabase (liquibase.database.core.MSSQLDatabase)1 Executor (liquibase.executor.Executor)1 ExecutorService (liquibase.executor.ExecutorService)1 ErrorPrecondition (liquibase.precondition.ErrorPrecondition)1 DBMSPrecondition (liquibase.precondition.core.DBMSPrecondition)1 PreconditionContainer (liquibase.precondition.core.PreconditionContainer)1 Column (liquibase.structure.core.Column)1 ForeignKey (liquibase.structure.core.ForeignKey)1