use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class ChangeLogParametersTest method setParameterValue_multiDatabase.
@Test
public void setParameterValue_multiDatabase() {
ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
changeLogParameters.set("doubleSet", "originalValue", new ContextExpression(), new Labels(), "baddb, h2", true, null);
assertEquals("originalValue", changeLogParameters.getValue("doubleSet", null));
}
use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class ChangeLogParametersTest method getParameterValue_MultipleLocalParametersInOneHierarchy.
@Test
public /**
* master.xml
* - table_1.xml (table.name=table_1 global=false)
* - - include_of_table_1.xml
* - - - include_of_include_of_table_1.xml
*
* The same parameter defined multiple times on different levels of included files
*/
void getParameterValue_MultipleLocalParametersInOneHierarchy() {
ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
DatabaseChangeLog master = new DatabaseChangeLog("master.xml");
DatabaseChangeLog table_1 = new DatabaseChangeLog("table_1.xml");
table_1.setParentChangeLog(master);
changeLogParameters.set("aKey", "aValue", "junit", "junitLabel", "baddb, h2", false, table_1);
DatabaseChangeLog include_of_table_1 = new DatabaseChangeLog("include_of_table_1.xml");
include_of_table_1.setParentChangeLog(table_1);
DatabaseChangeLog include_of_include_of_table_1 = new DatabaseChangeLog("include_of_include_of_table_1.xml");
include_of_include_of_table_1.setParentChangeLog(include_of_table_1);
changeLogParameters.set("aKey", "bValue", "junit", "junitLabel", "baddb, h2", false, include_of_include_of_table_1);
assertEquals("should return local value of changeSet", "bValue", changeLogParameters.getValue("aKey", include_of_include_of_table_1));
assertEquals("should return local value of closest ancestor changeSet (here the direct parent)", "aValue", changeLogParameters.getValue("aKey", include_of_table_1));
assertEquals("should return local value of changeSet", "aValue", changeLogParameters.getValue("aKey", table_1));
}
use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class SqlGeneratorFactoryTest method getGenerators.
@Test
public void getGenerators() {
SortedSet<SqlGenerator> allGenerators = SqlGeneratorFactory.getInstance().getGenerators(new AddAutoIncrementStatement(null, null, "person", "name", "varchar(255)", null, null, null, null), new H2Database());
assertNotNull(allGenerators);
assertEquals(1, allGenerators.size());
}
use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithH2Database.
@Test
public void testAutoIncrementStartWithH2Database() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof H2Database) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("BIGINT{autoIncrement:true}", database), new AutoIncrementConstraint(COLUMN_NAME1, BigInteger.ZERO, null));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT GENERATED BY DEFAULT AS IDENTITY (0))", generatedSql[0].toSql());
}
}
}
use of liquibase.database.core.H2Database in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementH2Database.
@Test
public void testAutoIncrementH2Database() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof H2Database) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("BIGINT{autoIncrement:true}", database), new AutoIncrementConstraint(COLUMN_NAME1));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT GENERATED BY DEFAULT AS IDENTITY)", generatedSql[0].toSql());
}
}
}
Aggregations