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;
}
});
}
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());
}
Aggregations