Search in sources :

Example 1 with MockResourceAccessor

use of liquibase.sdk.resource.MockResourceAccessor 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)

Example 2 with MockResourceAccessor

use of liquibase.sdk.resource.MockResourceAccessor in project liquibase by liquibase.

the class LiquibaseTest method constructor.

@Test
public void constructor() throws Exception {
    //going to test log setup
    LogFactory.reset();
    MockResourceAccessor resourceAccessor = this.mockResourceAccessor;
    MockDatabase database = new MockDatabase();
    Liquibase liquibase = new Liquibase("com/example/test.xml", resourceAccessor, database);
    assertNotNull(liquibase.getLog());
    assertEquals("com/example/test.xml", liquibase.getChangeLogFile());
    assertSame(resourceAccessor, liquibase.getResourceAccessor());
    assertNotNull(liquibase.getChangeLogParameters());
    assertEquals("Standard database changelog parameters were not set", "DATABASECHANGELOGLOCK", liquibase.getChangeLogParameters().getValue("database.databaseChangeLogLockTableName", null));
    assertSame(database, liquibase.getDatabase());
}
Also used : MockResourceAccessor(liquibase.sdk.resource.MockResourceAccessor) MockDatabase(liquibase.sdk.database.MockDatabase) Test(org.junit.Test)

Aggregations

MockDatabase (liquibase.sdk.database.MockDatabase)2 MockResourceAccessor (liquibase.sdk.resource.MockResourceAccessor)2 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 Before (org.junit.Before)1 Test (org.junit.Test)1