Merge branch '3.3.x' into 3.4.x

Closes gh-44634
This commit is contained in:
Andy Wilkinson 2025-03-06 18:32:07 +00:00
commit ab66034e1b
47 changed files with 178 additions and 169 deletions

View File

@ -53,6 +53,7 @@ import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurity
import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
@ -272,6 +273,21 @@ class ReactiveCloudFoundryActuatorAutoConfigurationTests {
}
@Test
@WithResource(name = "git.properties", content = """
#Generated by Git-Commit-Id-Plugin
#Thu May 23 09:26:42 BST 2013
git.commit.id.abbrev=e02a4f3
git.commit.user.email=dsyer@vmware.com
git.commit.message.full=Update Spring
git.commit.id=e02a4f3b6f452cdbf6dd311f1362679eb4c31ced
git.commit.message.short=Update Spring
git.commit.user.name=Dave Syer
git.build.user.name=Dave Syer
git.build.user.email=dsyer@vmware.com
git.branch=develop
git.commit.time=2013-04-24T08\\:42\\:13+0100
git.build.time=2013-05-23T09\\:26\\:42+0100
""")
@SuppressWarnings("unchecked")
void gitFullDetailsAlwaysPresent() {
this.contextRunner.withPropertyValues("VCAP_APPLICATION:---").run((context) -> {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@ -37,6 +37,7 @@ import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfigu
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithResource;
import static org.assertj.core.api.Assertions.assertThat;
@ -59,6 +60,21 @@ class CloudFoundryInfoEndpointWebExtensionTests {
HealthEndpointAutoConfiguration.class, CloudFoundryActuatorAutoConfiguration.class));
@Test
@WithResource(name = "git.properties", content = """
#Generated by Git-Commit-Id-Plugin
#Thu May 23 09:26:42 BST 2013
git.commit.id.abbrev=e02a4f3
git.commit.user.email=dsyer@vmware.com
git.commit.message.full=Update Spring
git.commit.id=e02a4f3b6f452cdbf6dd311f1362679eb4c31ced
git.commit.message.short=Update Spring
git.commit.user.name=Dave Syer
git.build.user.name=Dave Syer
git.build.user.email=dsyer@vmware.com
git.branch=develop
git.commit.time=2013-04-24T08\\:42\\:13+0100
git.build.time=2013-05-23T09\\:26\\:42+0100
""")
@SuppressWarnings("unchecked")
void gitFullDetailsAlwaysPresent() {
this.contextRunner.run((context) -> {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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,6 +21,7 @@ import javax.net.ssl.SSLHandshakeException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.boot.testsupport.web.servlet.ExampleServlet;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.Ssl;
@ -49,6 +50,7 @@ class SkipSslVerificationHttpRequestFactoryTests {
}
@Test
@WithPackageResources("test.jks")
void restCallToSelfSignedServerShouldNotThrowSslException() {
String httpsUrl = getHttpsUrl();
SkipSslVerificationHttpRequestFactory requestFactory = new SkipSslVerificationHttpRequestFactory();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -34,6 +34,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.context.TestPropertySource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
@ -44,6 +45,8 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.response
*
* @author Andy Wilkinson
*/
@TestPropertySource(
properties = "spring.flyway.locations=classpath:org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation")
class FlywayEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -31,6 +31,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
import org.springframework.test.context.TestPropertySource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
@ -41,6 +42,8 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.response
*
* @author Andy Wilkinson
*/
@TestPropertySource(
properties = "spring.liquibase.change-log=classpath:org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/db.changelog-master.yaml")
class LiquibaseEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -58,7 +58,9 @@ class SbomEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
@Bean
SbomProperties sbomProperties() {
SbomProperties properties = new SbomProperties();
properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
properties.getApplication()
.setLocation(
"classpath:org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/cyclonedx.json");
return properties;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@ -26,6 +26,7 @@ import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithResource;
import static org.assertj.core.api.Assertions.assertThat;
@ -34,6 +35,20 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Dmytro Nosan
*/
@WithResource(name = "hazelcast.xml", content = """
<hazelcast
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-5.0.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<map name="defaultCache" />
<network>
<join>
<auto-detection enabled="false"/>
<multicast enabled="false"/>
</join>
</network>
</hazelcast>
""")
class HazelcastHealthContributorAutoConfigurationIntegrationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@ -23,6 +23,7 @@ import org.springframework.boot.actuate.hazelcast.HazelcastHealthIndicator;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithResource;
import static org.assertj.core.api.Assertions.assertThat;
@ -31,6 +32,20 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Dmytro Nosan
*/
@WithResource(name = "hazelcast.xml", content = """
<hazelcast
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-5.0.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<map name="defaultCache" />
<network>
<join>
<auto-detection enabled="false"/>
<multicast enabled="false"/>
</join>
</network>
</hazelcast>
""")
class HazelcastHealthContributorAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()

View File

@ -41,6 +41,7 @@ import org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConf
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
@ -138,6 +139,17 @@ class HibernateMetricsAutoConfigurationTests {
}
@Test
@WithResource(name = "city-schema.sql", content = """
CREATE TABLE CITY (
id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name VARCHAR(30),
state VARCHAR(30),
country VARCHAR(30),
map VARCHAR(30)
);
""")
@WithResource(name = "city-data.sql",
content = "INSERT INTO CITY (ID, NAME, STATE, COUNTRY, MAP) values (2000, 'Washington', 'DC', 'US', 'Google');")
void entityManagerFactoryInstrumentationDoesNotDeadlockWithDeferredInitialization() {
this.contextRunner
.withPropertyValues("spring.jpa.properties.hibernate.generate_statistics:true",

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@ -31,6 +31,7 @@ import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactor
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext;
@ -132,13 +133,14 @@ class JettyMetricsAutoConfigurationTests {
}
@Test
@WithPackageResources("test.jks")
void autoConfiguresSslHandshakeMetricsWithEmbeddedServletJetty() {
new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new)
.withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class))
.withUserConfiguration(ServletWebServerConfiguration.class, MeterRegistryConfiguration.class)
.withPropertyValues("server.ssl.enabled: true", "server.ssl.key-store: src/test/resources/test.jks",
"server.ssl.key-store-password: secret", "server.ssl.key-password: password")
.withPropertyValues("server.ssl.enabled=true", "server.ssl.key-store=classpath:test.jks",
"server.ssl.key-store-password=secret", "server.ssl.key-password=password")
.run((context) -> {
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
assertThat(context).hasSingleBean(JettySslHandshakeMetricsBinder.class);
@ -148,13 +150,14 @@ class JettyMetricsAutoConfigurationTests {
}
@Test
@WithPackageResources("test.jks")
void autoConfiguresSslHandshakeMetricsWithEmbeddedReactiveJetty() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new)
.withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class,
ReactiveWebServerFactoryAutoConfiguration.class))
.withUserConfiguration(ReactiveWebServerConfiguration.class, MeterRegistryConfiguration.class)
.withPropertyValues("server.ssl.enabled: true", "server.ssl.key-store: src/test/resources/test.jks",
"server.ssl.key-store-password: secret", "server.ssl.key-password: password")
.withPropertyValues("server.ssl.enabled=true", "server.ssl.key-store=classpath:test.jks",
"server.ssl.key-store-password=secret", "server.ssl.key-password=password")
.run((context) -> {
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
@ -163,14 +166,15 @@ class JettyMetricsAutoConfigurationTests {
}
@Test
@WithPackageResources("test.jks")
void allowsCustomJettySslHandshakeMetricsBinderToBeUsed() {
new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new)
.withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class))
.withUserConfiguration(ServletWebServerConfiguration.class, CustomJettySslHandshakeMetricsBinder.class,
MeterRegistryConfiguration.class)
.withPropertyValues("server.ssl.enabled: true", "server.ssl.key-store: src/test/resources/test.jks",
"server.ssl.key-store-password: secret", "server.ssl.key-password: password")
.withPropertyValues("server.ssl.enabled=true", "server.ssl.key-store=classpath:test.jks",
"server.ssl.key-store-password=secret", "server.ssl.key-password=password")
.run((context) -> {
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
assertThat(context).hasSingleBean(JettySslHandshakeMetricsBinder.class)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -37,6 +37,7 @@ import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguratio
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
@ -143,13 +144,14 @@ class ManagementWebSecurityAutoConfigurationTests {
}
@Test
@WithPackageResources("saml-certificate")
void backOffIfSaml2RelyingPartyAutoConfigurationPresent() {
this.contextRunner.withConfiguration(AutoConfigurations.of(Saml2RelyingPartyAutoConfiguration.class))
.withPropertyValues(
"spring.security.saml2.relyingparty.registration.simplesamlphp.assertingparty.single-sign-on.url=https://simplesaml-for-spring-saml/SSOService.php",
"spring.security.saml2.relyingparty.registration.simplesamlphp.assertingparty.single-sign-on.sign-request=false",
"spring.security.saml2.relyingparty.registration.simplesamlphp.assertingparty.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
"spring.security.saml2.relyingparty.registration.simplesamlphp.assertingparty.verification.credentials[0].certificate-location=classpath:saml/certificate-location")
"spring.security.saml2.relyingparty.registration.simplesamlphp.assertingparty.verification.credentials[0].certificate-location=classpath:saml-certificate")
.run((context) -> assertThat(context).doesNotHaveBean(ManagementWebSecurityAutoConfiguration.class)
.doesNotHaveBean(MANAGEMENT_SECURITY_FILTER_CHAIN_BEAN));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -32,6 +32,7 @@ import org.springframework.boot.info.SslInfo;
import org.springframework.boot.info.SslInfo.CertificateChainInfo;
import org.springframework.boot.ssl.SslBundles;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -42,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Jonatan Ivanov
*/
@WithPackageResources("test.jks")
class SslHealthContributorAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()

View File

@ -1 +0,0 @@
INSERT INTO CITY (ID, NAME, STATE, COUNTRY, MAP) values (2000, 'Washington', 'DC', 'US', 'Google');

View File

@ -1,7 +0,0 @@
CREATE TABLE CITY (
id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name VARCHAR(30),
state VARCHAR(30),
country VARCHAR(30),
map VARCHAR(30)
);

View File

@ -1,13 +0,0 @@
#Generated by Git-Commit-Id-Plugin
#Thu May 23 09:26:42 BST 2013
git.commit.id.abbrev=e02a4f3
git.commit.user.email=dsyer@vmware.com
git.commit.message.full=Update Spring
git.commit.id=e02a4f3b6f452cdbf6dd311f1362679eb4c31ced
git.commit.message.short=Update Spring
git.commit.user.name=Dave Syer
git.build.user.name=Dave Syer
git.build.user.email=dsyer@vmware.com
git.branch=develop
git.commit.time=2013-04-24T08\:42\:13+0100
git.build.time=2013-05-23T09\:26\:42+0100

View File

@ -1,12 +0,0 @@
<hazelcast
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-5.0.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<map name="defaultCache" />
<network>
<join>
<auto-detection enabled="false"/>
<multicast enabled="false"/>
</join>
</network>
</hazelcast>

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithResource;
import static org.assertj.core.api.Assertions.assertThat;
@ -36,6 +37,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson
* @author Phillip Webb
*/
@WithResource(name = "db/migration/V1__init.sql", content = "DROP TABLE IF EXISTS TEST;")
@WithResource(name = "db/migration/V2__update.sql", content = "DROP TABLE IF EXISTS TEST;")
@WithResource(name = "db/migration/V3__update.sql", content = "DROP TABLE IF EXISTS TEST;")
class FlywayEndpointTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@ -25,6 +25,7 @@ import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithResource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@ -40,6 +41,21 @@ import static org.mockito.Mockito.mock;
class HazelcastHealthIndicatorTests {
@Test
@WithResource(name = "hazelcast.xml", content = """
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-5.0.xsd">
<instance-name>actuator-hazelcast</instance-name>
<map name="defaultCache" />
<network>
<join>
<auto-detection enabled="false"/>
<multicast enabled="false"/>
</join>
</network>
</hazelcast>
""")
void hazelcastUp() {
new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(HazelcastAutoConfiguration.class))
.withPropertyValues("spring.hazelcast.config=hazelcast.xml")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@ -35,6 +35,7 @@ import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
import org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer;
import org.springframework.boot.sql.init.DatabaseInitializationSettings;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -50,6 +51,12 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
* @author Leo Li
*/
@WithResource(name = "db/changelog/db.changelog-master.yaml", content = """
databaseChangeLog:
- changeSet:
id: 1
author: test
""")
class LiquibaseEndpointTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
@ -83,6 +90,7 @@ class LiquibaseEndpointTests {
}
@Test
@WithResource(name = "db/create-custom-schema.sql", content = "CREATE SCHEMA CUSTOMSCHEMA;")
void invokeWithCustomSchema() {
this.contextRunner.withUserConfiguration(Config.class, DataSourceWithSchemaConfiguration.class)
.withPropertyValues("spring.liquibase.default-schema=CUSTOMSCHEMA")
@ -122,6 +130,12 @@ class LiquibaseEndpointTests {
}
@Test
@WithResource(name = "db/changelog/db.changelog-master-backup.yaml", content = """
databaseChangeLog:
- changeSet:
id: 1
author: test
""")
void whenMultipleLiquibaseBeansArePresentChangeSetsAreCorrectlyReportedForEachBean() {
this.contextRunner.withUserConfiguration(Config.class, MultipleDataSourceLiquibaseConfiguration.class)
.run((context) -> {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -51,7 +51,7 @@ class SbomEndpointCycloneDxWebIntegrationTests {
@Bean
SbomProperties sbomProperties() {
SbomProperties properties = new SbomProperties();
properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
return properties;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -51,7 +51,7 @@ class SbomEndpointSpdxWebIntegrationTests {
@Bean
SbomProperties sbomProperties() {
SbomProperties properties = new SbomProperties();
properties.getApplication().setLocation("classpath:sbom/spdx.json");
properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/spdx.json");
return properties;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -51,7 +51,7 @@ class SbomEndpointSyftWebIntegrationTests {
@Bean
SbomProperties sbomProperties() {
SbomProperties properties = new SbomProperties();
properties.getApplication().setLocation("classpath:sbom/syft.json");
properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/syft.json");
return properties;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -48,9 +48,11 @@ class SbomEndpointTests {
@Test
void shouldListSboms() {
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
this.properties.getAdditional().put("alpha", sbom("classpath:sbom/cyclonedx.json"));
this.properties.getAdditional().put("beta", sbom("classpath:sbom/cyclonedx.json"));
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
this.properties.getAdditional()
.put("alpha", sbom("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json"));
this.properties.getAdditional()
.put("beta", sbom("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json"));
Sboms sboms = createEndpoint().sboms();
assertThat(sboms.ids()).containsExactly("alpha", "application", "beta");
}
@ -58,15 +60,16 @@ class SbomEndpointTests {
@Test
void shouldFailIfDuplicateSbomIdIsRegistered() {
// This adds an SBOM with id 'application'
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
this.properties.getAdditional().put("application", sbom("classpath:sbom/cyclonedx.json"));
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
this.properties.getAdditional()
.put("application", sbom("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json"));
assertThatIllegalStateException().isThrownBy(this::createEndpoint)
.withMessage("Duplicate SBOM registration with id 'application'");
}
@Test
void shouldUseLocationFromProperties() throws IOException {
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
String content = createEndpoint().sbom("application").getContentAsString(StandardCharsets.UTF_8);
assertThat(content).contains("\"bomFormat\" : \"CycloneDX\"");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -30,6 +30,7 @@ import org.junit.jupiter.params.provider.EnumSource.Mode;
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
import org.springframework.boot.actuate.sbom.SbomEndpointWebExtension.SbomType;
import org.springframework.boot.actuate.sbom.SbomProperties.Sbom;
import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
@ -53,7 +54,7 @@ class SbomEndpointWebExtensionTests {
@Test
void shouldReturnHttpOk() {
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
assertThat(response.getStatus()).isEqualTo(200);
}
@ -66,26 +67,27 @@ class SbomEndpointWebExtensionTests {
@Test
void shouldAutoDetectContentTypeForCycloneDx() {
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("application/vnd.cyclonedx+json"));
}
@Test
void shouldAutoDetectContentTypeForSpdx() {
this.properties.getApplication().setLocation("classpath:sbom/spdx.json");
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/spdx.json");
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("application/spdx+json"));
}
@Test
void shouldAutoDetectContentTypeForSyft() {
this.properties.getApplication().setLocation("classpath:sbom/syft.json");
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/syft.json");
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("application/vnd.syft+json"));
}
@Test
@WithResource(name = "git.properties", content = "git.commit.id.abbrev=e02a4f3")
void shouldSupportUnknownFiles() {
this.properties.getApplication().setLocation("classpath:git.properties");
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
@ -94,7 +96,7 @@ class SbomEndpointWebExtensionTests {
@Test
void shouldUseContentTypeIfSet() {
this.properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
this.properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
this.properties.getApplication().setMediaType(MimeType.valueOf("text/plain"));
WebEndpointResponse<Resource> response = createWebExtension().sbom("application");
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("text/plain"));
@ -103,7 +105,8 @@ class SbomEndpointWebExtensionTests {
@Test
void shouldUseContentTypeForAdditionalSbomsIfSet() {
this.properties.getAdditional()
.put("alpha", sbom("classpath:sbom/cyclonedx.json", MediaType.valueOf("text/plain")));
.put("alpha", sbom("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json",
MediaType.valueOf("text/plain")));
WebEndpointResponse<Resource> response = createWebExtension().sbom("alpha");
assertThat(response.getContentType()).isEqualTo(MimeType.valueOf("text/plain"));
}
@ -120,9 +123,9 @@ class SbomEndpointWebExtensionTests {
private String getSbomContent(SbomType type) throws IOException {
return switch (type) {
case CYCLONE_DX -> readResource("/sbom/cyclonedx.json");
case SPDX -> readResource("/sbom/spdx.json");
case SYFT -> readResource("/sbom/syft.json");
case CYCLONE_DX -> readResource("cyclonedx.json");
case SPDX -> readResource("spdx.json");
case SYFT -> readResource("syft.json");
case UNKNOWN -> throw new IllegalArgumentException("UNKNOWN is not supported");
};
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@ -54,7 +54,7 @@ class SbomEndpointWebIntegrationTests {
@Bean
SbomProperties sbomProperties() {
SbomProperties properties = new SbomProperties();
properties.getApplication().setLocation("classpath:sbom/cyclonedx.json");
properties.getApplication().setLocation("classpath:org/springframework/boot/actuate/sbom/cyclonedx.json");
return properties;
}

View File

@ -1,20 +0,0 @@
databaseChangeLog:
- changeSet:
id: 1
author: leoli
changes:
- createTable:
tableName: customerbackup
columns:
- column:
name: id
type: int
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: name
type: varchar(50)
constraints:
nullable: false

View File

@ -1,20 +0,0 @@
databaseChangeLog:
- changeSet:
id: 1
author: marceloverdijk
changes:
- createTable:
tableName: customer
columns:
- column:
name: id
type: int
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: name
type: varchar(50)
constraints:
nullable: false

View File

@ -1,13 +0,0 @@
#Generated by Git-Commit-Id-Plugin
#Thu May 23 09:26:42 BST 2013
git.commit.id.abbrev=e02a4f3
git.commit.user.email=dsyer@vmware.com
git.commit.message.full=Update Spring
git.commit.id=e02a4f3b6f452cdbf6dd311f1362679eb4c31ced
git.commit.message.short=Update Spring
git.commit.user.name=Dave Syer
git.build.user.name=Dave Syer
git.build.user.email=dsyer@vmware.com
git.branch=develop
git.commit.time=2013-04-24T08\:42\:13+0100
git.build.time=2013-05-23T09\:26\:42+0100

View File

@ -1,13 +0,0 @@
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-5.0.xsd">
<instance-name>actuator-hazelcast</instance-name>
<map name="defaultCache" />
<network>
<join>
<auto-detection enabled="false"/>
<multicast enabled="false"/>
</join>
</network>
</hazelcast>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="test" packages="">
<Properties>
<Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
<Property name="LOG_LEVEL_PATTERN">%5p</Property>
</Properties>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT" follow="true">
<PatternLayout pattern="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{${LOG_LEVEL_PATTERN}} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>