use of liquibase.database.core.SQLiteDatabase in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithIncrementBySQLiteDatabase.
@Test
public void testAutoIncrementStartWithIncrementBySQLiteDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof SQLiteDatabase) {
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.valueOf(2), BigInteger.TEN));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
// start with and increment by not supported by SQLite
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT AUTOINCREMENT)", generatedSql[0].toSql());
}
}
}
use of liquibase.database.core.SQLiteDatabase in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithSQLiteDatabase.
@Test
public void testAutoIncrementStartWithSQLiteDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof SQLiteDatabase) {
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.valueOf(2), null));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
// start with not supported by SQLlite
assertEquals("CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT AUTOINCREMENT)", generatedSql[0].toSql());
}
}
}
use of liquibase.database.core.SQLiteDatabase in project liquibase by liquibase.
the class TestContext method getAllDatabases.
public Set<Database> getAllDatabases() {
if (allDatabases == null) {
allDatabases = new HashSet<Database>();
allDatabases.addAll(DatabaseFactory.getInstance().getImplementedDatabases());
List<Database> toRemove = new ArrayList<Database>();
for (Database database : allDatabases) {
if (// todo: re-enable sqlite testing
(database instanceof SQLiteDatabase) || (database instanceof MockDatabase)) {
toRemove.add(database);
}
database.setCanCacheLiquibaseTableInfo(false);
}
allDatabases.removeAll(toRemove);
}
return allDatabases;
}
use of liquibase.database.core.SQLiteDatabase in project liquibase by liquibase.
the class DatabaseTestContext method getAllDatabases.
public Set<Database> getAllDatabases() {
if (allDatabases == null) {
allDatabases = new HashSet<Database>();
allDatabases.addAll(DatabaseFactory.getInstance().getImplementedDatabases());
List<Database> toRemove = new ArrayList<Database>();
for (Database database : allDatabases) {
if (//todo: re-enable sqlite testing
database instanceof SQLiteDatabase || database instanceof MockDatabase || database instanceof ExampleCustomDatabase) {
toRemove.add(database);
}
}
allDatabases.removeAll(toRemove);
}
return allDatabases;
}
use of liquibase.database.core.SQLiteDatabase in project liquibase by liquibase.
the class DatabaseTestTemplate method test.
private void test(DatabaseTest test, Set<Database> databasesToTestOn) throws Exception {
for (Database database : databasesToTestOn) {
if (database instanceof SQLiteDatabase) {
//todo: find how to get tests to run correctly on SQLite
continue;
}
JdbcExecutor writeExecutor = new JdbcExecutor();
writeExecutor.setDatabase(database);
ExecutorService.getInstance().setExecutor(database, writeExecutor);
LockService lockService = LockServiceFactory.getInstance().getLockService(database);
lockService.reset();
if (database.getConnection() != null) {
lockService.forceReleaseLock();
}
try {
test.performTest(database);
} catch (ComparisonFailure e) {
String newMessage = "Database Test Failure on " + database;
if (e.getMessage() != null) {
newMessage += ": " + e.getMessage();
}
ComparisonFailure newError = new ComparisonFailure(newMessage, e.getExpected(), e.getActual());
newError.setStackTrace(e.getStackTrace());
throw newError;
} catch (AssertionError e) {
e.printStackTrace();
String newMessage = "Database Test Failure on " + database;
if (e.getMessage() != null) {
newMessage += ": " + e.getMessage();
}
AssertionError newError = new AssertionError(newMessage);
newError.setStackTrace(e.getStackTrace());
throw newError;
} catch (MigrationFailedException e) {
e.printStackTrace();
String newMessage = "Database Test Failure on " + database;
if (e.getMessage() != null) {
newMessage += ": " + e.getMessage();
}
AssertionError newError = new AssertionError(newMessage);
newError.setStackTrace(e.getStackTrace());
throw newError;
} catch (Exception e) {
e.printStackTrace();
String newMessage = "Database Test Exception on " + database;
if (e.getMessage() != null) {
newMessage += ": " + e.getMessage();
}
Exception newError = e.getClass().getConstructor(String.class).newInstance(newMessage);
if (e.getCause() == null) {
newError.setStackTrace(e.getStackTrace());
} else {
newError.setStackTrace(e.getCause().getStackTrace());
}
throw newError;
} finally {
if (database.getConnection() != null && !database.getAutoCommitMode()) {
database.rollback();
}
}
}
}
Aggregations