use of liquibase.Contexts in project liquibase by liquibase.
the class AbstractIntegrationTest method testRollbackableChangeLogScriptOnFutureDatabase.
@Test
public void testRollbackableChangeLogScriptOnFutureDatabase() throws Exception {
if (database == null) {
return;
}
StringWriter writer = new StringWriter();
Liquibase liquibase = createLiquibase(rollbackChangeLog);
clearDatabase(liquibase);
liquibase = createLiquibase(rollbackChangeLog);
liquibase.futureRollbackSQL(new Contexts(this.contexts), new LabelExpression(), writer);
// System.out.println("Rollback SQL for future "+driverName+"\n\n"+writer.toString());
}
use of liquibase.Contexts 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());
}
use of liquibase.Contexts in project liquibase by liquibase.
the class AbstractIntegrationTest method testUnrunChangeSetsEmptyDatabase.
@Test
public void testUnrunChangeSetsEmptyDatabase() throws Exception {
if (database == null) {
return;
}
Liquibase liquibase = createLiquibase(completeChangeLog);
clearDatabase(liquibase);
liquibase = createLiquibase(completeChangeLog);
List<ChangeSet> list = liquibase.listUnrunChangeSets(new Contexts(this.contexts), new LabelExpression());
assertTrue(list.size() > 0);
}
use of liquibase.Contexts in project minijax by minijax.
the class LiquibaseHelper method validateDatabaseState.
/**
* Validates that the database is in a good state.
*
* @param database The database.
* @param fileName The change log file name.
* @param resourceAccessor The change log file loader.
*/
private void validateDatabaseState(final Database database) throws LiquibaseException {
final Liquibase liquibase = getLiquibase(database);
// all contexts
final Contexts contexts = new Contexts();
// no filters
final LabelExpression labels = new LabelExpression();
final List<ChangeSet> unrunChangeSets = liquibase.listUnrunChangeSets(contexts, labels);
if (!unrunChangeSets.isEmpty()) {
throw new IllegalStateException("Unrun change sets! Please migrate the database first");
}
}
use of liquibase.Contexts in project activityinfo by bedatadriven.
the class TestConnectionProvider method initializeDatabase.
private static void initializeDatabase() throws SQLException, LiquibaseException {
Connection connection;
try {
connection = DriverManager.getConnection(connectionUrl(DATABASE_NAME), USERNAME, PASSWORD);
Statement stmt = connection.createStatement();
stmt.execute("DROP DATABASE IF EXISTS " + DATABASE_NAME);
stmt.execute("CREATE DATABASE " + DATABASE_NAME);
stmt.execute("USE " + DATABASE_NAME);
} catch (SQLException e) {
// Database probably doesn't exist yet
connection = DriverManager.getConnection(connectionUrl(""), USERNAME, PASSWORD);
Statement stmt = connection.createStatement();
stmt.execute("CREATE DATABASE " + DATABASE_NAME);
stmt.close();
connection.close();
// Re-open specifically for this database
connection = DriverManager.getConnection(connectionUrl(DATABASE_NAME), USERNAME, PASSWORD);
}
Liquibase liquibase = new Liquibase("org/activityinfo/database/changelog/db.changelog-master.xml", new ClassLoaderResourceAccessor(), new JdbcConnection(connection));
liquibase.update(new Contexts());
connection.close();
}
Aggregations