mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Add liquibase ui-service property
See gh-39227
This commit is contained in:
parent
dae3952144
commit
d31b02c38d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
@ -22,6 +22,7 @@ import liquibase.UpdateSummaryEnum;
|
||||
import liquibase.UpdateSummaryOutputEnum;
|
||||
import liquibase.change.DatabaseChange;
|
||||
import liquibase.integration.spring.SpringLiquibase;
|
||||
import liquibase.ui.UIServiceEnum;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
@ -122,6 +123,9 @@ public class LiquibaseAutoConfiguration {
|
||||
liquibase
|
||||
.setShowSummaryOutput(UpdateSummaryOutputEnum.valueOf(properties.getShowSummaryOutput().name()));
|
||||
}
|
||||
if (properties.getUiService() != null) {
|
||||
liquibase.setUiService(UIServiceEnum.valueOf(properties.getUiService().name()));
|
||||
}
|
||||
return liquibase;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import liquibase.UpdateSummaryEnum;
|
||||
import liquibase.UpdateSummaryOutputEnum;
|
||||
import liquibase.integration.spring.SpringLiquibase;
|
||||
import liquibase.ui.UIServiceEnum;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.util.Assert;
|
||||
@ -147,6 +148,11 @@ public class LiquibaseProperties {
|
||||
*/
|
||||
private ShowSummaryOutput showSummaryOutput;
|
||||
|
||||
/**
|
||||
* Which UIService to use.
|
||||
*/
|
||||
private UIService uiService;
|
||||
|
||||
public String getChangeLog() {
|
||||
return this.changeLog;
|
||||
}
|
||||
@ -316,6 +322,14 @@ public class LiquibaseProperties {
|
||||
this.showSummaryOutput = showSummaryOutput;
|
||||
}
|
||||
|
||||
public UIService getUiService() {
|
||||
return this.uiService;
|
||||
}
|
||||
|
||||
public void setUiService(UIService uiService) {
|
||||
this.uiService = uiService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumeration of types of summary to show. Values are the same as those on
|
||||
* {@link UpdateSummaryEnum}. To maximize backwards compatibility, the Liquibase enum
|
||||
@ -368,4 +382,25 @@ public class LiquibaseProperties {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumeration of types of UIService. Values are the same as those on
|
||||
* {@link UIServiceEnum}. To maximize backwards compatibility, the Liquibase enum is
|
||||
* not used directly.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*/
|
||||
public enum UIService {
|
||||
|
||||
/**
|
||||
* Console-based UIService.
|
||||
*/
|
||||
CONSOLE,
|
||||
|
||||
/**
|
||||
* Logging-based UIService.
|
||||
*/
|
||||
LOGGER
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1959,6 +1959,10 @@
|
||||
"name": "spring.liquibase.show-summary-output",
|
||||
"defaultValue": "log"
|
||||
},
|
||||
{
|
||||
"name": "spring.liquibase.ui-service",
|
||||
"defaultValue": "logger"
|
||||
},
|
||||
{
|
||||
"name": "spring.mail.test-connection",
|
||||
"description": "Whether to test that the mail server is available on startup.",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
@ -33,6 +33,7 @@ import liquibase.UpdateSummaryEnum;
|
||||
import liquibase.UpdateSummaryOutputEnum;
|
||||
import liquibase.command.core.helpers.ShowSummaryArgument;
|
||||
import liquibase.integration.spring.SpringLiquibase;
|
||||
import liquibase.ui.UIServiceEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
@ -226,6 +227,7 @@ class LiquibaseAutoConfigurationTests {
|
||||
assertThat(liquibase).extracting("showSummary").isNull();
|
||||
assertThat(ShowSummaryArgument.SHOW_SUMMARY.getDefaultValue()).isEqualTo(UpdateSummaryEnum.SUMMARY);
|
||||
assertThat(liquibase).extracting("showSummaryOutput").isEqualTo(UpdateSummaryOutputEnum.LOG);
|
||||
assertThat(liquibase).extracting("uiService").isEqualTo(UIServiceEnum.LOGGER);
|
||||
}));
|
||||
}
|
||||
|
||||
@ -411,6 +413,16 @@ class LiquibaseAutoConfigurationTests {
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
void overrideUiService() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("spring.liquibase.ui-service=console")
|
||||
.run(assertLiquibase((liquibase) -> {
|
||||
UIServiceEnum uiService = (UIServiceEnum) ReflectionTestUtils.getField(liquibase, "uiService");
|
||||
assertThat(uiService).isEqualTo(UIServiceEnum.CONSOLE);
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void testOverrideParameters() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
@ -21,10 +21,12 @@ import java.util.stream.Stream;
|
||||
|
||||
import liquibase.UpdateSummaryEnum;
|
||||
import liquibase.UpdateSummaryOutputEnum;
|
||||
import liquibase.ui.UIServiceEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties.ShowSummary;
|
||||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties.ShowSummaryOutput;
|
||||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties.UIService;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ -45,6 +47,11 @@ public class LiquibasePropertiesTests {
|
||||
assertThat(namesOf(ShowSummaryOutput.values())).isEqualTo(namesOf(UpdateSummaryOutputEnum.values()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void valuesOfUiServiceMatchValuesOfUiServiceEnum() {
|
||||
assertThat(namesOf(UIService.values())).isEqualTo(namesOf(UIServiceEnum.values()));
|
||||
}
|
||||
|
||||
private List<String> namesOf(Enum<?>[] input) {
|
||||
return Stream.of(input).map(Enum::name).toList();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user