From 67b0a264749e40c88cef380c0d78805324f2a386 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 6 Mar 2025 18:00:02 +0000 Subject: [PATCH] Improve structure of test resources in Actuator modules Closes gh-44632 --- ...FoundryActuatorAutoConfigurationTests.java | 16 ++++++++++++ ...dFoundryInfoEndpointWebExtensionTests.java | 18 +++++++++++++- ...slVerificationHttpRequestFactoryTests.java | 4 ++- .../FlywayEndpointDocumentationTests.java | 5 +++- .../LiquibaseEndpointDocumentationTests.java | 5 +++- .../SbomEndpointDocumentationTests.java | 6 +++-- ...utorAutoConfigurationIntegrationTests.java | 17 ++++++++++++- ...althContributorAutoConfigurationTests.java | 17 ++++++++++++- ...ibernateMetricsAutoConfigurationTests.java | 14 ++++++++++- .../JettyMetricsAutoConfigurationTests.java | 18 ++++++++------ ...mentWebSecurityAutoConfigurationTests.java | 6 +++-- .../test/resources/actuator-docs-index.html | 1 - .../src/test/resources/city-data.sql | 1 - .../src/test/resources/city-schema.sql | 7 ------ .../resources/db/create-custom-schema.sql | 1 - .../src/test/resources/git.properties | 13 ---------- .../src/test/resources/hazelcast.xml | 12 --------- .../cloudfoundry/servlet}/test.jks | Bin .../endpoint/web/documentation}/V1__init.sql | 0 .../web/documentation}/cyclonedx.json | 0 .../documentation}/db.changelog-master.yaml | 0 .../autoconfigure/metrics/web/jetty}/test.jks | Bin .../security/servlet/saml-certificate} | 0 .../actuate/flyway/FlywayEndpointTests.java | 6 ++++- .../HazelcastHealthIndicatorTests.java | 18 +++++++++++++- .../liquibase/LiquibaseEndpointTests.java | 16 +++++++++++- ...mEndpointCycloneDxWebIntegrationTests.java | 4 +-- .../SbomEndpointSpdxWebIntegrationTests.java | 4 +-- .../SbomEndpointSyftWebIntegrationTests.java | 4 +-- .../boot/actuate/sbom/SbomEndpointTests.java | 17 +++++++------ .../sbom/SbomEndpointWebExtensionTests.java | 23 ++++++++++-------- .../sbom/SbomEndpointWebIntegrationTests.java | 4 +-- .../test/resources/actuator-docs-index.html | 1 - .../changelog/db.changelog-master-backup.yaml | 20 --------------- .../db/changelog/db.changelog-master.yaml | 20 --------------- .../resources/db/create-custom-schema.sql | 1 - .../test/resources/db/migration/V1__init.sql | 1 - .../resources/db/migration/V2__update.sql | 1 - .../resources/db/migration/V3__update.sql | 1 - .../src/test/resources/git.properties | 13 ---------- .../src/test/resources/hazelcast.xml | 13 ---------- .../src/test/resources/log4j2-test.xml | 17 ------------- .../boot/actuate}/sbom/cyclonedx.json | 0 .../boot/actuate}/sbom/spdx.json | 0 .../boot/actuate}/sbom/syft.json | 0 45 files changed, 176 insertions(+), 169 deletions(-) delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/actuator-docs-index.html delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-data.sql delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-schema.sql delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/db/create-custom-schema.sql delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/git.properties delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/hazelcast.xml rename spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/{ => org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet}/test.jks (100%) rename spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/{db/migration => org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation}/V1__init.sql (100%) rename spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/{sbom => org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation}/cyclonedx.json (100%) rename spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/{db/changelog => org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation}/db.changelog-master.yaml (100%) rename spring-boot-project/{spring-boot-actuator/src/test/resources => spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/metrics/web/jetty}/test.jks (100%) rename spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/{saml/certificate-location => org/springframework/boot/actuate/autoconfigure/security/servlet/saml-certificate} (100%) delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/actuator-docs-index.html delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/db/changelog/db.changelog-master-backup.yaml delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/db/changelog/db.changelog-master.yaml delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/db/create-custom-schema.sql delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V1__init.sql delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V2__update.sql delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V3__update.sql delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/git.properties delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/hazelcast.xml delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/resources/log4j2-test.xml rename spring-boot-project/spring-boot-actuator/src/test/resources/{ => org/springframework/boot/actuate}/sbom/cyclonedx.json (100%) rename spring-boot-project/spring-boot-actuator/src/test/resources/{ => org/springframework/boot/actuate}/sbom/spdx.json (100%) rename spring-boot-project/spring-boot-actuator/src/test/resources/{ => org/springframework/boot/actuate}/sbom/syft.json (100%) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java index cddbd59bea..856bb2af97 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java @@ -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) -> { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryInfoEndpointWebExtensionTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryInfoEndpointWebExtensionTests.java index e8cebbf1dd..ab9b5800c2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryInfoEndpointWebExtensionTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryInfoEndpointWebExtensionTests.java @@ -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) -> { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/SkipSslVerificationHttpRequestFactoryTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/SkipSslVerificationHttpRequestFactoryTests.java index 6d7f0cf019..edaca1f623 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/SkipSslVerificationHttpRequestFactoryTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/SkipSslVerificationHttpRequestFactoryTests.java @@ -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(); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/FlywayEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/FlywayEndpointDocumentationTests.java index 591b40e723..a04987c274 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/FlywayEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/FlywayEndpointDocumentationTests.java @@ -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.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; @@ -45,6 +46,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * * @author Andy Wilkinson */ +@TestPropertySource( + properties = "spring.flyway.locations=classpath:org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation") class FlywayEndpointDocumentationTests extends MockMvcEndpointDocumentationTests { @Test diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LiquibaseEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LiquibaseEndpointDocumentationTests.java index cd12c81c2c..fe5cf55142 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LiquibaseEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LiquibaseEndpointDocumentationTests.java @@ -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.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; @@ -42,6 +43,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * * @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 diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SbomEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SbomEndpointDocumentationTests.java index f427e9f25e..1dbf29709f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SbomEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/SbomEndpointDocumentationTests.java @@ -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. @@ -61,7 +61,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; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfigurationIntegrationTests.java index 7101dd9522..2c0cad8eeb 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfigurationIntegrationTests.java @@ -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 = """ + + + + + + + + + + """) class HazelcastHealthContributorAutoConfigurationIntegrationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfigurationTests.java index 73ed857e17..02a8f55a46 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfigurationTests.java @@ -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 = """ + + + + + + + + + + """) class HazelcastHealthContributorAutoConfigurationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java index 21d94348e1..853717cae3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java @@ -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. @@ -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; @@ -136,6 +137,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", diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/jetty/JettyMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/jetty/JettyMetricsAutoConfigurationTests.java index 0e8437a192..23adfa9fa0 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/jetty/JettyMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/jetty/JettyMetricsAutoConfigurationTests.java @@ -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) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java index 869ee26aa4..a891deac7b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java @@ -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. @@ -36,6 +36,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.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; @@ -132,13 +133,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)); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/actuator-docs-index.html b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/actuator-docs-index.html deleted file mode 100644 index 8b13789179..0000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/actuator-docs-index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-data.sql b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-data.sql deleted file mode 100644 index eb08623b4c..0000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-data.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO CITY (ID, NAME, STATE, COUNTRY, MAP) values (2000, 'Washington', 'DC', 'US', 'Google'); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-schema.sql b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-schema.sql deleted file mode 100644 index b2a4112add..0000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-schema.sql +++ /dev/null @@ -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) -); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/db/create-custom-schema.sql b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/db/create-custom-schema.sql deleted file mode 100644 index 469b79ad89..0000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/db/create-custom-schema.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE SCHEMA CUSTOMSCHEMA; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/git.properties b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/git.properties deleted file mode 100644 index d88056068a..0000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/git.properties +++ /dev/null @@ -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 diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/hazelcast.xml b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/hazelcast.xml deleted file mode 100644 index 566f53e3a1..0000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/hazelcast.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/test.jks b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/test.jks similarity index 100% rename from spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/test.jks rename to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/test.jks diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/db/migration/V1__init.sql b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/V1__init.sql similarity index 100% rename from spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/db/migration/V1__init.sql rename to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/V1__init.sql diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/sbom/cyclonedx.json b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/cyclonedx.json similarity index 100% rename from spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/sbom/cyclonedx.json rename to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/cyclonedx.json diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/db/changelog/db.changelog-master.yaml b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/db.changelog-master.yaml similarity index 100% rename from spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/db/changelog/db.changelog-master.yaml rename to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/db.changelog-master.yaml diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/test.jks b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/metrics/web/jetty/test.jks similarity index 100% rename from spring-boot-project/spring-boot-actuator/src/test/resources/test.jks rename to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/metrics/web/jetty/test.jks diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/saml/certificate-location b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/security/servlet/saml-certificate similarity index 100% rename from spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/saml/certificate-location rename to spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/org/springframework/boot/actuate/autoconfigure/security/servlet/saml-certificate diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/flyway/FlywayEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/flyway/FlywayEndpointTests.java index 4a892135a6..191d83439b 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/flyway/FlywayEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/flyway/FlywayEndpointTests.java @@ -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() diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/HazelcastHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/HazelcastHealthIndicatorTests.java index d478843988..c2be016125 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/HazelcastHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/hazelcast/HazelcastHealthIndicatorTests.java @@ -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 = """ + + actuator-hazelcast + + + + + + + + + """) void hazelcastUp() { new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(HazelcastAutoConfiguration.class)) .withPropertyValues("spring.hazelcast.config=hazelcast.xml") diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpointTests.java index c0f6900f1a..02ebb20d37 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpointTests.java @@ -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) -> { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointCycloneDxWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointCycloneDxWebIntegrationTests.java index 85e5b12f19..371a9542a2 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointCycloneDxWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointCycloneDxWebIntegrationTests.java @@ -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; } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointSpdxWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointSpdxWebIntegrationTests.java index 264e8cd05d..4e8eba326f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointSpdxWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointSpdxWebIntegrationTests.java @@ -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; } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointSyftWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointSyftWebIntegrationTests.java index 0c6469322d..6ed52ec4fd 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointSyftWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointSyftWebIntegrationTests.java @@ -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; } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointTests.java index f4c724d690..63f3fd8598 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointTests.java @@ -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\""); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointWebExtensionTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointWebExtensionTests.java index 95831aacfd..03701f2f0e 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointWebExtensionTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointWebExtensionTests.java @@ -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 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 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 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 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 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 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 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"); }; } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointWebIntegrationTests.java index 77b4ecdfc6..b41e9e14bc 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/sbom/SbomEndpointWebIntegrationTests.java @@ -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; } diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/actuator-docs-index.html b/spring-boot-project/spring-boot-actuator/src/test/resources/actuator-docs-index.html deleted file mode 100644 index 8b13789179..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/actuator-docs-index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/db/changelog/db.changelog-master-backup.yaml b/spring-boot-project/spring-boot-actuator/src/test/resources/db/changelog/db.changelog-master-backup.yaml deleted file mode 100644 index a3a19b43af..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/db/changelog/db.changelog-master-backup.yaml +++ /dev/null @@ -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 diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/db/changelog/db.changelog-master.yaml b/spring-boot-project/spring-boot-actuator/src/test/resources/db/changelog/db.changelog-master.yaml deleted file mode 100644 index 134b17b543..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/db/changelog/db.changelog-master.yaml +++ /dev/null @@ -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 diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/db/create-custom-schema.sql b/spring-boot-project/spring-boot-actuator/src/test/resources/db/create-custom-schema.sql deleted file mode 100644 index 469b79ad89..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/db/create-custom-schema.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE SCHEMA CUSTOMSCHEMA; diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V1__init.sql b/spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V1__init.sql deleted file mode 100644 index 867c7c24f5..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V1__init.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS TEST; diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V2__update.sql b/spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V2__update.sql deleted file mode 100644 index 867c7c24f5..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V2__update.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS TEST; diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V3__update.sql b/spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V3__update.sql deleted file mode 100644 index 867c7c24f5..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/db/migration/V3__update.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS TEST; diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/git.properties b/spring-boot-project/spring-boot-actuator/src/test/resources/git.properties deleted file mode 100644 index d88056068a..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/git.properties +++ /dev/null @@ -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 diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/hazelcast.xml b/spring-boot-project/spring-boot-actuator/src/test/resources/hazelcast.xml deleted file mode 100644 index d01639965c..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/hazelcast.xml +++ /dev/null @@ -1,13 +0,0 @@ - - actuator-hazelcast - - - - - - - - diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/log4j2-test.xml b/spring-boot-project/spring-boot-actuator/src/test/resources/log4j2-test.xml deleted file mode 100644 index 8c0f7f4652..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - %xwEx - %5p - - - - - - - - - - - - diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/sbom/cyclonedx.json b/spring-boot-project/spring-boot-actuator/src/test/resources/org/springframework/boot/actuate/sbom/cyclonedx.json similarity index 100% rename from spring-boot-project/spring-boot-actuator/src/test/resources/sbom/cyclonedx.json rename to spring-boot-project/spring-boot-actuator/src/test/resources/org/springframework/boot/actuate/sbom/cyclonedx.json diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/sbom/spdx.json b/spring-boot-project/spring-boot-actuator/src/test/resources/org/springframework/boot/actuate/sbom/spdx.json similarity index 100% rename from spring-boot-project/spring-boot-actuator/src/test/resources/sbom/spdx.json rename to spring-boot-project/spring-boot-actuator/src/test/resources/org/springframework/boot/actuate/sbom/spdx.json diff --git a/spring-boot-project/spring-boot-actuator/src/test/resources/sbom/syft.json b/spring-boot-project/spring-boot-actuator/src/test/resources/org/springframework/boot/actuate/sbom/syft.json similarity index 100% rename from spring-boot-project/spring-boot-actuator/src/test/resources/sbom/syft.json rename to spring-boot-project/spring-boot-actuator/src/test/resources/org/springframework/boot/actuate/sbom/syft.json