use of liquibase.Contexts in project liquibase by liquibase.
the class MarkNextChangeSetRanTask method executeWithLiquibaseClassloader.
@Override
public void executeWithLiquibaseClassloader() throws BuildException {
Liquibase liquibase = getLiquibase();
Writer writer = null;
try {
FileResource outputFile = getOutputFile();
if (outputFile != null) {
writer = getOutputFileWriter();
liquibase.markNextChangeSetRan(new Contexts(getContexts()), getLabels(), writer);
} else {
liquibase.markNextChangeSetRan(new Contexts(getContexts()), getLabels());
}
} catch (LiquibaseException e) {
throw new BuildException("Unable to mark next changeset as ran: " + e.getMessage(), e);
} catch (IOException e) {
throw new BuildException("Unable to mark next changeset as ran. Error creating output writer.", e);
} finally {
FileUtils.close(writer);
}
}
use of liquibase.Contexts in project liquibase by liquibase.
the class ChangeLogSyncTask method executeWithLiquibaseClassloader.
@Override
public void executeWithLiquibaseClassloader() throws BuildException {
Liquibase liquibase = getLiquibase();
OutputStreamWriter writer = null;
try {
FileResource outputFile = getOutputFile();
if (outputFile != null) {
writer = new OutputStreamWriter(outputFile.getOutputStream(), getOutputEncoding());
liquibase.changeLogSync(toTag, new Contexts(getContexts()), getLabels(), writer);
} else {
liquibase.changeLogSync(toTag, new Contexts(getContexts()), getLabels());
}
} catch (UnsupportedEncodingException e) {
throw new BuildException("Unable to generate sync SQL. Encoding [" + getOutputEncoding() + "] is not supported.", e);
} catch (IOException e) {
throw new BuildException("Unable to generate sync SQL. Error creating output writer.", e);
} catch (LiquibaseException e) {
throw new BuildException("Unable to sync change log: " + e.getMessage(), e);
} finally {
FileUtils.close(writer);
}
}
use of liquibase.Contexts in project liquibase by liquibase.
the class ChangeLogIteratorTest method runChangeSet_doubleFilterIterator.
@Test
public void runChangeSet_doubleFilterIterator() throws Exception {
TestChangeSetVisitor testChangeLogVisitor = new TestChangeSetVisitor();
ChangeLogIterator iterator = new ChangeLogIterator(changeLog, new ContextChangeSetFilter(new Contexts("test1")), new DbmsChangeSetFilter(new MySQLDatabase()));
iterator.run(testChangeLogVisitor, new RuntimeEnvironment(null, null, null));
assertEquals(3, testChangeLogVisitor.visitedChangeSets.size());
assertEquals("1", testChangeLogVisitor.visitedChangeSets.get(0).getId());
assertEquals("4", testChangeLogVisitor.visitedChangeSets.get(1).getId());
assertEquals("5", testChangeLogVisitor.visitedChangeSets.get(2).getId());
}
use of liquibase.Contexts in project liquibase by liquibase.
the class ContextChangeSetFilterTest method singleContexts.
@Test
public void singleContexts() {
ContextChangeSetFilter filter = new ContextChangeSetFilter(new Contexts("TEST1"));
assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test1", null, null)).isAccepted());
assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test1, test2", null, null)).isAccepted());
assertFalse(filter.accepts(new ChangeSet(null, null, false, false, null, "test2", null, null)).isAccepted());
assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, null, null)).isAccepted());
}
use of liquibase.Contexts in project liquibase by liquibase.
the class ContextChangeSetFilterTest method multiContextsSingeParameter.
@Test
public void multiContextsSingeParameter() {
ContextChangeSetFilter filter = new ContextChangeSetFilter(new Contexts("test1, test2"));
assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test1", null, null)).isAccepted());
assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test2", null, null)).isAccepted());
assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test1, test2", null, null)).isAccepted());
assertFalse(filter.accepts(new ChangeSet(null, null, false, false, null, "test3", null, null)).isAccepted());
assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test3, test1", null, null)).isAccepted());
assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test3, TEST1", null, null)).isAccepted());
assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, null, null)).isAccepted());
}
Aggregations