use of liquibase.precondition.core.DBMSPrecondition in project liquibase by liquibase.
the class ValidatingVisitorPreConditionsTest method testPreconditionForOracleOnOracleWithChangeLog.
/**
* Test against oracle, but I don't know for sure if the precondition is really
* validated because oracle supports creating sequences.
*/
@Test
public void testPreconditionForOracleOnOracleWithChangeLog() {
// 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);
OracleDatabase oracleDb = new OracleDatabase() {
@Override
public List<RanChangeSet> getRanChangeSetList() throws DatabaseException {
return new ArrayList<RanChangeSet>();
}
@Override
public void rollback() throws DatabaseException {
//super.rollback();
}
};
String[] empty = {};
boolean exceptionThrown = false;
try {
changeLog.validate(oracleDb, empty);
} catch (LiquibaseException ex) {
exceptionThrown = true;
}
assertFalse(exceptionThrown);
}
use of liquibase.precondition.core.DBMSPrecondition 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);
}
use of liquibase.precondition.core.DBMSPrecondition in project liquibase by liquibase.
the class ValidatingVisitorPreConditionsTest method testPreConditionsForOracleOnMSSQLWithChangeLog.
/**
* Test the same precondition from a changelog with mssql database, this
* should not fail on the validation but just mark is as handled.
*/
@Test
public void testPreConditionsForOracleOnMSSQLWithChangeLog() {
// 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();
}
};
String[] empty = {};
boolean exceptionThrown = false;
try {
// call the validate which gives the error
changeLog.validate(mssqlDb, empty);
} catch (LiquibaseException ex) {
System.out.println(ex.getMessage());
exceptionThrown = true;
}
assertFalse(exceptionThrown);
}
Aggregations