Search in sources :

Example 6 with MockDatabase

use of liquibase.sdk.database.MockDatabase in project liquibase by liquibase.

the class LiquibaseTest method setCurrentDateTimeFunction.

@Test
public void setCurrentDateTimeFunction() throws LiquibaseException {
    Database database = mockDatabase;
    String testFunction = "GetMyTime";
    new Liquibase("com/example/test.xml", mockResourceAccessor, database).setCurrentDateTimeFunction(testFunction);
    verify(database).setCurrentDateTimeFunction(testFunction);
}
Also used : MockDatabase(liquibase.sdk.database.MockDatabase) Database(liquibase.database.Database) Test(org.junit.Test)

Example 7 with MockDatabase

use of liquibase.sdk.database.MockDatabase in project liquibase by liquibase.

the class LiquibaseTest method constructor_createDatabaseInstanceFromConnection.

@Test
public void constructor_createDatabaseInstanceFromConnection() throws LiquibaseException {
    DatabaseConnection databaseConnection = mock(DatabaseConnection.class);
    Database database = mockDatabase;
    try {
        DatabaseFactory.setInstance(mock(DatabaseFactory.class));
        when(DatabaseFactory.getInstance().findCorrectDatabaseImplementation(databaseConnection)).thenReturn(database);
        Liquibase liquibase = new Liquibase("com/example/test.xml", mockResourceAccessor, databaseConnection);
        assertSame("Liquibase constructor passing connection did not find the correct database implementation", database, liquibase.getDatabase());
    } finally {
        DatabaseFactory.reset();
    }
}
Also used : DatabaseFactory(liquibase.database.DatabaseFactory) MockDatabase(liquibase.sdk.database.MockDatabase) Database(liquibase.database.Database) DatabaseConnection(liquibase.database.DatabaseConnection) Test(org.junit.Test)

Aggregations

MockDatabase (liquibase.sdk.database.MockDatabase)7 Test (org.junit.Test)5 Database (liquibase.database.Database)4 ChangeLogIterator (liquibase.changelog.ChangeLogIterator)2 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)2 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)2 MockResourceAccessor (liquibase.sdk.resource.MockResourceAccessor)2 ArrayList (java.util.ArrayList)1 Contexts (liquibase.Contexts)1 LabelExpression (liquibase.LabelExpression)1 RuntimeEnvironment (liquibase.RuntimeEnvironment)1 ChangeSet (liquibase.changelog.ChangeSet)1 ChangeSetFilterResult (liquibase.changelog.filter.ChangeSetFilterResult)1 ChangeSetVisitor (liquibase.changelog.visitor.ChangeSetVisitor)1 DatabaseConnection (liquibase.database.DatabaseConnection)1 DatabaseFactory (liquibase.database.DatabaseFactory)1 DB2Database (liquibase.database.core.DB2Database)1 SQLiteDatabase (liquibase.database.core.SQLiteDatabase)1 ExampleCustomDatabase (liquibase.database.example.ExampleCustomDatabase)1 LiquibaseException (liquibase.exception.LiquibaseException)1