Search in sources :

Example 6 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);
    } 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)6 ArrayList (java.util.ArrayList)3 PreconditionErrorException (liquibase.exception.PreconditionErrorException)3 RanChangeSet (liquibase.changelog.RanChangeSet)2 FailedPrecondition (liquibase.precondition.FailedPrecondition)2 Precondition (liquibase.precondition.Precondition)2 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)1 ChangeSet (liquibase.changelog.ChangeSet)1 ObjectQuotingStrategy (liquibase.database.ObjectQuotingStrategy)1 MSSQLDatabase (liquibase.database.core.MSSQLDatabase)1 DBMSPrecondition (liquibase.precondition.core.DBMSPrecondition)1 PreconditionContainer (liquibase.precondition.core.PreconditionContainer)1 TableRowCountStatement (liquibase.statement.core.TableRowCountStatement)1 Test (org.junit.Test)1