Search in sources :

Example 46 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method testRollbackableChangeLogScriptOnExistingDatabase.

@Test
public void testRollbackableChangeLogScriptOnExistingDatabase() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase(rollbackChangeLog);
    clearDatabase(liquibase);
    liquibase = createLiquibase(rollbackChangeLog);
    liquibase.update(this.contexts);
    StringWriter writer = new StringWriter();
    liquibase = createLiquibase(rollbackChangeLog);
    liquibase.rollback(new Date(0), this.contexts, writer);
//        System.out.println("Rollback SQL for "+driverName+StreamUtil.getLineSeparator()+StreamUtil.getLineSeparator()+writer.toString());
}
Also used : Liquibase(liquibase.Liquibase) Test(org.junit.Test)

Example 47 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method testDbDoc.

@Test
public void testDbDoc() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase(completeChangeLog);
    liquibase.dropAll(getSchemasToDrop());
    liquibase = createLiquibase(completeChangeLog);
    liquibase.update(this.contexts);
    File outputDir = File.createTempFile("liquibase-dbdoctest", "dir");
    outputDir.delete();
    outputDir.mkdir();
    liquibase = createLiquibase(completeChangeLog);
    liquibase.generateDocumentation(outputDir.getAbsolutePath(), this.contexts);
    deleteOnExit(outputDir);
}
Also used : Liquibase(liquibase.Liquibase) Test(org.junit.Test)

Example 48 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method verifyObjectQuotingStrategy.

@Test
public void verifyObjectQuotingStrategy() throws Exception {
    if (database == null) {
        return;
    }
    if (!Arrays.asList("oracle,h2,hsqldb,postgresql,mysql").contains(database.getShortName())) {
        return;
    }
    Liquibase liquibase = createLiquibase(objectQuotingStrategyChangeLog);
    clearDatabase(liquibase);
    liquibase.update(contexts);
    clearDatabase(liquibase);
}
Also used : Liquibase(liquibase.Liquibase) Test(org.junit.Test)

Example 49 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method contextsWithHyphensWorkInFormattedSql.

@Test
public void contextsWithHyphensWorkInFormattedSql() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase("changelogs/common/sqlstyle/formatted.changelog.sql");
    liquibase.update("hyphen-context-using-sql,camelCaseContextUsingSql");
    SnapshotGeneratorFactory tableSnapshotGenerator = SnapshotGeneratorFactory.getInstance();
    assertNotNull(tableSnapshotGenerator.has(new Table().setName("hyphen_context"), database));
    assertNotNull(tableSnapshotGenerator.has(new Table().setName("camel_context"), database));
    assertNotNull(tableSnapshotGenerator.has(new Table().setName("bar_id"), database));
    assertNotNull(tableSnapshotGenerator.has(new Table().setName("foo_id"), database));
}
Also used : Liquibase(liquibase.Liquibase) SnapshotGeneratorFactory(liquibase.snapshot.SnapshotGeneratorFactory) Test(org.junit.Test)

Example 50 with Liquibase

use of liquibase.Liquibase in project liquibase by liquibase.

the class AbstractIntegrationTest method invalidIncludeDoesntBreakLiquibase.

@Test
public void invalidIncludeDoesntBreakLiquibase() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase(invalidReferenceChangeLog);
    try {
        liquibase.update(new Contexts());
        fail("Did not fail with invalid include");
    } catch (ChangeLogParseException ignored) {
    //expected
    }
    LockService lockService = LockServiceFactory.getInstance().getLockService(database);
    assertFalse(lockService.hasChangeLogLock());
}
Also used : Liquibase(liquibase.Liquibase) LockService(liquibase.lockservice.LockService) ChangeLogParseException(liquibase.exception.ChangeLogParseException) Contexts(liquibase.Contexts) Test(org.junit.Test)

Aggregations

Liquibase (liquibase.Liquibase)59 Test (org.junit.Test)37 Contexts (liquibase.Contexts)12 LiquibaseException (liquibase.exception.LiquibaseException)10 ValidationFailedException (liquibase.exception.ValidationFailedException)9 BuildException (org.apache.tools.ant.BuildException)9 IOException (java.io.IOException)8 Database (liquibase.database.Database)7 DatabaseSnapshot (liquibase.snapshot.DatabaseSnapshot)7 SnapshotControl (liquibase.snapshot.SnapshotControl)7 CatalogAndSchema (liquibase.CatalogAndSchema)6 LabelExpression (liquibase.LabelExpression)6 AbstractIntegrationTest (liquibase.dbtest.AbstractIntegrationTest)6 Namespace (net.sourceforge.argparse4j.inf.Namespace)6 Date (java.util.Date)5 JdbcConnection (liquibase.database.jvm.JdbcConnection)5 CompareControl (liquibase.diff.compare.CompareControl)5 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 FileResource (org.apache.tools.ant.types.resources.FileResource)5