use of liquibase.database.core.MySQLDatabase in project liquibase by liquibase.
the class AddColumnGeneratorTest method testAddMultipleColumnsMySql.
@Test
public void testAddMultipleColumnsMySql() {
AddColumnStatement columns = new AddColumnStatement(new AddColumnStatement(null, null, TABLE_NAME, "column1", "INT", null, new NotNullConstraint()), new AddColumnStatement(null, null, TABLE_NAME, "column2", "INT", null, new NotNullConstraint()));
assertFalse(generatorUnderTest.validate(columns, new MySQLDatabase(), new MockSqlGeneratorChain()).hasErrors());
Sql[] sql = generatorUnderTest.generateSql(columns, new MySQLDatabase(), new MockSqlGeneratorChain());
assertEquals(1, sql.length);
assertEquals("ALTER TABLE " + TABLE_NAME + " ADD column1 INT NOT NULL, ADD column2 INT NOT NULL", sql[0].toSql());
assertEquals("[DEFAULT, table_name, table_name.column1, table_name.column2]", String.valueOf(sql[0].getAffectedDatabaseObjects()));
}
use of liquibase.database.core.MySQLDatabase in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementStartWithIncrementByMySQLDatabase.
@Test
public void testAutoIncrementStartWithIncrementByMySQLDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof MySQLDatabase) {
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);
// increment by not supported by MySQL
assertEquals("CREATE TABLE CATALOG_NAME.TABLE_NAME (COLUMN1_NAME BIGINT AUTO_INCREMENT NULL) AUTO_INCREMENT=2", generatedSql[0].toSql());
}
}
}
use of liquibase.database.core.MySQLDatabase in project liquibase by liquibase.
the class DiffToChangeLogTest method getOrderedOutputTypes_isConsistant.
@Test
public void getOrderedOutputTypes_isConsistant() throws Exception {
MySQLDatabase database = new MySQLDatabase();
DiffToChangeLog obj = new DiffToChangeLog(new DiffResult(new EmptyDatabaseSnapshot(database), new EmptyDatabaseSnapshot(database), new CompareControl()), null);
for (Class<? extends ChangeGenerator> type : new Class[] { UnexpectedObjectChangeGenerator.class, MissingObjectChangeGenerator.class, ChangedObjectChangeGenerator.class }) {
List<Class<? extends DatabaseObject>> orderedOutputTypes = obj.getOrderedOutputTypes(type);
for (int i = 0; i < 50; i++) {
assertThat("Error checking " + type.getName(), orderedOutputTypes, contains(obj.getOrderedOutputTypes(type).toArray()));
}
}
}
use of liquibase.database.core.MySQLDatabase in project liquibase by liquibase.
the class JdbcExecutorTest method getInstance.
@Test
public void getInstance() {
final Database oracle1 = new OracleDatabase() {
@Override
public boolean equals(Object o) {
return o == this;
}
};
final Database oracle2 = new OracleDatabase() {
@Override
public boolean equals(Object o) {
return o == this;
}
};
final Database mysql = new MySQLDatabase() {
@Override
public boolean equals(Object o) {
return o == this;
}
};
assertNotNull(ExecutorService.getInstance().getExecutor(oracle1));
assertNotNull(ExecutorService.getInstance().getExecutor(oracle2));
assertNotNull(ExecutorService.getInstance().getExecutor(mysql));
assertTrue(ExecutorService.getInstance().getExecutor(oracle1) == ExecutorService.getInstance().getExecutor(oracle1));
assertTrue(ExecutorService.getInstance().getExecutor(oracle2) == ExecutorService.getInstance().getExecutor(oracle2));
assertTrue(ExecutorService.getInstance().getExecutor(mysql) == ExecutorService.getInstance().getExecutor(mysql));
assertTrue(ExecutorService.getInstance().getExecutor(oracle1) != ExecutorService.getInstance().getExecutor(oracle2));
assertTrue(ExecutorService.getInstance().getExecutor(oracle1) != ExecutorService.getInstance().getExecutor(mysql));
}
use of liquibase.database.core.MySQLDatabase in project liquibase by liquibase.
the class LockServiceFactoryTest method getLockService.
@Test
public void getLockService() {
final Database oracle1 = new OracleDatabase() {
@Override
public boolean equals(Object o) {
return o == this;
}
};
final Database oracle2 = new OracleDatabase() {
@Override
public boolean equals(Object o) {
return o == this;
}
};
final Database mysql = new MySQLDatabase() {
@Override
public boolean equals(Object o) {
return o == this;
}
};
DatabaseFactory databaseFactory = DatabaseFactory.getInstance();
databaseFactory.register(oracle1);
databaseFactory.register(oracle2);
databaseFactory.register(mysql);
LockServiceFactory lockServiceFactory = LockServiceFactory.getInstance();
assertNotNull(lockServiceFactory.getLockService(oracle1));
assertNotNull(lockServiceFactory.getLockService(oracle2));
assertNotNull(lockServiceFactory.getLockService(mysql));
assertTrue(lockServiceFactory.getLockService(oracle1) == lockServiceFactory.getLockService(oracle1));
assertTrue(lockServiceFactory.getLockService(oracle2) == lockServiceFactory.getLockService(oracle2));
assertTrue(lockServiceFactory.getLockService(mysql) == lockServiceFactory.getLockService(mysql));
assertTrue(lockServiceFactory.getLockService(oracle1) != lockServiceFactory.getLockService(oracle2));
assertTrue(lockServiceFactory.getLockService(oracle1) != lockServiceFactory.getLockService(mysql));
assertTrue(lockServiceFactory.getLockService(getMockDatabase()) instanceof MockLockService);
}
Aggregations