ProductionLiquibaseRunner implements PreHook { Liquibase createLiquibase(String changelogfile, ResourceAccessor resourceAccessor, DatabaseConnection databaseConnection) throws LiquibaseException { if (liquibaseFactory == null) { liquibaseFactory = new LiquibaseFactory() { @Override public Liquibase create(String changelogfile, ResourceAccessor resourceAccessor, DatabaseConnection databaseConnection) throws LiquibaseException { return new Liquibase(changelogfile, resourceAccessor, databaseConnection); } }; } return liquibaseFactory.create(changelogfile, resourceAccessor, databaseConnection); }  @Reference void setLogService(LogService logService); @Activate void activate(); @Override void prepare(DataSource datasource);  }
@Test public void testCreateLiquibase() throws Exception { ProductionLiquibaseRunner runner = new ProductionLiquibaseRunner(); MockLogService logservice = new MockLogService(); runner.setLogService(logservice); runner.activate(); DatabaseConnection connection = mock(DatabaseConnection.class); when(connection.getDatabaseProductName()).thenReturn("PostgreSQL"); Liquibase liquibase = runner.createLiquibase(null, null, connection); assertNotNull(liquibase); }