Skip to content

Commit

Permalink
Merge branch 'main' into artemis-service-connection
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez committed Jan 30, 2024
2 parents 8a66735 + 10e750a commit 2e0349d
Show file tree
Hide file tree
Showing 26 changed files with 153 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-pull-request.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: gradle/wrapper-validation-action@v1

- name: Set up Gradle
uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2
uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa

- name: Build
env:
Expand Down
Expand Up @@ -64,6 +64,9 @@ class EnvironmentEndpointDocumentationTests extends MockMvcEndpointDocumentation
private static final FieldDescriptor activeProfiles = fieldWithPath("activeProfiles")
.description("Names of the active profiles, if any.");

private static final FieldDescriptor defaultProfiles = fieldWithPath("defaultProfiles")
.description("Names of the default profiles, if any.");

private static final FieldDescriptor propertySources = fieldWithPath("propertySources")
.description("Property sources in order of precedence.");

Expand All @@ -79,7 +82,7 @@ void env() throws Exception {
replacePattern(Pattern.compile(
"org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/"), ""),
filterProperties()),
responseFields(activeProfiles, propertySources, propertySourceName,
responseFields(activeProfiles, defaultProfiles, propertySources, propertySourceName,
fieldWithPath("propertySources.[].properties")
.description("Properties in the property source keyed by property name."),
fieldWithPath("propertySources.[].properties.*.value")
Expand All @@ -101,7 +104,7 @@ void singlePropertyFromEnv() throws Exception {
.optional(),
fieldWithPath("property.source").description("Name of the source of the property."),
fieldWithPath("property.value").description("Value of the property."), activeProfiles,
propertySources, propertySourceName,
defaultProfiles, propertySources, propertySourceName,
fieldWithPath("propertySources.[].property")
.description("Property in the property source, if any.")
.optional(),
Expand Down
Expand Up @@ -101,7 +101,8 @@ private EnvironmentDescriptor getEnvironmentDescriptor(Predicate<String> propert
propertyNamePredicate, showUnsanitized));
}
});
return new EnvironmentDescriptor(Arrays.asList(this.environment.getActiveProfiles()), propertySources);
return new EnvironmentDescriptor(Arrays.asList(this.environment.getActiveProfiles()),
Arrays.asList(this.environment.getDefaultProfiles()), propertySources);
}

@ReadOperation
Expand All @@ -114,7 +115,7 @@ EnvironmentEntryDescriptor getEnvironmentEntryDescriptor(String propertyName, bo
Map<String, PropertyValueDescriptor> descriptors = getPropertySourceDescriptors(propertyName, showUnsanitized);
PropertySummaryDescriptor summary = getPropertySummaryDescriptor(descriptors);
return new EnvironmentEntryDescriptor(summary, Arrays.asList(this.environment.getActiveProfiles()),
toPropertySourceDescriptors(descriptors));
Arrays.asList(this.environment.getDefaultProfiles()), toPropertySourceDescriptors(descriptors));
}

private List<PropertySourceEntryDescriptor> toPropertySourceDescriptors(
Expand Down Expand Up @@ -209,17 +210,25 @@ public static final class EnvironmentDescriptor implements OperationResponseBody

private final List<String> activeProfiles;

private final List<String> defaultProfiles;

private final List<PropertySourceDescriptor> propertySources;

private EnvironmentDescriptor(List<String> activeProfiles, List<PropertySourceDescriptor> propertySources) {
private EnvironmentDescriptor(List<String> activeProfiles, List<String> defaultProfiles,
List<PropertySourceDescriptor> propertySources) {
this.activeProfiles = activeProfiles;
this.defaultProfiles = defaultProfiles;
this.propertySources = propertySources;
}

public List<String> getActiveProfiles() {
return this.activeProfiles;
}

public List<String> getDefaultProfiles() {
return this.defaultProfiles;
}

public List<PropertySourceDescriptor> getPropertySources() {
return this.propertySources;
}
Expand All @@ -236,12 +245,15 @@ public static final class EnvironmentEntryDescriptor {

private final List<String> activeProfiles;

private final List<String> defaultProfiles;

private final List<PropertySourceEntryDescriptor> propertySources;

EnvironmentEntryDescriptor(PropertySummaryDescriptor property, List<String> activeProfiles,
List<PropertySourceEntryDescriptor> propertySources) {
List<String> defaultProfiles, List<PropertySourceEntryDescriptor> propertySources) {
this.property = property;
this.activeProfiles = activeProfiles;
this.defaultProfiles = defaultProfiles;
this.propertySources = propertySources;
}

Expand All @@ -253,6 +265,10 @@ public List<String> getActiveProfiles() {
return this.activeProfiles;
}

public List<String> getDefaultProfiles() {
return this.defaultProfiles;
}

public List<PropertySourceEntryDescriptor> getPropertySources() {
return this.propertySources;
}
Expand Down
Expand Up @@ -86,7 +86,8 @@ void whenShowValuesIsWhenAuthorizedAndSecurityContextIsNotAuthorized() {

private void verifyPrefixed(SecurityContext securityContext, boolean showUnsanitized) {
given(this.delegate.getEnvironmentEntryDescriptor("test", showUnsanitized))
.willReturn(new EnvironmentEntryDescriptor(null, Collections.emptyList(), Collections.emptyList()));
.willReturn(new EnvironmentEntryDescriptor(null, Collections.emptyList(), Collections.emptyList(),
Collections.emptyList()));
this.webExtension.environmentEntry(securityContext, "test");
then(this.delegate).should().getEnvironmentEntryDescriptor("test", showUnsanitized);
}
Expand Down
@@ -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.
Expand All @@ -22,6 +22,7 @@
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;
Expand Down Expand Up @@ -122,6 +123,9 @@ public SpringLiquibase liquibase(ObjectProvider<DataSource> dataSource,
liquibase
.setShowSummaryOutput(UpdateSummaryOutputEnum.valueOf(properties.getShowSummaryOutput().name()));
}
if (properties.getUiService() != null) {
liquibase.setUiService(UIServiceEnum.valueOf(properties.getUiService().name()));
}
return liquibase;
}

Expand Down
@@ -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.
Expand All @@ -22,6 +22,7 @@
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;
Expand Down Expand Up @@ -147,6 +148,11 @@ public class LiquibaseProperties {
*/
private ShowSummaryOutput showSummaryOutput;

/**
* Which UIService to use.
*/
private UIService uiService;

public String getChangeLog() {
return this.changeLog;
}
Expand Down Expand Up @@ -316,6 +322,14 @@ public void setShowSummaryOutput(ShowSummaryOutput showSummaryOutput) {
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
Expand Down Expand Up @@ -368,4 +382,25 @@ public enum ShowSummaryOutput {

}

/**
* 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

}

}
Expand Up @@ -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.",
Expand Down
@@ -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.
Expand Down Expand Up @@ -33,6 +33,7 @@
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;
Expand Down Expand Up @@ -226,6 +227,7 @@ void defaultValues() {
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);
}));
}

Expand Down Expand Up @@ -411,6 +413,16 @@ void overrideShowSummaryOutput() {
}));
}

@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() {
Expand Down
@@ -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.
Expand All @@ -21,10 +21,12 @@

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;

Expand All @@ -45,6 +47,11 @@ void valuesOfShowSummaryOutputMatchValuesOfUpdateSummaryOutputEnum() {
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();
}
Expand Down
@@ -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.
Expand All @@ -16,7 +16,6 @@

package org.springframework.boot.docker.compose.service.connection.activemq;

import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQConnectionDetails;
import org.springframework.boot.docker.compose.core.RunningService;
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
Expand All @@ -43,7 +42,7 @@ protected ActiveMQConnectionDetails getDockerComposeConnectionDetails(DockerComp
}

/**
* {@link RabbitConnectionDetails} backed by a {@code rabbitmq}
* {@link ActiveMQConnectionDetails} backed by a {@code activemq}
* {@link RunningService}.
*/
static class ActiveMQDockerComposeConnectionDetails extends DockerComposeConnectionDetails
Expand Down
2 changes: 1 addition & 1 deletion spring-boot-project/spring-boot-parent/build.gradle
Expand Up @@ -34,7 +34,7 @@ bom {
]
}
}
library("Commons Compress", "1.23.0") {
library("Commons Compress", "1.25.0") {
group("org.apache.commons") {
modules = [
"commons-compress"
Expand Down
Expand Up @@ -27,7 +27,7 @@ dependencies {
api("com.fasterxml.jackson.core:jackson-databind")
api("com.fasterxml.jackson.module:jackson-module-parameter-names")
api("net.java.dev.jna:jna-platform")
api("org.apache.commons:commons-compress:1.19")
api("org.apache.commons:commons-compress")
api("org.apache.httpcomponents.client5:httpclient5")
api("org.springframework:spring-core")
api("org.tomlj:tomlj:1.0.0")
Expand Down
@@ -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.
Expand Down Expand Up @@ -131,12 +131,12 @@ private void copyLayerTar(Path path, OutputStream out) throws IOException {
try (TarArchiveInputStream tarIn = new TarArchiveInputStream(Files.newInputStream(path));
TarArchiveOutputStream tarOut = new TarArchiveOutputStream(out)) {
tarOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
TarArchiveEntry entry = tarIn.getNextTarEntry();
TarArchiveEntry entry = tarIn.getNextEntry();
while (entry != null) {
tarOut.putArchiveEntry(entry);
StreamUtils.copy(tarIn, tarOut);
tarOut.closeArchiveEntry();
entry = tarIn.getNextTarEntry();
entry = tarIn.getNextEntry();
}
tarOut.finish();
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 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.
Expand Down Expand Up @@ -90,13 +90,13 @@ private void copyAndRebaseEntries(OutputStream outputStream) throws IOException
new GzipCompressorInputStream(Files.newInputStream(this.path)));
TarArchiveOutputStream output = new TarArchiveOutputStream(outputStream)) {
writeBasePathEntries(output, basePath);
TarArchiveEntry entry = tar.getNextTarEntry();
TarArchiveEntry entry = tar.getNextEntry();
while (entry != null) {
entry.setName(basePath + "/" + entry.getName());
output.putArchiveEntry(entry);
StreamUtils.copy(tar, output);
output.closeArchiveEntry();
entry = tar.getNextTarEntry();
entry = tar.getNextEntry();
}
output.finish();
}
Expand Down

0 comments on commit 2e0349d

Please sign in to comment.