Merge branch '2.1.x'

Closes gh-16461
pull/16474/head
Andy Wilkinson 6 years ago
commit 537a97c1e5

@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -87,6 +87,10 @@ public class LiquibaseEndpoint {
if (StringUtils.hasText(defaultSchema)) {
database.setDefaultSchemaName(defaultSchema);
}
database.setDatabaseChangeLogTableName(
liquibase.getDatabaseChangeLogTable());
database.setDatabaseChangeLogLockTableName(
liquibase.getDatabaseChangeLogLockTable());
service.setDatabase(database);
return new LiquibaseBean(service.getRanChangeSets().stream()
.map(ChangeSet::new).collect(Collectors.toList()));

@ -18,11 +18,13 @@ package org.springframework.boot.actuate.liquibase;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import javax.sql.DataSource;
import org.junit.Test;
import org.springframework.boot.actuate.liquibase.LiquibaseEndpoint.LiquibaseBean;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
@ -49,11 +51,12 @@ public class LiquibaseEndpointTests {
@Test
public void liquibaseReportIsReturned() {
this.contextRunner.withUserConfiguration(Config.class)
.run((context) -> assertThat(
context.getBean(LiquibaseEndpoint.class).liquibaseBeans()
.getContexts().get(context.getId()).getLiquibaseBeans())
.hasSize(1));
this.contextRunner.withUserConfiguration(Config.class).run((context) -> {
Map<String, LiquibaseBean> liquibaseBeans = context
.getBean(LiquibaseEndpoint.class).liquibaseBeans().getContexts()
.get(context.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
});
}
@Test
@ -61,10 +64,27 @@ public class LiquibaseEndpointTests {
this.contextRunner.withUserConfiguration(Config.class)
.withPropertyValues("spring.liquibase.default-schema=CUSTOMSCHEMA",
"spring.datasource.schema=classpath:/db/create-custom-schema.sql")
.run((context) -> assertThat(
context.getBean(LiquibaseEndpoint.class).liquibaseBeans()
.getContexts().get(context.getId()).getLiquibaseBeans())
.hasSize(1));
.run((context) -> {
Map<String, LiquibaseBean> liquibaseBeans = context
.getBean(LiquibaseEndpoint.class).liquibaseBeans()
.getContexts().get(context.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets())
.hasSize(1);
});
}
@Test
public void invokeWithCustomTables() {
this.contextRunner.withUserConfiguration(Config.class).withPropertyValues(
"spring.liquibase.database-change-log-lock-table=liquibase_database_changelog_lock",
"spring.liquibase.database-change-log-table=liquibase_database_changelog")
.run((context) -> {
Map<String, LiquibaseBean> liquibaseBeans = context
.getBean(LiquibaseEndpoint.class).liquibaseBeans()
.getContexts().get(context.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets())
.hasSize(1);
});
}
@Test

Loading…
Cancel
Save