Search in sources :

Example 1 with LogFactory

use of liquibase.logging.LogFactory in project liquibase by liquibase.

the class LiquibaseTest method before.

//    private TestLiquibase testLiquibase;
//    private DatabaseConnection connectionForConstructor;
@Before
public void before() throws Exception {
    //        if (connectionForConstructor != null) {
    //            reset(connectionForConstructor);
    //        }
    //        connectionForConstructor = createMock(DatabaseConnection.class);
    //        connectionForConstructor.setAutoCommit(false);
    //        expectLastCall().atLeastOnce();
    //
    //        DatabaseMetaData metaData = createMock(DatabaseMetaData.class);
    //        expect(metaData.getDatabaseProductName()).andReturn("Oracle");
    //        replay(metaData);
    //
    ////        expect(connectionForConstructor.getMetaData()).andReturn(metaData);
    //        replay(connectionForConstructor);
    //
    //        testLiquibase = new TestLiquibase();
    mockResourceAccessor = new MockResourceAccessor();
    mockDatabase = mock(Database.class);
    mockLockService = mock(LockService.class);
    mockLockServiceFactory = mock(LockServiceFactory.class);
    mockChangeLogParserFactory = mock(ChangeLogParserFactory.class);
    mockChangeLogParser = mock(ChangeLogParser.class);
    mockChangeLog = mock(DatabaseChangeLog.class);
    mockChangeLogIterator = mock(ChangeLogIterator.class);
    mockLogger = mock(Logger.class);
    LockServiceFactory.setInstance(mockLockServiceFactory);
    when(mockLockServiceFactory.getLockService(any(Database.class))).thenReturn(mockLockService);
    ChangeLogParserFactory.setInstance(mockChangeLogParserFactory);
    when(mockChangeLogParserFactory.getParser(anyString(), Mockito.isA(ResourceAccessor.class))).thenReturn(mockChangeLogParser);
    when(mockChangeLogParser.parse(anyString(), any(ChangeLogParameters.class), Mockito.isA(ResourceAccessor.class))).thenReturn(mockChangeLog);
    LogFactory.setInstance(new LogFactory() {

        @Override
        public Logger getLog(String name) {
            return mockLogger;
        }
    });
}
Also used : MockResourceAccessor(liquibase.sdk.resource.MockResourceAccessor) ResourceAccessor(liquibase.resource.ResourceAccessor) LockService(liquibase.lockservice.LockService) LockServiceFactory(liquibase.lockservice.LockServiceFactory) ChangeLogParserFactory(liquibase.parser.ChangeLogParserFactory) Logger(liquibase.logging.Logger) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) LogFactory(liquibase.logging.LogFactory) MockResourceAccessor(liquibase.sdk.resource.MockResourceAccessor) ChangeLogIterator(liquibase.changelog.ChangeLogIterator) ChangeLogParameters(liquibase.changelog.ChangeLogParameters) ChangeLogParser(liquibase.parser.ChangeLogParser) MockDatabase(liquibase.sdk.database.MockDatabase) Database(liquibase.database.Database) Before(org.junit.Before)

Aggregations

ChangeLogIterator (liquibase.changelog.ChangeLogIterator)1 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)1 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)1 Database (liquibase.database.Database)1 LockService (liquibase.lockservice.LockService)1 LockServiceFactory (liquibase.lockservice.LockServiceFactory)1 LogFactory (liquibase.logging.LogFactory)1 Logger (liquibase.logging.Logger)1 ChangeLogParser (liquibase.parser.ChangeLogParser)1 ChangeLogParserFactory (liquibase.parser.ChangeLogParserFactory)1 ResourceAccessor (liquibase.resource.ResourceAccessor)1 MockDatabase (liquibase.sdk.database.MockDatabase)1 MockResourceAccessor (liquibase.sdk.resource.MockResourceAccessor)1 Before (org.junit.Before)1