use of liquibase.Liquibase in project liquibase by liquibase.
the class H2IntegrationTest method runYamlChangelog.
@Test
public void runYamlChangelog() throws Exception {
if (getDatabase() == null) {
return;
}
Liquibase liquibase = createLiquibase(completeChangeLog);
clearDatabase();
// run again to test changelog testing logic
liquibase = createLiquibase("changelogs/yaml/common.tests.changelog.yaml");
liquibase.setChangeLogParameter("loginuser", testSystem.getUsername());
try {
liquibase.update(this.contexts);
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.out);
throw e;
}
}
use of liquibase.Liquibase in project liquibase by liquibase.
the class H2IntegrationTest method runJsonChangelog.
@Test
public void runJsonChangelog() throws Exception {
if (getDatabase() == null) {
return;
}
Liquibase liquibase = createLiquibase(completeChangeLog);
clearDatabase();
// run again to test changelog testing logic
liquibase = createLiquibase("changelogs/json/common.tests.changelog.json");
liquibase.setChangeLogParameter("loginuser", testSystem.getUsername());
try {
liquibase.update(this.contexts);
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.out);
throw e;
}
}
use of liquibase.Liquibase in project liquibase by liquibase.
the class MssqlIntegrationTest method dataTypesTest.
@Test
public void dataTypesTest() throws Exception {
assumeNotNull(this.getDatabase());
clearDatabase();
Liquibase liquibase = createLiquibase("changelogs/mssql/issues/data.types.xml");
liquibase.update((String) null);
DatabaseSnapshot snapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(CatalogAndSchema.DEFAULT, this.getDatabase(), new SnapshotControl(getDatabase()));
for (Table table : snapshot.get(Table.class)) {
if (getDatabase().isLiquibaseObject(table)) {
continue;
}
for (Column column : table.getColumns()) {
String expectedType = column.getName().split("_")[0];
switch(expectedType.toUpperCase()) {
// varchar(max), nvarchar(max) and varbinary(max).
case "TEXT":
expectedType = "varchar";
break;
case "NTEXT":
expectedType = "nvarchar";
break;
case "IMAGE":
expectedType = "varbinary";
break;
default:
}
String foundTypeDefinition = DataTypeFactory.getInstance().from(column.getType(), new MSSQLDatabase()).toDatabaseDataType(getDatabase()).toString();
// [varbinary] -> varbinary
foundTypeDefinition = foundTypeDefinition.replaceFirst("^\\[(.*?)\\]", "$1");
String foundType = foundTypeDefinition.replaceFirst("\\(.*", "").trim();
assertEquals("Wrong data type for " + table.getName() + "." + column.getName(), expectedType.toLowerCase(), foundType.toLowerCase());
if ("varbinary".equalsIgnoreCase(expectedType)) {
if (column.getName().endsWith("_MAX")) {
assertEquals("VARBINARY(MAX)", foundTypeDefinition.toUpperCase());
} else {
assertEquals("VARBINARY(1)", foundTypeDefinition.toUpperCase());
}
}
}
}
}
use of liquibase.Liquibase in project liquibase by liquibase.
the class OracleIntegrationTest method smartDataLoad.
@Test
public void smartDataLoad() throws Exception {
assumeNotNull(this.getDatabase());
Liquibase liquibase = createLiquibase("changelogs/common/smartDataLoad.changelog.xml");
clearDatabase();
try {
liquibase.update(this.contexts);
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.out);
throw e;
}
// check that the automatically rollback now works too
try {
liquibase.rollback(new Date(0), this.contexts);
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.out);
throw e;
}
}
use of liquibase.Liquibase in project liquibase by liquibase.
the class OracleIntegrationTest method viewCreatedOnCorrectSchema.
@Test
public void viewCreatedOnCorrectSchema() throws Exception {
assumeNotNull(this.getDatabase());
Liquibase liquibase = createLiquibase(this.viewOnSchemaChangeLog);
clearDatabase();
try {
liquibase.update(this.contexts);
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.out);
throw e;
}
Statement queryIndex = ((JdbcConnection) this.getDatabase().getConnection()).getUnderlyingConnection().createStatement();
ResultSet indexOwner = queryIndex.executeQuery("SELECT owner FROM ALL_VIEWS WHERE view_name = 'V_BOOK2'");
assertTrue(indexOwner.next());
String owner = indexOwner.getString("owner");
assertEquals("LBCAT2", owner);
// check that the automatically rollback now works too
try {
liquibase.rollback(new Date(0), this.contexts);
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.out);
throw e;
}
}
Aggregations