Search in sources :

Example 1 with MockLockService

use of liquibase.lockservice.ext.MockLockService 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);
}
Also used : OracleDatabase(liquibase.database.core.OracleDatabase) MockLockService(liquibase.lockservice.ext.MockLockService) DatabaseFactory(liquibase.database.DatabaseFactory) MockDatabase(liquibase.sdk.database.MockDatabase) OracleDatabase(liquibase.database.core.OracleDatabase) MySQLDatabase(liquibase.database.core.MySQLDatabase) Database(liquibase.database.Database) MySQLDatabase(liquibase.database.core.MySQLDatabase) Test(org.junit.Test)

Aggregations

Database (liquibase.database.Database)1 DatabaseFactory (liquibase.database.DatabaseFactory)1 MySQLDatabase (liquibase.database.core.MySQLDatabase)1 OracleDatabase (liquibase.database.core.OracleDatabase)1 MockLockService (liquibase.lockservice.ext.MockLockService)1 MockDatabase (liquibase.sdk.database.MockDatabase)1 Test (org.junit.Test)1