use of liquibase.changelog.RanChangeSet 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.changelog.RanChangeSet in project liquibase by liquibase.
the class ValidatingVisitorTest method visit_successful.
@Test
public void visit_successful() throws Exception {
CreateTableChange change1 = new CreateTableChange();
change1.setTableName("table1");
ColumnConfig column1 = new ColumnConfig();
change1.addColumn(column1);
column1.setName("col1");
column1.setType("int");
CreateTableChange change2 = new CreateTableChange();
change2.setTableName("table2");
ColumnConfig column2 = new ColumnConfig();
change2.addColumn(column2);
column2.setName("col2");
column2.setType("int");
changeSet1.addChange(change1);
changeSet2.addChange(change2);
ValidatingVisitor handler = new ValidatingVisitor(new ArrayList<RanChangeSet>());
handler.visit(changeSet1, new DatabaseChangeLog(), new MockDatabase(), null);
handler.visit(changeSet2, new DatabaseChangeLog(), new MockDatabase(), null);
assertTrue(handler.validationPassed());
}
use of liquibase.changelog.RanChangeSet in project liquibase by liquibase.
the class ValidatingVisitorTest method visit_torunOnly.
@Test
public void visit_torunOnly() throws Exception {
changeSet1.addChange(new CreateTableChange() {
@Override
public ValidationErrors validate(Database database) {
ValidationErrors changeValidationErrors = new ValidationErrors();
changeValidationErrors.addError("Test message");
return changeValidationErrors;
}
});
List<RanChangeSet> ran = new ArrayList<RanChangeSet>();
ran.add(new RanChangeSet(changeSet1));
ValidatingVisitor handler = new ValidatingVisitor(ran);
handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
assertEquals(0, handler.getSetupExceptions().size());
assertTrue(handler.validationPassed());
}
use of liquibase.changelog.RanChangeSet in project liquibase by liquibase.
the class ValidatingVisitorTest method visit_setupException.
@Test
public void visit_setupException() throws Exception {
changeSet1.addChange(new CreateTableChange() {
@Override
public void finishInitialization() throws SetupException {
throw new SetupException("Test message");
}
});
ValidatingVisitor handler = new ValidatingVisitor(new ArrayList<RanChangeSet>());
handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
assertEquals(1, handler.getSetupExceptions().size());
assertEquals("Test message", handler.getSetupExceptions().get(0).getMessage());
assertFalse(handler.validationPassed());
}
use of liquibase.changelog.RanChangeSet in project liquibase by liquibase.
the class ValidatingVisitorTest method visit_duplicate.
@Test
public void visit_duplicate() throws Exception {
ValidatingVisitor handler = new ValidatingVisitor(new ArrayList<RanChangeSet>());
handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
assertEquals(1, handler.getDuplicateChangeSets().size());
assertFalse(handler.validationPassed());
}
Aggregations