Search in sources :

Example 1 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class SpringLiquibase method createLiquibase.

protected Liquibase createLiquibase(Connection c) throws LiquibaseException {
    SpringResourceOpener resourceAccessor = createResourceOpener();
    Liquibase liquibase = new Liquibase(getChangeLog(), resourceAccessor, createDatabase(c, resourceAccessor));
    liquibase.setIgnoreClasspathPrefix(isIgnoreClasspathPrefix());
    if (parameters != null) {
        for (Map.Entry<String, String> entry : parameters.entrySet()) {
            liquibase.setChangeLogParameter(entry.getKey(), entry.getValue());
        }
    }
    if (isDropFirst()) {
        liquibase.dropAll();
    }
    return liquibase;
}
Also used : Liquibase(liquibase.Liquibase) Map(java.util.Map)

Example 2 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method testClearChecksums.

@Test
public void testClearChecksums() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase(completeChangeLog);
    clearDatabase(liquibase);
    liquibase = createLiquibase(completeChangeLog);
    clearDatabase(liquibase);
    liquibase = createLiquibase(completeChangeLog);
    liquibase.update(this.contexts);
    liquibase.clearCheckSums();
}
Also used : Liquibase(liquibase.Liquibase) Test(org.junit.Test)

Example 3 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method testTagEmptyDatabase.

@Test
public void testTagEmptyDatabase() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase(completeChangeLog);
    clearDatabase(liquibase);
    liquibase = createLiquibase(completeChangeLog);
    liquibase.checkLiquibaseTables(false, null, new Contexts(), new LabelExpression());
    liquibase.tag("empty");
    liquibase = createLiquibase(rollbackChangeLog);
    liquibase.update(new Contexts());
    liquibase.rollback("empty", new Contexts());
}
Also used : Liquibase(liquibase.Liquibase) LabelExpression(liquibase.LabelExpression) Contexts(liquibase.Contexts) Test(org.junit.Test)

Example 4 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method testUpdateClearUpdate.

@Test
public void testUpdateClearUpdate() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase(completeChangeLog);
    clearDatabase(liquibase);
    liquibase = createLiquibase(completeChangeLog);
    liquibase.update(this.contexts);
    clearDatabase(liquibase);
    liquibase = createLiquibase(completeChangeLog);
    liquibase.update(this.contexts);
}
Also used : Liquibase(liquibase.Liquibase) Test(org.junit.Test)

Example 5 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method runChangeLogFile.

protected void runChangeLogFile(String changeLogFile) throws Exception {
    Liquibase liquibase = createLiquibase(changeLogFile);
    clearDatabase(liquibase);
    //run again to test changelog testing logic
    liquibase = createLiquibase(changeLogFile);
    try {
        liquibase.update(this.contexts);
    } catch (ValidationFailedException e) {
        e.printDescriptiveError(System.out);
        throw e;
    }
}
Also used : Liquibase(liquibase.Liquibase) ValidationFailedException(liquibase.exception.ValidationFailedException)

Aggregations

Liquibase (liquibase.Liquibase)97 Test (org.junit.Test)29 LiquibaseException (liquibase.exception.LiquibaseException)25 ClassLoaderResourceAccessor (liquibase.resource.ClassLoaderResourceAccessor)25 JdbcConnection (liquibase.database.jvm.JdbcConnection)24 IOException (java.io.IOException)22 Database (liquibase.database.Database)22 SQLException (java.sql.SQLException)17 Contexts (liquibase.Contexts)17 ValidationFailedException (liquibase.exception.ValidationFailedException)11 AbstractIntegrationTest (liquibase.dbtest.AbstractIntegrationTest)10 DatabaseException (liquibase.exception.DatabaseException)10 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)10 BuildException (org.apache.tools.ant.BuildException)10 ChangeSet (liquibase.changelog.ChangeSet)9 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)9 Connection (java.sql.Connection)8 ResourceAccessor (liquibase.resource.ResourceAccessor)8 FileNotFoundException (java.io.FileNotFoundException)6 Date (java.util.Date)6