Search in sources :

Example 21 with DatabaseChangeLog

use of liquibase.changelog.DatabaseChangeLog in project liquibase by liquibase.

the class AbstractChangeLogParser method parse.

@Override
public DatabaseChangeLog parse(String physicalChangeLogLocation, ChangeLogParameters changeLogParameters, ResourceAccessor resourceAccessor) throws ChangeLogParseException {
    ParsedNode parsedNode = parseToNode(physicalChangeLogLocation, changeLogParameters, resourceAccessor);
    if (parsedNode == null) {
        return null;
    }
    DatabaseChangeLog changeLog = new DatabaseChangeLog(DatabaseChangeLog.normalizePath(physicalChangeLogLocation));
    changeLog.setChangeLogParameters(changeLogParameters);
    try {
        changeLog.load(parsedNode, resourceAccessor);
    } catch (Exception e) {
        throw new ChangeLogParseException(e);
    }
    return changeLog;
}
Also used : ParsedNode(liquibase.parser.core.ParsedNode) ChangeLogParseException(liquibase.exception.ChangeLogParseException) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) ChangeLogParseException(liquibase.exception.ChangeLogParseException)

Example 22 with DatabaseChangeLog

use of liquibase.changelog.DatabaseChangeLog in project liquibase by liquibase.

the class ValidatingVisitorTest method visit_validateError.

@Test
public void visit_validateError() 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>();
    ValidatingVisitor handler = new ValidatingVisitor(ran);
    handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
    assertEquals(1, handler.getValidationErrors().getErrorMessages().size());
    assertTrue(handler.getValidationErrors().getErrorMessages().get(0).startsWith("Test message"));
    assertFalse(handler.validationPassed());
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors) CreateTableChange(liquibase.change.core.CreateTableChange) Database(liquibase.database.Database) MockDatabase(liquibase.database.core.MockDatabase) ArrayList(java.util.ArrayList) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) RanChangeSet(liquibase.changelog.RanChangeSet) Test(org.junit.Test)

Example 23 with DatabaseChangeLog

use of liquibase.changelog.DatabaseChangeLog in project liquibase by liquibase.

the class OracleIntegrationTest method sqlplusChangelog.

@Test
public void sqlplusChangelog() throws Exception {
    Database database = this.getDatabase();
    assumeNotNull(database);
    Liquibase liquibase = createLiquibase(this.customExecutorChangeLog);
    clearDatabase();
    // 
    // Add a visitor so we can assert
    // 
    DatabaseChangeLog changeLog = liquibase.getDatabaseChangeLog();
    for (ChangeSet changeSet : changeLog.getChangeSets()) {
        changeSet.addSqlVisitor(new TestSqlVisitor());
    }
    try {
        liquibase.update(this.contexts);
    } catch (ValidationFailedException e) {
        e.printDescriptiveError(System.out);
        throw e;
    }
    database.commit();
}
Also used : Liquibase(liquibase.Liquibase) ValidationFailedException(liquibase.exception.ValidationFailedException) Database(liquibase.database.Database) ChangeSet(liquibase.changelog.ChangeSet) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) Test(org.junit.Test) AbstractIntegrationTest(liquibase.dbtest.AbstractIntegrationTest)

Aggregations

DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)23 ChangeSet (liquibase.changelog.ChangeSet)11 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)6 RanChangeSet (liquibase.changelog.RanChangeSet)6 LiquibaseException (liquibase.exception.LiquibaseException)6 IOException (java.io.IOException)5 CreateTableChange (liquibase.change.core.CreateTableChange)5 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)5 Database (liquibase.database.Database)5 MockDatabase (liquibase.database.core.MockDatabase)5 ChangeLogParseException (liquibase.exception.ChangeLogParseException)4 ContextExpression (liquibase.ContextExpression)3 Labels (liquibase.Labels)3 Liquibase (liquibase.Liquibase)3 ColumnConfig (liquibase.change.ColumnConfig)3 CommandExecutionException (liquibase.exception.CommandExecutionException)3 CompositeResourceAccessor (liquibase.resource.CompositeResourceAccessor)3 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)3 ResourceAccessor (liquibase.resource.ResourceAccessor)3