Search in sources :

Example 11 with Contexts

use of liquibase.Contexts in project liquibase by liquibase.

the class ChangeLogParametersTest method setParameterValue_rightDBWrongContext.

@Test
public void setParameterValue_rightDBWrongContext() {
    ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
    changeLogParameters.setContexts(new Contexts("junit"));
    changeLogParameters.set("doubleSet", "originalValue", "anotherContext", "anotherLabel", "baddb, h2", true, null);
    assertNull(changeLogParameters.getValue("doubleSet", null));
}
Also used : H2Database(liquibase.database.core.H2Database) Contexts(liquibase.Contexts) Test(org.junit.Test)

Example 12 with Contexts

use of liquibase.Contexts in project liquibase by liquibase.

the class ContextChangeSetFilterTest method visitorContextFilterLowerLower.

@Test
public void visitorContextFilterLowerLower() {
    ContextChangeSetFilter filter = new ContextChangeSetFilter(new Contexts("test1"));
    ChangeSet changeSet = new ChangeSet(null, null, false, false, null, null, null, null);
    changeSet.addSqlVisitor(new TestSqlVisitor("test1"));
    assertTrue(filter.accepts(changeSet).isAccepted());
    assertEquals(1, changeSet.getSqlVisitors().size());
}
Also used : Contexts(liquibase.Contexts) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Example 13 with Contexts

use of liquibase.Contexts in project liquibase by liquibase.

the class ContextChangeSetFilterTest method visitorContextFilterLowerUpper.

@Test
public void visitorContextFilterLowerUpper() {
    ContextChangeSetFilter filter = new ContextChangeSetFilter(new Contexts("test1"));
    ChangeSet changeSet = new ChangeSet(null, null, false, false, null, null, null, null);
    changeSet.addSqlVisitor(new TestSqlVisitor("TEST1"));
    assertTrue(filter.accepts(changeSet).isAccepted());
    assertEquals(1, changeSet.getSqlVisitors().size());
}
Also used : Contexts(liquibase.Contexts) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Example 14 with Contexts

use of liquibase.Contexts in project liquibase by liquibase.

the class ContextChangeSetFilterTest method visitorContextFilterUpperLower.

@Test
public void visitorContextFilterUpperLower() {
    ContextChangeSetFilter filter = new ContextChangeSetFilter(new Contexts("TEST1"));
    ChangeSet changeSet = new ChangeSet(null, null, false, false, null, null, null, null);
    changeSet.addSqlVisitor(new TestSqlVisitor("test1"));
    assertTrue(filter.accepts(changeSet).isAccepted());
    assertEquals(1, changeSet.getSqlVisitors().size());
}
Also used : Contexts(liquibase.Contexts) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Example 15 with Contexts

use of liquibase.Contexts in project liquibase by liquibase.

the class ContextChangeSetFilterTest method multiContexts.

@Test
public void multiContexts() {
    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());
}
Also used : Contexts(liquibase.Contexts) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Aggregations

Contexts (liquibase.Contexts)32 Test (org.junit.Test)18 Liquibase (liquibase.Liquibase)16 ChangeSet (liquibase.changelog.ChangeSet)12 LabelExpression (liquibase.LabelExpression)10 LiquibaseException (liquibase.exception.LiquibaseException)8 IOException (java.io.IOException)5 Database (liquibase.database.Database)5 BuildException (org.apache.tools.ant.BuildException)5 FileResource (org.apache.tools.ant.types.resources.FileResource)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 RuntimeEnvironment (liquibase.RuntimeEnvironment)4 Writer (java.io.Writer)3 Connection (java.sql.Connection)3 ContextChangeSetFilter (liquibase.changelog.filter.ContextChangeSetFilter)3 JdbcConnection (liquibase.database.jvm.JdbcConnection)3 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)3 ResourceAccessor (liquibase.resource.ResourceAccessor)3 OutputStreamWriter (java.io.OutputStreamWriter)2 SQLException (java.sql.SQLException)2