use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class DiffGeneratorFactoryTest method getGenerator.
@Test
public void getGenerator() throws DatabaseException {
DiffGenerator generator = DiffGeneratorFactory.getInstance().getGenerator(new H2Database(), new H2Database());
assertNotNull(generator);
assertTrue(generator instanceof StandardDiffGenerator);
}
use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class ChangeLogParametersTest method setParameterValue_doubleSetButSecondWrongDatabase.
@Test
public void setParameterValue_doubleSetButSecondWrongDatabase() {
ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
changeLogParameters.set("doubleSet", "originalValue", new ContextExpression(), new Labels(), "baddb", true, null);
changeLogParameters.set("doubleSet", "newValue");
assertEquals("newValue", changeLogParameters.getValue("doubleSet", null));
}
use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class ChangeLogParametersTest method setParameterValue_doubleSet_withDbms.
@Test
public void setParameterValue_doubleSet_withDbms() throws Exception {
final DatabaseChangeLog changelog = new DatabaseChangeLog("com/example/changelog.txt");
ChangeLogParameters h2Params = new ChangeLogParameters(new H2Database());
ChangeLogParameters oracleParams = new ChangeLogParameters(new OracleDatabase());
ChangeLogParameters mysqlParams = new ChangeLogParameters(new MySQLDatabase());
h2Params.set("dbmsProperty", "h2 value", new ContextExpression(), new Labels(), "h2", false, changelog);
h2Params.set("dbmsProperty", "oracle value", new ContextExpression(), new Labels(), "oracle", false, changelog);
oracleParams.set("dbmsProperty", "h2 value", new ContextExpression(), new Labels(), "h2", false, changelog);
oracleParams.set("dbmsProperty", "oracle value", new ContextExpression(), new Labels(), "oracle", false, changelog);
mysqlParams.set("dbmsProperty", "h2 value", new ContextExpression(), new Labels(), "h2", false, changelog);
mysqlParams.set("dbmsProperty", "oracle value", new ContextExpression(), new Labels(), "oracle", false, changelog);
assertEquals("h2 value", h2Params.getValue("dbmsProperty", changelog));
assertEquals("oracle value", oracleParams.getValue("dbmsProperty", changelog));
assertNull(mysqlParams.getValue("dbmsProperty", changelog));
}
use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class ChangeLogParametersTest method getParameterValue_IgnoreLocalParameterAfterGlobalParameter.
@Test
public /**
* db.changelog-master.xml
* - table_1.xml (table.name=table_1 global=false)
* - - include templates/common_columns_1.xml
* - table_2.xml (table.name=table_2 global=false)
* - - include templates/common_columns_2.xml
* - - - include templates/common_columns_1.xml
*
* Local parameters with the same name are ignore after the first global parameter with that same name.
*/
void getParameterValue_IgnoreLocalParameterAfterGlobalParameter() {
ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
DatabaseChangeLog master = new DatabaseChangeLog("db/db.changelog-master.xml");
DatabaseChangeLog table_1 = new DatabaseChangeLog("db/changelog/table_1.xml");
table_1.setParentChangeLog(master);
changeLogParameters.set("table.name", "table_1", "junit", "junitLabel", "baddb, h2", true, table_1);
DatabaseChangeLog common_columns_1_of_table_1 = new DatabaseChangeLog("db/templates/common_columns_1.xml");
common_columns_1_of_table_1.setParentChangeLog(table_1);
assertEquals("table_1", changeLogParameters.getValue("table.name", common_columns_1_of_table_1));
assertEquals("table_1", changeLogParameters.getValue("table.name", table_1));
DatabaseChangeLog table_2 = new DatabaseChangeLog("db/changelog/table_2.xml");
table_2.setParentChangeLog(master);
changeLogParameters.set("table.name", "table_2", "junit", "junitLabel", "baddb, h2", false, table_2);
DatabaseChangeLog common_columns_2_of_table_2 = new DatabaseChangeLog("db/templates/common_columns_2.xml");
common_columns_2_of_table_2.setParentChangeLog(table_2);
DatabaseChangeLog common_columns_1_of_table_2 = new DatabaseChangeLog("db/templates/common_columns_1.xml");
common_columns_1_of_table_2.setParentChangeLog(common_columns_2_of_table_2);
// the local parameter value "table_2" is being ignored since there is already a global value defined
assertEquals("should return first global value", "table_1", changeLogParameters.getValue("table.name", common_columns_1_of_table_2));
assertEquals("should return first global value", "table_1", changeLogParameters.getValue("table.name", common_columns_2_of_table_2));
assertEquals("should return first global value", "table_1", changeLogParameters.getValue("table.name", table_2));
}
use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class ChangeLogParametersTest method getParameterValue_SamePropertyNonGlobalIn2InnerFiles.
@Test
public /**
* root.xml
* -a.xml
* -b.xml
*
* in a and b we define same prop with key 'aKey'. Expected when b is processed then bValue is taken no matter of Object instances
*/
void getParameterValue_SamePropertyNonGlobalIn2InnerFiles() {
DatabaseChangeLog inner1 = new DatabaseChangeLog();
inner1.setPhysicalFilePath("a");
DatabaseChangeLog inner2 = new DatabaseChangeLog();
inner2.setPhysicalFilePath("b");
ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
changeLogParameters.set("aKey", "aValue", "junit", "junitLabel", "baddb, h2", false, inner1);
changeLogParameters.set("aKey", "bValue", "junit", "junitLabel", "baddb, h2", false, inner2);
DatabaseChangeLog inner2SamePath = new DatabaseChangeLog();
inner2SamePath.setPhysicalFilePath("b");
Object aKey = changeLogParameters.getValue("aKey", inner2SamePath);
assertEquals("bValue", aKey);
}
Aggregations