diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java
index 95cdaad841..9da9edf4b9 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java
@@ -166,6 +166,8 @@ class AutoConfigurationImportSelectorTests {
}
@Test
+ @WithTestAutoConfigurationImportsResource
+ @WithTestAutoConfigurationReplacementsResource
void removedExclusionsAreApplied() {
TestAutoConfigurationImportSelector importSelector = new TestAutoConfigurationImportSelector(
TestAutoConfiguration.class);
@@ -234,7 +236,9 @@ class AutoConfigurationImportSelectorTests {
}
@Test
- void soringConsidersReplacements() {
+ @WithTestAutoConfigurationImportsResource
+ @WithTestAutoConfigurationReplacementsResource
+ void sortingConsidersReplacements() {
TestAutoConfigurationImportSelector importSelector = new TestAutoConfigurationImportSelector(
TestAutoConfiguration.class);
setupImportSelector(importSelector);
@@ -397,4 +401,28 @@ class AutoConfigurationImportSelectorTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(
+ name = "META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.imports",
+ content = """
+ org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$AfterDeprecatedAutoConfiguration
+ org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$ReplacementAutoConfiguration
+ """)
+ @interface WithTestAutoConfigurationImportsResource {
+
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(
+ name = "META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.replacements",
+ content = """
+ org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$DeprecatedAutoConfiguration=\
+ org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$ReplacementAutoConfiguration
+ """)
+ @interface WithTestAutoConfigurationReplacementsResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoaderTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoaderTests.java
index adb83a99bf..ab919d4ec9 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoaderTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoaderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2019 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.
@@ -20,6 +20,8 @@ import java.util.Collections;
import org.junit.jupiter.api.Test;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
+
import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -27,6 +29,12 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
+@WithResource(name = "metadata.properties", content = """
+ test=
+ test.string=abc
+ test.int=123
+ test.set=a,b,b,c
+ """)
class AutoConfigurationMetadataLoaderTests {
@Test
@@ -90,8 +98,8 @@ class AutoConfigurationMetadataLoaderTests {
}
private AutoConfigurationMetadata load() {
- return AutoConfigurationMetadataLoader.loadMetadata(null,
- "META-INF/AutoConfigurationMetadataLoaderTests.properties");
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ return AutoConfigurationMetadataLoader.loadMetadata(classLoader, "metadata.properties");
}
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationReplacementsTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationReplacementsTests.java
index 30ae61950a..5e1b5b4e59 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationReplacementsTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationReplacementsTests.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.
@@ -24,8 +24,11 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
+
import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -33,10 +36,21 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
+@WithResource(
+ name = "META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationReplacementsTests$TestAutoConfigurationReplacements.replacements",
+ content = """
+ com.example.A1=com.example.A2
+ com.example.B1=com.example.B2
+ """)
class AutoConfigurationReplacementsTests {
- private final AutoConfigurationReplacements replacements = AutoConfigurationReplacements
- .load(TestAutoConfigurationReplacements.class, null);
+ private AutoConfigurationReplacements replacements;
+
+ @BeforeEach
+ void loadReplacements() {
+ this.replacements = AutoConfigurationReplacements.load(TestAutoConfigurationReplacements.class,
+ Thread.currentThread().getContextClassLoader());
+ }
@Test
void replaceWhenMatchReplacesClassName() {
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelectorTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelectorTests.java
index f63d78964b..5e6a9feccc 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelectorTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelectorTests.java
@@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.core.annotation.AliasFor;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.type.AnnotationMetadata;
@@ -74,6 +75,12 @@ class ImportAutoConfigurationImportSelectorTests {
}
@Test
+ @WithResource(
+ name = "META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFile.imports",
+ content = """
+ org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$ImportedAutoConfiguration
+ org.springframework.boot.autoconfigure.missing.MissingAutoConfiguration
+ """)
void importsAreSelectedFromImportsFile() throws Exception {
AnnotationMetadata annotationMetadata = getAnnotationMetadata(FromImportsFile.class);
String[] imports = this.importSelector.selectImports(annotationMetadata);
@@ -83,9 +90,15 @@ class ImportAutoConfigurationImportSelectorTests {
}
@Test
+ @WithResource(
+ name = "META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFile.imports",
+ content = """
+ optional:org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$ImportedAutoConfiguration
+ optional:org.springframework.boot.autoconfigure.missing.MissingAutoConfiguration
+ org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$AnotherImportedAutoConfiguration
+ """)
void importsSelectedFromImportsFileIgnoreMissingOptionalClasses() throws Exception {
- AnnotationMetadata annotationMetadata = getAnnotationMetadata(
- FromImportsFileIgnoresMissingOptionalClasses.class);
+ AnnotationMetadata annotationMetadata = getAnnotationMetadata(FromImportsFile.class);
String[] imports = this.importSelector.selectImports(annotationMetadata);
assertThat(imports).containsExactly(
"org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$ImportedAutoConfiguration",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
index 1f3e84d18e..a6bdc9fdfc 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.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.
@@ -910,9 +910,8 @@ class RabbitAutoConfigurationTests {
void enableSslWithBundle() {
this.contextRunner.withUserConfiguration(TestConfiguration.class)
.withPropertyValues("spring.rabbitmq.ssl.bundle=test-bundle",
- "spring.ssl.bundle.jks.test-bundle.keystore.location=classpath:test.jks",
- "spring.ssl.bundle.jks.test-bundle.keystore.password=secret",
- "spring.ssl.bundle.jks.test-bundle.key.password=password")
+ "spring.ssl.bundle.jks.test-bundle.keystore.location=classpath:org/springframework/boot/autoconfigure/amqp/test.jks",
+ "spring.ssl.bundle.jks.test-bundle.keystore.password=secret")
.run((context) -> {
com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = getTargetConnectionFactory(context);
assertThat(rabbitConnectionFactory.isSSL()).isTrue();
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java
index 8f10bea4e0..5b6a4c3cce 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.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.
@@ -72,6 +72,8 @@ import org.springframework.boot.sql.init.DatabaseInitializationSettings;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.system.OutputCaptureExtension;
+import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
+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;
@@ -288,13 +290,13 @@ class BatchAutoConfigurationTests {
}
@Test
+ @WithPackageResources("custom-schema.sql")
void testRenamePrefix() {
this.contextRunner
.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class,
HibernateJpaAutoConfiguration.class)
.withPropertyValues("spring.datasource.generate-unique-name=true",
- "spring.batch.jdbc.schema:classpath:batch/custom-schema.sql",
- "spring.batch.jdbc.tablePrefix:PREFIX_")
+ "spring.batch.jdbc.schema:classpath:custom-schema.sql", "spring.batch.jdbc.tablePrefix:PREFIX_")
.run((context) -> {
assertThat(context).hasSingleBean(JobLauncher.class);
assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema())
@@ -412,6 +414,7 @@ class BatchAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/changelog/db.changelog-master.yaml", content = "databaseChangeLog:")
void jobRepositoryBeansDependOnLiquibase() {
this.contextRunner.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class)
.withUserConfiguration(LiquibaseAutoConfiguration.class)
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java
index a907a075b2..3377b5a449 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.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.boot.autoconfigure.transaction.TransactionAutoConfigu
import org.springframework.boot.sql.init.DatabaseInitializationMode;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Isolation;
@@ -70,11 +71,11 @@ class BatchAutoConfigurationWithoutJpaTests {
}
@Test
+ @WithPackageResources("custom-schema.sql")
void jdbcWithCustomPrefix() {
this.contextRunner.withUserConfiguration(DefaultConfiguration.class, EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.datasource.generate-unique-name=true",
- "spring.batch.jdbc.schema:classpath:batch/custom-schema.sql",
- "spring.batch.jdbc.tablePrefix:PREFIX_")
+ "spring.batch.jdbc.schema:classpath:custom-schema.sql", "spring.batch.jdbc.tablePrefix:PREFIX_")
.run((context) -> {
assertThat(new JdbcTemplate(context.getBean(DataSource.class))
.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java
index b29f64cce6..5b576c3974 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.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.
@@ -16,6 +16,10 @@
package org.springframework.boot.autoconfigure.cache;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -48,6 +52,7 @@ import org.springframework.boot.autoconfigure.cache.support.MockCachingProvider.
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
@@ -481,6 +486,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
}
@Test
+ @WithHazelcastXmlResource
void hazelcastCacheExplicit() {
this.contextRunner.withConfiguration(AutoConfigurations.of(HazelcastAutoConfiguration.class))
.withUserConfiguration(DefaultCacheConfiguration.class)
@@ -496,6 +502,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
}
@Test
+ @WithHazelcastXmlResource
void hazelcastCacheWithCustomizers() {
this.contextRunner.withUserConfiguration(HazelcastCacheAndCustomizersConfiguration.class)
.withPropertyValues("spring.cache.type=hazelcast")
@@ -548,10 +555,31 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
}
@Test
+ @WithResource(name = "hazelcast-specific.xml", content = """
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ """)
void hazelcastAsJCacheWithConfig() {
String cachingProviderFqn = HazelcastServerCachingProvider.class.getName();
try {
- String configLocation = "org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.xml";
+ String configLocation = "hazelcast-specific.xml";
this.contextRunner.withUserConfiguration(DefaultCacheConfiguration.class)
.withPropertyValues("spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn,
"spring.cache.jcache.config=" + configLocation)
@@ -568,6 +596,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
}
@Test
+ @WithHazelcastXmlResource
void hazelcastAsJCacheWithExistingHazelcastInstance() {
String cachingProviderFqn = HazelcastServerCachingProvider.class.getName();
this.contextRunner.withConfiguration(AutoConfigurations.of(HazelcastAutoConfiguration.class))
@@ -587,6 +616,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
}
@Test
+ @WithInfinispanXmlResource
void infinispanCacheWithConfig() {
this.contextRunner.withUserConfiguration(DefaultCacheConfiguration.class)
.withPropertyValues("spring.cache.type=infinispan", "spring.cache.infinispan.config=infinispan.xml")
@@ -635,6 +665,7 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
}
@Test
+ @WithInfinispanXmlResource
void infinispanAsJCacheWithConfig() {
String cachingProviderClassName = JCachingProvider.class.getName();
String configLocation = "infinispan.xml";
@@ -1078,4 +1109,45 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "infinispan.xml", content = """
+
+
+
+
+
+
+
+
+
+
+
+
+
+ """)
+ @interface WithInfinispanXmlResource {
+
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "hazelcast.xml", content = """
+
+ default-instance
+
+
+
+
+
+
+
+
+ """)
+ @interface WithHazelcastXmlResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/EhCache3CacheAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/EhCache3CacheAutoConfigurationTests.java
index 3ee060cffe..92f66b9ac9 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/EhCache3CacheAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/EhCache3CacheAutoConfigurationTests.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 org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.cache.CacheAutoConfigurationTests.DefaultCacheConfiguration;
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.cache.jcache.JCacheCacheManager;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
@@ -49,6 +50,34 @@ class EhCache3CacheAutoConfigurationTests extends AbstractCacheAutoConfiguration
}
@Test
+ @WithResource(name = "ehcache3.xml", content = """
+
+
+
+ 200
+
+
+
+
+ 600
+
+
+
+
+
+
+ 400
+
+
+
+
+ """)
void ehcache3AsJCacheWithConfig() {
String cachingProviderFqn = EhcacheCachingProvider.class.getName();
String configLocation = "ehcache3.xml";
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java
index 4a276d96bd..d7ef91cbe3 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.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.
@@ -38,6 +38,7 @@ import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfigurati
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.ssl.NoSuchSslBundleException;
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;
@@ -89,6 +90,7 @@ class CassandraAutoConfigurationTests {
}
@Test
+ @WithPackageResources("test.jks")
void cqlSessionBuilderWithSslBundle() {
this.contextRunner
.withPropertyValues("spring.cassandra.ssl.bundle=test-bundle",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnResourceTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnResourceTests.java
index e01c32696d..177603123f 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnResourceTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnResourceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2019 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.
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.condition;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -35,6 +36,7 @@ class ConditionalOnResourceTests {
private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test
+ @WithResource(name = "schema.sql")
void testResourceExists() {
this.context.register(BasicConfiguration.class);
this.context.refresh();
@@ -43,6 +45,7 @@ class ConditionalOnResourceTests {
}
@Test
+ @WithResource(name = "schema.sql")
void testResourceExistsWithPlaceholder() {
TestPropertyValues.of("schema=schema.sql").applyTo(this.context);
this.context.register(PlaceholderConfiguration.class);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ResourceConditionTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ResourceConditionTests.java
index dfc936fdd8..f1daa8d5c9 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ResourceConditionTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ResourceConditionTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2019 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.
@@ -20,6 +20,7 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -45,6 +46,7 @@ class ResourceConditionTests {
}
@Test
+ @WithResource(name = "logging.properties")
void defaultResourceAndNoExplicitKey() {
load(DefaultLocationConfiguration.class);
assertThat(this.context.containsBean("foo")).isTrue();
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.java
index fbe9204e4f..2a239fd917 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.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.
@@ -16,6 +16,10 @@
package org.springframework.boot.autoconfigure.context;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.util.Locale;
import org.junit.jupiter.api.Disabled;
@@ -28,6 +32,7 @@ import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfigura
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.annotation.Bean;
@@ -59,6 +64,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void propertiesBundleWithSlashIsDetected() {
this.contextRunner.withPropertyValues("spring.messages.basename=test/messages").run((context) -> {
assertThat(context).hasSingleBean(MessageSource.class);
@@ -67,6 +73,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void propertiesBundleWithDotIsDetected() {
this.contextRunner.withPropertyValues("spring.messages.basename=test.messages").run((context) -> {
assertThat(context).hasSingleBean(MessageSource.class);
@@ -75,6 +82,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestSwedishPropertiesResource
void testEncodingWorks() {
this.contextRunner.withPropertyValues("spring.messages.basename=test/swedish")
.run((context) -> assertThat(context.getMessage("foo", null, "Foo message", Locale.UK))
@@ -82,6 +90,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void testCacheDurationNoUnit() {
this.contextRunner
.withPropertyValues("spring.messages.basename=test/messages", "spring.messages.cache-duration=10")
@@ -89,6 +98,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void testCacheDurationWithUnit() {
this.contextRunner
.withPropertyValues("spring.messages.basename=test/messages", "spring.messages.cache-duration=1m")
@@ -103,6 +113,8 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
+ @WithTestMessages2PropertiesResource
void testMultipleMessageSourceCreated() {
this.contextRunner.withPropertyValues("spring.messages.basename=test/messages,test/messages2")
.run((context) -> {
@@ -112,13 +124,17 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
@Disabled("Expected to fail per gh-1075")
+ @WithResource(name = "application-switch-messages.properties", content = "spring.messages.basename:test/messages")
void testMessageSourceFromPropertySourceAnnotation() {
this.contextRunner.withUserConfiguration(Config.class)
.run((context) -> assertThat(context.getMessage("foo", null, "Foo message", Locale.UK)).isEqualTo("bar"));
}
@Test
+ @WithTestMessagesPropertiesResource
+ @WithResource(name = "test/common-messages.properties", content = "hello=world")
void testCommonMessages() {
this.contextRunner
.withPropertyValues("spring.messages.basename=test/messages",
@@ -127,16 +143,18 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void testCommonMessagesWhenNotFound() {
this.contextRunner
.withPropertyValues("spring.messages.basename=test/messages",
- "spring.messages.common-messages=classpath:test/common-messages-missing.properties")
+ "spring.messages.common-messages=classpath:test/common-messages.properties")
.run((context) -> assertThat(context).getFailure()
.hasMessageContaining(
- "Failed to load common messages from 'class path resource [test/common-messages-missing.properties]'"));
+ "Failed to load common messages from 'class path resource [test/common-messages.properties]'"));
}
@Test
+ @WithTestMessagesPropertiesResource
void testFallbackDefault() {
this.contextRunner.withPropertyValues("spring.messages.basename=test/messages")
.run((context) -> assertThat(context.getBean(MessageSource.class))
@@ -144,6 +162,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void testFallbackTurnOff() {
this.contextRunner
.withPropertyValues("spring.messages.basename=test/messages",
@@ -153,6 +172,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void testFormatMessageDefault() {
this.contextRunner.withPropertyValues("spring.messages.basename=test/messages")
.run((context) -> assertThat(context.getBean(MessageSource.class))
@@ -160,6 +180,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void testFormatMessageOn() {
this.contextRunner
.withPropertyValues("spring.messages.basename=test/messages",
@@ -169,6 +190,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void testUseCodeAsDefaultMessageDefault() {
this.contextRunner.withPropertyValues("spring.messages.basename=test/messages")
.run((context) -> assertThat(context.getBean(MessageSource.class))
@@ -176,6 +198,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void testUseCodeAsDefaultMessageOn() {
this.contextRunner
.withPropertyValues("spring.messages.basename=test/messages",
@@ -191,6 +214,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void existingMessageSourceInParentIsIgnored() {
this.contextRunner.run((parent) -> this.contextRunner.withParent(parent)
.withPropertyValues("spring.messages.basename=test/messages")
@@ -198,6 +222,7 @@ class MessageSourceAutoConfigurationTests {
}
@Test
+ @WithTestMessagesPropertiesResource
void messageSourceWithNonStandardBeanNameIsIgnored() {
this.contextRunner.withPropertyValues("spring.messages.basename=test/messages")
.withUserConfiguration(CustomBeanNameMessageSourceConfiguration.class)
@@ -258,4 +283,25 @@ class MessageSourceAutoConfigurationTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "test/messages.properties", content = "foo=bar")
+ @interface WithTestMessagesPropertiesResource {
+
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "test/messages2.properties", content = "foo-foo=bar-bar")
+ @interface WithTestMessages2PropertiesResource {
+
+ }
+
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "test/swedish.properties", content = "foo=Some text with some swedish öäå!")
+ @interface WithTestSwedishPropertiesResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java
index 73b5f3ded9..99b402bf61 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.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.
@@ -42,6 +42,7 @@ import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.ssl.NoSuchSslBundleException;
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;
@@ -201,13 +202,14 @@ class CouchbaseAutoConfigurationTests {
}
@Test
+ @WithPackageResources("test.jks")
void enableSslWithBundle() {
testClusterEnvironment((env) -> {
SecurityConfig securityConfig = env.securityConfig();
assertThat(securityConfig.tlsEnabled()).isTrue();
assertThat(securityConfig.trustManagerFactory()).isNotNull();
- }, "spring.ssl.bundle.jks.test-bundle.keystore.location=classpath:test.jks",
- "spring.ssl.bundle.jks.test-bundle.keystore.password=secret",
+ }, "spring.ssl.bundle.jks.test-bundle.truststore.location=classpath:test.jks",
+ "spring.ssl.bundle.jks.test-bundle.truststore.password=secret",
"spring.couchbase.env.ssl.bundle=test-bundle");
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfigurationTests.java
index 1b481cb506..0c251b578f 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfigurationTests.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.
@@ -33,6 +33,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration;
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.data.domain.ManagedTypes;
@@ -61,6 +62,17 @@ import static org.mockito.Mockito.mock;
* @author Mark Paluch
* @author Jens Schauder
*/
+@WithResource(name = "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 = "data.sql",
+ content = "INSERT INTO CITY (ID, NAME, STATE, COUNTRY, MAP) values (2000, 'Washington', 'DC', 'US', 'Google');")
class JdbcRepositoriesAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
@@ -208,8 +220,8 @@ class JdbcRepositoriesAutoConfigurationTests {
return (runner) -> runner
.withConfiguration(
AutoConfigurations.of(DataSourceAutoConfiguration.class, SqlInitializationAutoConfiguration.class))
- .withPropertyValues("spring.sql.init.schema-locations=classpath:data-city-schema.sql",
- "spring.sql.init.data-locations=classpath:city.sql", "spring.datasource.generate-unique-name:true");
+ .withPropertyValues("spring.sql.init.schema-locations=classpath:schema.sql",
+ "spring.sql.init.data-locations=classpath:data.sql", "spring.datasource.generate-unique-name:true");
}
@TestAutoConfigurationPackage(City.class)
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/r2dbc/R2dbcRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/r2dbc/R2dbcRepositoriesAutoConfigurationTests.java
index b9bea3baf0..e9c9dd9bf6 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/r2dbc/R2dbcRepositoriesAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/r2dbc/R2dbcRepositoriesAutoConfigurationTests.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.data.r2dbc.city.CityRepository;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration;
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.Configuration;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
@@ -48,6 +49,17 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Mark Paluch
*/
+@WithResource(name = "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 = "data.sql",
+ content = "INSERT INTO CITY (ID, NAME, STATE, COUNTRY, MAP) values (2000, 'Washington', 'DC', 'US', 'Google');")
class R2dbcRepositoriesAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
@@ -117,8 +129,8 @@ class R2dbcRepositoriesAutoConfigurationTests {
@Autowired
void initializeDatabase(ConnectionFactory connectionFactory) {
ResourceLoader resourceLoader = new DefaultResourceLoader();
- Resource[] scripts = new Resource[] { resourceLoader.getResource("classpath:data-city-schema.sql"),
- resourceLoader.getResource("classpath:city.sql") };
+ Resource[] scripts = new Resource[] { resourceLoader.getResource("classpath:schema.sql"),
+ resourceLoader.getResource("classpath:data.sql") };
new ResourceDatabasePopulator(scripts).populate(connectionFactory).block();
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java
index f66f5fe5af..bee589fa0c 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java
@@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.assertj.SimpleAsyncTaskExecutorAssert;
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
@@ -255,6 +256,7 @@ class RedisAutoConfigurationJedisTests {
}
@Test
+ @WithPackageResources("test.jks")
void testRedisConfigurationWithSslBundle() {
this.contextRunner
.withPropertyValues("spring.data.redis.ssl.bundle:test-bundle",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java
index 4e0802ff58..2cc868b868 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.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.
@@ -41,6 +41,7 @@ import org.springframework.boot.test.context.assertj.AssertableApplicationContex
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.testsupport.assertj.SimpleAsyncTaskExecutorAssert;
+import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
@@ -571,6 +572,7 @@ class RedisAutoConfigurationTests {
}
@Test
+ @WithPackageResources("test.jks")
void testRedisConfigurationWithSslBundle() {
this.contextRunner
.withPropertyValues("spring.data.redis.ssl.bundle:test-bundle",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java
index 25b0da05ae..ffd4acd6cb 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfigurationTests.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.elasticsearch.ElasticsearchRestCli
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
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;
import org.springframework.test.util.ReflectionTestUtils;
@@ -288,6 +289,7 @@ class ElasticsearchRestClientAutoConfigurationTests {
}
@Test
+ @WithPackageResources("test.jks")
@SuppressWarnings("unchecked")
void configureWithSslBundle() {
List properties = new ArrayList<>();
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
index 3a55e89395..f9e049d8df 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.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.
@@ -16,6 +16,11 @@
package org.springframework.boot.autoconfigure.flyway;
+import java.io.Serializable;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
@@ -25,6 +30,10 @@ import java.util.UUID;
import javax.sql.DataSource;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.Location;
import org.flywaydb.core.api.MigrationVersion;
@@ -68,6 +77,8 @@ import org.springframework.boot.test.context.assertj.AssertableApplicationContex
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.system.OutputCaptureExtension;
+import org.springframework.boot.testsupport.classpath.resources.ResourcePath;
+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;
@@ -411,7 +422,9 @@ class FlywayAutoConfigurationTests {
}
@Test
- void failOnMissingLocationsAllExist() {
+ @WithResource(name = "db/changelog/V1.1__refine.sql")
+ @WithResource(name = "db/migration/V1__init.sql", content = "DROP TABLE IF EXISTS TEST")
+ void failOnMissingLocationsDoesNotFailWhenAllExist() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.fail-on-missing-locations=true")
.withPropertyValues("spring.flyway.locations:classpath:db/changelog,classpath:db/migration")
@@ -419,6 +432,8 @@ class FlywayAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/changelog/V1.1__refine.sql")
+ @WithResource(name = "db/migration/V1__init.sql", content = "DROP TABLE IF EXISTS TEST")
void failOnMissingLocationsAllExistWithImplicitClasspathPrefix() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.fail-on-missing-locations=true")
@@ -427,10 +442,11 @@ class FlywayAutoConfigurationTests {
}
@Test
- void failOnMissingLocationsAllExistWithFilesystemPrefix() {
+ @WithResource(name = "db/migration/V1__init.sql", content = "DROP TABLE IF EXISTS TEST")
+ void failOnMissingLocationsFilesystemPrefixDoesNotFailWhenAllExist(@ResourcePath("db/migration") String migration) {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.fail-on-missing-locations=true")
- .withPropertyValues("spring.flyway.locations:filesystem:src/test/resources/db/migration")
+ .withPropertyValues("spring.flyway.locations:filesystem:" + migration)
.run((context) -> assertThat(context).hasNotFailed());
}
@@ -466,6 +482,7 @@ class FlywayAutoConfigurationTests {
}
@Test
+ @WithMetaInfPersistenceXmlResource
void customFlywayWithJpa() {
this.contextRunner
.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CustomFlywayWithJpaConfiguration.class)
@@ -480,6 +497,7 @@ class FlywayAutoConfigurationTests {
}
@Test
+ @WithMetaInfPersistenceXmlResource
void customFlywayMigrationInitializerWithJpa() {
this.contextRunner
.withUserConfiguration(EmbeddedDataSourceConfiguration.class,
@@ -518,6 +536,7 @@ class FlywayAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/vendors/h2/V1__init.sql", content = "DROP TABLE IF EXISTS TEST;")
void useVendorDirectory() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.locations=classpath:db/vendors/{vendor},classpath:db/changelog")
@@ -530,6 +549,7 @@ class FlywayAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/vendors/h2/V1__init.sql", content = "DROP TABLE IF EXISTS TEST;")
void useOneLocationWithVendorDirectory() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.locations=classpath:db/vendors/{vendor}")
@@ -1336,4 +1356,74 @@ class FlywayAutoConfigurationTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "META-INF/persistence.xml",
+ content = """
+
+
+
+ org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests$City
+ true
+
+
+ """)
+ @interface WithMetaInfPersistenceXmlResource {
+
+ }
+
+ @Entity
+ public static class City implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Column(nullable = false)
+ private String name;
+
+ @Column(nullable = false)
+ private String state;
+
+ @Column(nullable = false)
+ private String country;
+
+ @Column(nullable = false)
+ private String map;
+
+ protected City() {
+ }
+
+ City(String name, String state, String country, String map) {
+ this.name = name;
+ this.state = state;
+ this.country = country;
+ this.map = map;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getState() {
+ return this.state;
+ }
+
+ public String getCountry() {
+ return this.country;
+ }
+
+ public String getMap() {
+ return this.map;
+ }
+
+ @Override
+ public String toString() {
+ return getName() + "," + getState() + "," + getCountry();
+ }
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/NativeImageResourceProviderCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/NativeImageResourceProviderCustomizerTests.java
index 6928a3f894..33b474d841 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/NativeImageResourceProviderCustomizerTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/NativeImageResourceProviderCustomizerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2022 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.
@@ -24,6 +24,8 @@ import org.flywaydb.core.api.resource.LoadableResource;
import org.flywaydb.core.internal.resource.NoopResourceProvider;
import org.junit.jupiter.api.Test;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
+
import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -44,6 +46,7 @@ class NativeImageResourceProviderCustomizerTests {
}
@Test
+ @WithResource(name = "db/migration/V1__init.sql")
void nativeImageResourceProviderShouldFindMigrations() {
FluentConfiguration configuration = new FluentConfiguration();
this.customizer.customize(configuration);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java
index 3a47775541..14644c63c8 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.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.
@@ -20,11 +20,15 @@ import java.io.StringWriter;
import java.time.Duration;
import java.util.Locale;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.ApplicationContext;
import org.springframework.http.MediaType;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
@@ -46,6 +50,12 @@ class FreeMarkerAutoConfigurationReactiveIntegrationTests {
private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(FreeMarkerAutoConfiguration.class));
+ @BeforeEach
+ @AfterEach
+ void clearReactorSchedulers() {
+ Schedulers.shutdownNow();
+ }
+
@Test
void defaultConfiguration() {
this.contextRunner.run((context) -> {
@@ -57,6 +67,7 @@ class FreeMarkerAutoConfigurationReactiveIntegrationTests {
}
@Test
+ @WithResource(name = "templates/home.ftlh", content = "home")
void defaultViewResolution() {
this.contextRunner.run((context) -> {
MockServerWebExchange exchange = render(context, "home");
@@ -67,6 +78,7 @@ class FreeMarkerAutoConfigurationReactiveIntegrationTests {
}
@Test
+ @WithResource(name = "templates/prefix/prefixed.ftlh", content = "prefixed")
void customPrefix() {
this.contextRunner.withPropertyValues("spring.freemarker.prefix:prefix/").run((context) -> {
MockServerWebExchange exchange = render(context, "prefixed");
@@ -76,6 +88,7 @@ class FreeMarkerAutoConfigurationReactiveIntegrationTests {
}
@Test
+ @WithResource(name = "templates/suffixed.freemarker", content = "suffixed")
void customSuffix() {
this.contextRunner.withPropertyValues("spring.freemarker.suffix:.freemarker").run((context) -> {
MockServerWebExchange exchange = render(context, "suffixed");
@@ -85,6 +98,7 @@ class FreeMarkerAutoConfigurationReactiveIntegrationTests {
}
@Test
+ @WithResource(name = "custom-templates/custom.ftlh", content = "custom")
void customTemplateLoaderPath() {
this.contextRunner.withPropertyValues("spring.freemarker.templateLoaderPath:classpath:/custom-templates/")
.run((context) -> {
@@ -104,6 +118,7 @@ class FreeMarkerAutoConfigurationReactiveIntegrationTests {
}
@Test
+ @WithResource(name = "templates/message.ftlh", content = "Message: ${greeting}")
void renderTemplate() {
this.contextRunner.withPropertyValues().run((context) -> {
FreeMarkerConfigurer freemarker = context.getBean(FreeMarkerConfigurer.class);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java
index 975478d8ae..0806826649 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.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.
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;
@@ -75,6 +76,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
}
@Test
+ @WithResource(name = "templates/home.ftlh", content = "home")
void defaultViewResolution() throws Exception {
load();
MockHttpServletResponse response = render("home");
@@ -84,6 +86,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
}
@Test
+ @WithResource(name = "templates/home.ftlh", content = "home")
void customContentType() throws Exception {
load("spring.freemarker.contentType:application/json");
MockHttpServletResponse response = render("home");
@@ -93,6 +96,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
}
@Test
+ @WithResource(name = "templates/prefix/prefixed.ftlh", content = "prefixed")
void customPrefix() throws Exception {
load("spring.freemarker.prefix:prefix/");
MockHttpServletResponse response = render("prefixed");
@@ -101,6 +105,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
}
@Test
+ @WithResource(name = "templates/suffixed.freemarker", content = "suffixed")
void customSuffix() throws Exception {
load("spring.freemarker.suffix:.freemarker");
MockHttpServletResponse response = render("suffixed");
@@ -109,6 +114,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
}
@Test
+ @WithResource(name = "custom-templates/custom.ftlh", content = "custom")
void customTemplateLoaderPath() throws Exception {
load("spring.freemarker.templateLoaderPath:classpath:/custom-templates/");
MockHttpServletResponse response = render("custom");
@@ -138,6 +144,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests {
}
@Test
+ @WithResource(name = "templates/message.ftlh", content = "Message: ${greeting}")
void renderTemplate() throws Exception {
load();
FreeMarkerConfigurer freemarker = this.context.getBean(FreeMarkerConfigurer.class);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java
index 156abc5186..c80bfc3fcb 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.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.
@@ -27,6 +27,7 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.boot.testsupport.BuildOutput;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
@@ -51,6 +52,7 @@ class FreeMarkerAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(FreeMarkerAutoConfiguration.class));
@Test
+ @WithResource(name = "templates/message.ftlh", content = "Message: ${greeting}")
void renderNonWebAppTemplate() {
this.contextRunner.run((context) -> {
freemarker.template.Configuration freemarker = context.getBean(freemarker.template.Configuration.class);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProviderTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProviderTests.java
index d39f11fb8b..1c510f5c5b 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProviderTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProviderTests.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.beans.factory.aot.AotServices;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider.FreeMarkerTemplateAvailabilityProperties;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider.FreeMarkerTemplateAvailabilityRuntimeHints;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.mock.env.MockEnvironment;
@@ -45,6 +46,7 @@ class FreeMarkerTemplateAvailabilityProviderTests {
private final MockEnvironment environment = new MockEnvironment();
@Test
+ @WithResource(name = "templates/home.ftlh")
void availabilityOfTemplateInDefaultLocation() {
assertThat(this.provider.isTemplateAvailable("home", this.environment, getClass().getClassLoader(),
this.resourceLoader))
@@ -59,6 +61,7 @@ class FreeMarkerTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "custom-templates/custom.ftlh")
void availabilityOfTemplateWithCustomLoaderPath() {
this.environment.setProperty("spring.freemarker.template-loader-path", "classpath:/custom-templates/");
assertThat(this.provider.isTemplateAvailable("custom", this.environment, getClass().getClassLoader(),
@@ -67,6 +70,7 @@ class FreeMarkerTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "custom-templates/custom.ftlh")
void availabilityOfTemplateWithCustomLoaderPathConfiguredAsAList() {
this.environment.setProperty("spring.freemarker.template-loader-path[0]", "classpath:/custom-templates/");
assertThat(this.provider.isTemplateAvailable("custom", this.environment, getClass().getClassLoader(),
@@ -75,6 +79,7 @@ class FreeMarkerTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "templates/prefix/prefixed.ftlh")
void availabilityOfTemplateWithCustomPrefix() {
this.environment.setProperty("spring.freemarker.prefix", "prefix/");
assertThat(this.provider.isTemplateAvailable("prefixed", this.environment, getClass().getClassLoader(),
@@ -83,6 +88,7 @@ class FreeMarkerTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "templates/suffixed.freemarker")
void availabilityOfTemplateWithCustomSuffix() {
this.environment.setProperty("spring.freemarker.suffix", ".freemarker");
assertThat(this.provider.isTemplateAvailable("suffixed", this.environment, getClass().getClassLoader(),
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/DefaultGraphQlSchemaConditionTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/DefaultGraphQlSchemaConditionTests.java
index 197eaab69e..c486ac898a 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/DefaultGraphQlSchemaConditionTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/DefaultGraphQlSchemaConditionTests.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.
@@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
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;
@@ -38,6 +39,8 @@ class DefaultGraphQlSchemaConditionTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
@Test
+ @WithResource(name = "graphql/one.graphqls")
+ @WithResource(name = "graphql/two.graphqls")
void matchesWhenSchemaFilesAreDetected() {
this.contextRunner.withUserConfiguration(TestingConfiguration.class).run((context) -> {
didMatch(context);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java
index f7e7543ede..be1efca974 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.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.
@@ -35,10 +35,13 @@ import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration.GraphQlResourcesRuntimeHints;
+import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener;
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
+import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ByteArrayResource;
@@ -59,6 +62,25 @@ import static org.mockito.Mockito.mock;
/**
* Tests for {@link GraphQlAutoConfiguration}.
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
@ExtendWith(OutputCaptureExtension.class)
class GraphQlAutoConfigurationTests {
@@ -67,11 +89,12 @@ class GraphQlAutoConfigurationTests {
@Test
void shouldContributeDefaultBeans() {
- this.contextRunner.run((context) -> assertThat(context).hasSingleBean(GraphQlSource.class)
- .hasSingleBean(BatchLoaderRegistry.class)
- .hasSingleBean(ExecutionGraphQlService.class)
- .hasSingleBean(AnnotatedControllerConfigurer.class)
- .hasSingleBean(EncodingCursorStrategy.class));
+ this.contextRunner.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO))
+ .run((context) -> assertThat(context).hasSingleBean(GraphQlSource.class)
+ .hasSingleBean(BatchLoaderRegistry.class)
+ .hasSingleBean(ExecutionGraphQlService.class)
+ .hasSingleBean(AnnotatedControllerConfigurer.class)
+ .hasSingleBean(EncodingCursorStrategy.class));
}
@Test
@@ -99,6 +122,12 @@ class GraphQlAutoConfigurationTests {
}
@Test
+ @WithResource(name = "graphql/types/person.custom", content = """
+ type Person {
+ id: ID
+ name: String
+ }
+ """)
void shouldScanLocationsWithCustomExtension() {
this.contextRunner.withPropertyValues("spring.graphql.schema.file-extensions:.graphqls,.custom")
.run((context) -> {
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQueryByExampleAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQueryByExampleAutoConfigurationTests.java
index 964bf0ebaf..531c66fbac 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQueryByExampleAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQueryByExampleAutoConfigurationTests.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.
@@ -18,12 +18,11 @@ package org.springframework.boot.autoconfigure.graphql.data;
import java.util.Optional;
-import org.junit.jupiter.api.Test;
-
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.graphql.Book;
import org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.repository.CrudRepository;
@@ -41,6 +40,25 @@ import static org.mockito.Mockito.mock;
*
* @author Brian Clozel
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
class GraphQlQueryByExampleAutoConfigurationTests {
private static final Book book = new Book("42", "Test title", 42, "Test Author");
@@ -51,7 +69,6 @@ class GraphQlQueryByExampleAutoConfigurationTests {
.withUserConfiguration(MockRepositoryConfig.class)
.withPropertyValues("spring.main.web-application-type=servlet");
- @Test
void shouldRegisterDataFetcherForQueryByExampleRepositories() {
this.contextRunner.run((context) -> {
ExecutionGraphQlService graphQlService = context.getBean(ExecutionGraphQlService.class);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslAutoConfigurationTests.java
index ff2624099b..4b0c324847 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlQuerydslAutoConfigurationTests.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.autoconfigure.graphql.Book;
import org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
@@ -44,6 +45,25 @@ import static org.mockito.Mockito.mock;
*
* @author Brian Clozel
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
class GraphQlQuerydslAutoConfigurationTests {
private static final Book book = new Book("42", "Test title", 42, "Test Author");
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQueryByExampleAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQueryByExampleAutoConfigurationTests.java
index 8f4a94a410..834c630f90 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQueryByExampleAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQueryByExampleAutoConfigurationTests.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.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.graphql.Book;
import org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor;
@@ -41,6 +42,25 @@ import static org.mockito.Mockito.mock;
*
* @author Brian Clozel
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
class GraphQlReactiveQueryByExampleAutoConfigurationTests {
private static final Mono bookPublisher = Mono.just(new Book("42", "Test title", 42, "Test Author"));
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQuerydslAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQuerydslAutoConfigurationTests.java
index 8c807fe989..9401bed26e 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQuerydslAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/data/GraphQlReactiveQuerydslAutoConfigurationTests.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.
@@ -24,6 +24,7 @@ import org.springframework.boot.autoconfigure.graphql.Book;
import org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor;
@@ -43,6 +44,25 @@ import static org.mockito.Mockito.mock;
*
* @author Brian Clozel
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
class GraphQlReactiveQuerydslAutoConfigurationTests {
private static final Mono bookPublisher = Mono.just(new Book("42", "Test title", 42, "Test Author"));
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java
index 51978cc79f..2c15f2b124 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/reactive/GraphQlWebFluxAutoConfigurationTests.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.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.HttpHandlerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
@@ -57,6 +58,25 @@ import static org.hamcrest.Matchers.containsString;
*
* @author Brian Clozel
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
class GraphQlWebFluxAutoConfigurationTests {
private static final String BASE_URL = "https://spring.example.org/";
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/rsocket/GraphQlRSocketAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/rsocket/GraphQlRSocketAutoConfigurationTests.java
index 69f664ef0e..bdf39ff98b 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/rsocket/GraphQlRSocketAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/rsocket/GraphQlRSocketAutoConfigurationTests.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.reactive.WebFluxAutoConfigurat
import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration;
import org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
import org.springframework.boot.web.embedded.netty.NettyRouteProvider;
@@ -53,6 +54,25 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Brian Clozel
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
class GraphQlRSocketAutoConfigurationTests {
private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner()
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebFluxSecurityAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebFluxSecurityAutoConfigurationTests.java
index 3d8fcc9fa6..fc4e623cf7 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebFluxSecurityAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebFluxSecurityAutoConfigurationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2024 the original author or authors.
+ * Copyright 2020-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.boot.autoconfigure.security.reactive.ReactiveSecurity
import org.springframework.boot.autoconfigure.web.reactive.HttpHandlerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.graphql.execution.ErrorType;
@@ -60,6 +61,25 @@ import static org.springframework.security.config.Customizer.withDefaults;
*
* @author Brian Clozel
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
class GraphQlWebFluxSecurityAutoConfigurationTests {
private static final String BASE_URL = "https://spring.example.org/graphql";
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebMvcSecurityAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebMvcSecurityAutoConfigurationTests.java
index 809668c190..b4deaa3cb8 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebMvcSecurityAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/security/GraphQlWebMvcSecurityAutoConfigurationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2024 the original author or authors.
+ * Copyright 2020-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.security.servlet.SecurityAutoConfi
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 org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.graphql.execution.ErrorType;
@@ -60,6 +61,25 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
*
* @author Brian Clozel
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
class GraphQlWebMvcSecurityAutoConfigurationTests {
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java
index 9bd6618804..67de434594 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfigurationTests.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.boot.autoconfigure.jackson.JacksonAutoConfiguration;
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 org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
@@ -61,6 +62,25 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
*
* @author Brian Clozel
*/
+@WithResource(name = "graphql/types/book.graphqls", content = """
+ type Book {
+ id: ID
+ name: String
+ pageCount: Int
+ author: String
+ }
+ """)
+@WithResource(name = "graphql/schema.graphqls", content = """
+ type Query {
+ greeting(name: String! = "Spring"): String!
+ bookById(id: ID): Book
+ books: BookConnection
+ }
+
+ type Subscription {
+ booksOnSale(minPages: Int) : Book!
+ }
+ """)
class GraphQlWebMvcAutoConfigurationTests {
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfigurationTests.java
index 03a0d82118..d2eba9d5fb 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfigurationTests.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.junit.jupiter.api.Test;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testsupport.BuildOutput;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.io.ClassPathResource;
@@ -83,6 +84,7 @@ class GroovyTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/home.tpl", content = "yield 'home'")
void defaultViewResolution() throws Exception {
registerAndRefreshContext();
MockHttpServletResponse response = render("home");
@@ -92,6 +94,11 @@ class GroovyTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/includes.tpl", content = """
+ yield 'include'
+ include template: 'included.tpl'
+ """)
+ @WithResource(name = "templates/included.tpl", content = "yield 'here'")
void includesViewResolution() throws Exception {
registerAndRefreshContext();
MockHttpServletResponse response = render("includes");
@@ -108,6 +115,11 @@ class GroovyTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/includes.tpl", content = """
+ yield 'include'
+ include template: 'included.tpl'
+ """)
+ @WithResource(name = "templates/included_fr.tpl", content = "yield 'voila'")
void localeViewResolution() throws Exception {
registerAndRefreshContext();
MockHttpServletResponse response = render("includes", Locale.FRENCH);
@@ -117,6 +129,7 @@ class GroovyTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/home.tpl", content = "yield 'home'")
void customContentType() throws Exception {
registerAndRefreshContext("spring.groovy.template.contentType:application/json");
MockHttpServletResponse response = render("home");
@@ -126,6 +139,7 @@ class GroovyTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/prefix/prefixed.tpl", content = "yield \"prefixed\"")
void customPrefix() throws Exception {
registerAndRefreshContext("spring.groovy.template.prefix:prefix/");
MockHttpServletResponse response = render("prefixed");
@@ -134,6 +148,7 @@ class GroovyTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/suffixed.groovytemplate", content = "yield \"suffixed\"")
void customSuffix() throws Exception {
registerAndRefreshContext("spring.groovy.template.suffix:.groovytemplate");
MockHttpServletResponse response = render("suffixed");
@@ -142,6 +157,7 @@ class GroovyTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "custom-templates/custom.tpl", content = "yield \"custom\"")
void customTemplateLoaderPath() throws Exception {
registerAndRefreshContext("spring.groovy.template.resource-loader-path:classpath:/custom-templates/");
MockHttpServletResponse response = render("custom");
@@ -156,6 +172,7 @@ class GroovyTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/message.tpl", content = "yield \"Message: ${greeting}\"")
void renderTemplate() throws Exception {
registerAndRefreshContext();
GroovyMarkupConfig config = this.context.getBean(GroovyMarkupConfig.class);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProviderTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProviderTests.java
index 86c0158471..e3a3d1f804 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProviderTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProviderTests.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.beans.factory.aot.AotServices;
import org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAvailabilityProvider.GroovyTemplateAvailabilityProperties;
import org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAvailabilityProvider.GroovyTemplateAvailabilityRuntimeHints;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.mock.env.MockEnvironment;
@@ -45,6 +46,7 @@ class GroovyTemplateAvailabilityProviderTests {
private final MockEnvironment environment = new MockEnvironment();
@Test
+ @WithResource(name = "templates/home.tpl")
void availabilityOfTemplateInDefaultLocation() {
assertThat(this.provider.isTemplateAvailable("home", this.environment, getClass().getClassLoader(),
this.resourceLoader))
@@ -59,6 +61,7 @@ class GroovyTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "custom-templates/custom.tpl")
void availabilityOfTemplateWithCustomLoaderPath() {
this.environment.setProperty("spring.groovy.template.resource-loader-path", "classpath:/custom-templates/");
assertThat(this.provider.isTemplateAvailable("custom", this.environment, getClass().getClassLoader(),
@@ -67,6 +70,7 @@ class GroovyTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "custom-templates/custom.tpl")
void availabilityOfTemplateWithCustomLoaderPathConfiguredAsAList() {
this.environment.setProperty("spring.groovy.template.resource-loader-path[0]", "classpath:/custom-templates/");
assertThat(this.provider.isTemplateAvailable("custom", this.environment, getClass().getClassLoader(),
@@ -75,6 +79,7 @@ class GroovyTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "templates/prefix/prefixed.tpl")
void availabilityOfTemplateWithCustomPrefix() {
this.environment.setProperty("spring.groovy.template.prefix", "prefix/");
assertThat(this.provider.isTemplateAvailable("prefixed", this.environment, getClass().getClassLoader(),
@@ -83,6 +88,7 @@ class GroovyTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "templates/suffixed.groovytemplate")
void availabilityOfTemplateWithCustomSuffix() {
this.environment.setProperty("spring.groovy.template.suffix", ".groovytemplate");
assertThat(this.provider.isTemplateAvailable("suffixed", this.environment, getClass().getClassLoader(),
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java
index 1a578b657b..4d5e6c478c 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.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.
@@ -16,6 +16,10 @@
package org.springframework.boot.autoconfigure.hazelcast;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.util.Map;
import com.hazelcast.config.Config;
@@ -38,6 +42,7 @@ import org.springframework.boot.test.context.assertj.AssertableApplicationContex
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
@@ -57,6 +62,7 @@ class HazelcastAutoConfigurationServerTests {
.withConfiguration(AutoConfigurations.of(HazelcastAutoConfiguration.class));
@Test
+ @WithHazelcastXmlResource
void defaultConfigFile() {
// hazelcast.xml present in root classpath
this.contextRunner.run((context) -> {
@@ -201,6 +207,7 @@ class HazelcastAutoConfigurationServerTests {
}
@Test
+ @WithHazelcastXmlResource
void autoConfiguredConfigUsesApplicationClassLoader() {
this.contextRunner.run((context) -> {
Config config = context.getBean(HazelcastInstance.class).getConfig();
@@ -209,6 +216,7 @@ class HazelcastAutoConfigurationServerTests {
}
@Test
+ @WithHazelcastXmlResource
void autoConfiguredConfigUsesSpringManagedContext() {
this.contextRunner.run((context) -> {
Config config = context.getBean(HazelcastInstance.class).getConfig();
@@ -217,6 +225,7 @@ class HazelcastAutoConfigurationServerTests {
}
@Test
+ @WithHazelcastXmlResource
void autoConfiguredConfigCanUseSpringAwareComponent() {
this.contextRunner.withPropertyValues("test.hazelcast.key=42").run((context) -> {
HazelcastInstance hz = context.getBean(HazelcastInstance.class);
@@ -226,14 +235,19 @@ class HazelcastAutoConfigurationServerTests {
}
@Test
+ @WithHazelcastXmlResource
void autoConfiguredConfigWithoutHazelcastSpringDoesNotUseSpringManagedContext() {
- this.contextRunner.withClassLoader(new FilteredClassLoader(SpringManagedContext.class)).run((context) -> {
- Config config = context.getBean(HazelcastInstance.class).getConfig();
- assertThat(config.getManagedContext()).isNull();
- });
+ this.contextRunner
+ .withClassLoader(
+ new FilteredClassLoader(Thread.currentThread().getContextClassLoader(), SpringManagedContext.class))
+ .run((context) -> {
+ Config config = context.getBean(HazelcastInstance.class).getConfig();
+ assertThat(config.getManagedContext()).isNull();
+ });
}
@Test
+ @WithHazelcastXmlResource
void autoConfiguredContextCanOverrideManagementContextUsingCustomizer() {
this.contextRunner.withBean(TestHazelcastConfigCustomizer.class).run((context) -> {
Config config = context.getBean(HazelcastInstance.class).getConfig();
@@ -242,6 +256,7 @@ class HazelcastAutoConfigurationServerTests {
}
@Test
+ @WithHazelcastXmlResource
void autoConfiguredConfigSetsHazelcastLoggingToSlf4j() {
this.contextRunner.run((context) -> {
Config config = context.getBean(HazelcastInstance.class).getConfig();
@@ -322,4 +337,24 @@ class HazelcastAutoConfigurationServerTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "hazelcast.xml", content = """
+
+ default-instance
+
+
+
+
+
+
+
+
+ """)
+ @interface WithHazelcastXmlResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationTests.java
index fdff5e4210..def1dcb188 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationTests.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.
@@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.core.io.ClassPathResource;
import static org.assertj.core.api.Assertions.assertThat;
@@ -37,7 +38,39 @@ class HazelcastAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(HazelcastAutoConfiguration.class));
@Test
- void defaultConfigFile() {
+ @WithResource(name = "hazelcast.xml", content = """
+
+ default-instance
+
+
+
+
+
+
+
+
+ """)
+ @WithResource(name = "hazelcast.yml", content = """
+ hazelcast:
+ network:
+ join:
+ auto-detection:
+ enabled: false
+ multicast:
+ enabled: false
+ """)
+ @WithResource(name = "hazelcast.yaml", content = """
+ hazelcast:
+ network:
+ join:
+ auto-detection:
+ enabled: false
+ multicast:
+ enabled: false
+ """)
+ void defaultConfigFileIsHazelcastXml() {
// no hazelcast-client.xml and hazelcast.xml is present in root classpath
// this also asserts that XML has priority over YAML
// as hazelcast.yaml, hazelcast.yml, and hazelcast.xml are available.
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfigurationTests.java
index 7a65682b93..38f420f6da 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfigurationTests.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.autoconfigure.context.PropertyPlaceholderAutoCon
import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.info.GitProperties;
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;
@@ -90,6 +91,13 @@ class ProjectInfoAutoConfigurationTests {
}
@Test
+ @WithResource(name = "META-INF/build-info.properties", content = """
+ build.group=com.example
+ build.artifact=demo
+ build.name=Demo Project
+ build.version=0.0.1-SNAPSHOT
+ build.time=2016-03-04T14:16:05.000Z
+ """)
void buildPropertiesDefaultLocation() {
this.contextRunner.run((context) -> {
BuildProperties buildProperties = context.getBean(BuildProperties.class);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java
index f23e0fd71c..8ab1525fd7 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.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.
@@ -57,6 +57,7 @@ import org.springframework.boot.sql.init.DatabaseInitializationMode;
import org.springframework.boot.sql.init.DatabaseInitializationSettings;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.assertj.SimpleAsyncTaskExecutorAssert;
+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;
@@ -378,6 +379,8 @@ class IntegrationAutoConfigurationTests {
}
@Test
+ @WithResource(name = "META-INF/spring.integration.properties",
+ content = "spring.integration.endpoints.noAutoStartup=testService*")
void integrationGlobalPropertiesFromSpringIntegrationPropertiesFile() {
this.contextRunner
.withPropertyValues("spring.integration.channel.auto-create=false",
@@ -558,7 +561,7 @@ class IntegrationAutoConfigurationTests {
}
@MessagingGateway
- interface TestGateway extends RequestReplyExchanger {
+ public interface TestGateway extends RequestReplyExchanger {
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationPropertiesEnvironmentPostProcessorTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationPropertiesEnvironmentPostProcessorTests.java
index 1b4bbab884..4cacb3e54d 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationPropertiesEnvironmentPostProcessorTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationPropertiesEnvironmentPostProcessorTests.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.
@@ -37,6 +37,7 @@ import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.origin.Origin;
import org.springframework.boot.origin.OriginLookup;
import org.springframework.boot.origin.TextResourceOrigin;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;
@@ -60,6 +61,8 @@ import static org.mockito.Mockito.mock;
class IntegrationPropertiesEnvironmentPostProcessorTests {
@Test
+ @WithResource(name = "META-INF/spring.integration.properties",
+ content = "spring.integration.endpoints.noAutoStartup=testService*")
void postProcessEnvironmentAddPropertySource() {
ConfigurableEnvironment environment = new StandardEnvironment();
new IntegrationPropertiesEnvironmentPostProcessor().postProcessEnvironment(environment,
@@ -69,6 +72,8 @@ class IntegrationPropertiesEnvironmentPostProcessorTests {
}
@Test
+ @WithResource(name = "META-INF/spring.integration.properties",
+ content = "spring.integration.endpoints.noAutoStartup=testService*")
void postProcessEnvironmentAddPropertySourceLast() {
ConfigurableEnvironment environment = new StandardEnvironment();
environment.getPropertySources()
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDriverConfigurationFailureAnalyzerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDriverConfigurationFailureAnalyzerTests.java
index 9dafdc04b7..c9030edae2 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDriverConfigurationFailureAnalyzerTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDriverConfigurationFailureAnalyzerTests.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.
@@ -24,6 +24,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration;
import org.springframework.boot.diagnostics.FailureAnalysis;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
@@ -37,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class HikariDriverConfigurationFailureAnalyzerTests {
@Test
+ @WithResource(name = "schema.sql", content = "")
void failureAnalysisIsPerformed() {
FailureAnalysis failureAnalysis = performAnalysis(TestConfiguration.class);
assertThat(failureAnalysis).isNotNull();
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcClientAutoConfigurationTests.java
index 6c4035dc79..209f9df0e3 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcClientAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcClientAutoConfigurationTests.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.
@@ -22,6 +22,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.simple.JdbcClient;
@@ -68,6 +69,16 @@ class JdbcClientAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/city/V1__init.sql", content = """
+ CREATE SEQUENCE city_seq INCREMENT BY 50;
+ CREATE TABLE CITY (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY,
+ name VARCHAR(30),
+ state VARCHAR(30),
+ country VARCHAR(30),
+ map VARCHAR(30)
+ );
+ """)
void jdbcClientIsOrderedAfterFlywayMigration() {
this.contextRunner.withUserConfiguration(JdbcClientDataSourceMigrationValidator.class)
.withPropertyValues("spring.flyway.locations:classpath:db/city")
@@ -79,6 +90,31 @@ class JdbcClientAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/changelog/db.changelog-city.yaml", content = """
+ databaseChangeLog:
+ - changeSet:
+ id: 1
+ author: dsyer
+ changes:
+ - createSequence:
+ sequenceName: city_seq
+ incrementBy: 50
+ - createTable:
+ tableName: city
+ columns:
+ - column:
+ name: id
+ type: bigint
+ autoIncrement: true
+ constraints:
+ primaryKey: true
+ nullable: false
+ - column:
+ name: name
+ type: varchar(50)
+ constraints:
+ nullable: false
+ """)
void jdbcClientIsOrderedAfterLiquibaseMigration() {
this.contextRunner.withUserConfiguration(JdbcClientDataSourceMigrationValidator.class)
.withPropertyValues("spring.liquibase.change-log:classpath:db/changelog/db.changelog-city.yaml")
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.java
index 7154f618dd..9326b73131 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.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.
@@ -16,6 +16,10 @@
package org.springframework.boot.autoconfigure.jdbc;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.util.Collections;
import javax.sql.DataSource;
@@ -27,6 +31,7 @@ import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration;
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;
@@ -149,6 +154,13 @@ class JdbcTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "schema.sql", content = """
+ CREATE TABLE BAR (
+ id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
+ name VARCHAR(30)
+ );
+ """)
+ @WithResource(name = "data.sql", content = "INSERT INTO BAR VALUES (1, 'Andy');")
void testDependencyToScriptBasedDataSourceInitialization() {
this.contextRunner.withConfiguration(AutoConfigurations.of(SqlInitializationAutoConfiguration.class))
.withUserConfiguration(DataSourceInitializationValidator.class)
@@ -159,6 +171,16 @@ class JdbcTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/city/V1__init.sql", content = """
+ CREATE SEQUENCE city_seq INCREMENT BY 50;
+ CREATE TABLE CITY (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY,
+ name VARCHAR(30),
+ state VARCHAR(30),
+ country VARCHAR(30),
+ map VARCHAR(30)
+ );
+ """)
void testDependencyToFlyway() {
this.contextRunner.withUserConfiguration(DataSourceMigrationValidator.class)
.withPropertyValues("spring.flyway.locations:classpath:db/city")
@@ -170,6 +192,16 @@ class JdbcTemplateAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/city/V1__init.sql", content = """
+ CREATE SEQUENCE city_seq INCREMENT BY 50;
+ CREATE TABLE CITY (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY,
+ name VARCHAR(30),
+ state VARCHAR(30),
+ country VARCHAR(30),
+ map VARCHAR(30)
+ );
+ """)
void testDependencyToFlywayWithJdbcTemplateMixed() {
this.contextRunner.withUserConfiguration(NamedParameterDataSourceMigrationValidator.class)
.withPropertyValues("spring.flyway.locations:classpath:db/city")
@@ -182,6 +214,7 @@ class JdbcTemplateAutoConfigurationTests {
}
@Test
+ @WithDbChangelogCityYamlResource
void testDependencyToLiquibase() {
this.contextRunner.withUserConfiguration(DataSourceMigrationValidator.class)
.withPropertyValues("spring.liquibase.change-log:classpath:db/changelog/db.changelog-city.yaml")
@@ -193,6 +226,7 @@ class JdbcTemplateAutoConfigurationTests {
}
@Test
+ @WithDbChangelogCityYamlResource
void testDependencyToLiquibaseWithJdbcTemplateMixed() {
this.contextRunner.withUserConfiguration(NamedParameterDataSourceMigrationValidator.class)
.withPropertyValues("spring.liquibase.change-log:classpath:db/changelog/db.changelog-city.yaml")
@@ -291,4 +325,35 @@ class JdbcTemplateAutoConfigurationTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "db/changelog/db.changelog-city.yaml", content = """
+ databaseChangeLog:
+ - changeSet:
+ id: 1
+ author: dsyer
+ changes:
+ - createSequence:
+ sequenceName: city_seq
+ incrementBy: 50
+ - createTable:
+ tableName: city
+ columns:
+ - column:
+ name: id
+ type: bigint
+ autoIncrement: true
+ constraints:
+ primaryKey: true
+ nullable: false
+ - column:
+ name: name
+ type: varchar(50)
+ constraints:
+ nullable: false
+ """)
+ @interface WithDbChangelogCityYamlResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
index 9e24b43d13..05afc38597 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
@@ -54,6 +54,7 @@ import org.springframework.boot.test.context.assertj.AssertableApplicationContex
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.testsupport.assertj.SimpleAsyncTaskExecutorAssert;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
@@ -119,6 +120,8 @@ class KafkaAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(KafkaAutoConfiguration.class, SslAutoConfiguration.class));
@Test
+ @WithResource(name = "ksLoc")
+ @WithResource(name = "tsLoc")
void consumerProperties() {
this.contextRunner.withPropertyValues("spring.kafka.bootstrap-servers=foo:1234",
"spring.kafka.properties.foo=bar", "spring.kafka.properties.baz=qux",
@@ -200,6 +203,8 @@ class KafkaAutoConfigurationTests {
}
@Test
+ @WithResource(name = "ksLocP")
+ @WithResource(name = "tsLocP")
void producerProperties() {
this.contextRunner.withPropertyValues("spring.kafka.clientId=cid",
"spring.kafka.properties.foo.bar.baz=qux.fiz.buz", "spring.kafka.producer.acks=all",
@@ -270,6 +275,8 @@ class KafkaAutoConfigurationTests {
}
@Test
+ @WithResource(name = "ksLocP")
+ @WithResource(name = "tsLocP")
void adminProperties() {
this.contextRunner
.withPropertyValues("spring.kafka.clientId=cid", "spring.kafka.properties.foo.bar.baz=qux.fiz.buz",
@@ -330,8 +337,10 @@ class KafkaAutoConfigurationTests {
});
}
- @SuppressWarnings("unchecked")
@Test
+ @SuppressWarnings("unchecked")
+ @WithResource(name = "ksLocP")
+ @WithResource(name = "tsLocP")
void streamsProperties() {
this.contextRunner.withUserConfiguration(EnableKafkaStreamsConfiguration.class)
.withPropertyValues("spring.kafka.client-id=cid",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfigurationTests.java
index 8833ccd11b..74249e5d35 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfigurationTests.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.
@@ -16,6 +16,11 @@
package org.springframework.boot.autoconfigure.ldap.embedded;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
import com.unboundid.ldap.listener.InMemoryDirectoryServer;
import com.unboundid.ldap.sdk.BindResult;
import com.unboundid.ldap.sdk.DN;
@@ -30,6 +35,7 @@ import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -100,6 +106,7 @@ class EmbeddedLdapAutoConfigurationTests {
}
@Test
+ @WithSchemaLdifResource
void testSetLdifFile() {
this.contextRunner.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org").run((context) -> {
InMemoryDirectoryServer server = context.getBean(InMemoryDirectoryServer.class);
@@ -108,6 +115,7 @@ class EmbeddedLdapAutoConfigurationTests {
}
@Test
+ @WithSchemaLdifResource
void testQueryEmbeddedLdap() {
this.contextRunner.withPropertyValues("spring.ldap.embedded.base-dn:dc=spring,dc=org")
.withConfiguration(AutoConfigurations.of(LdapAutoConfiguration.class))
@@ -130,6 +138,34 @@ class EmbeddedLdapAutoConfigurationTests {
}
@Test
+ @WithResource(name = "custom-schema.ldif", content = """
+ dn: cn=schema
+ attributeTypes: ( 1.3.6.1.4.1.32473.1.1.1
+ NAME 'exampleAttributeName'
+ DESC 'An example attribute type definition'
+ EQUALITY caseIgnoreMatch
+ ORDERING caseIgnoreOrderingMatch
+ SUBSTR caseIgnoreSubstringsMatch
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
+ SINGLE-VALUE
+ X-ORIGIN 'Managing Schema Document' )
+ objectClasses: ( 1.3.6.1.4.1.32473.1.2.2
+ NAME 'exampleAuxiliaryClass'
+ DESC 'An example auxiliary object class definition'
+ SUP top
+ AUXILIARY
+ MAY exampleAttributeName
+ X-ORIGIN 'Managing Schema Document' )
+ """)
+ @WithResource(name = "custom-schema-sample.ldif", content = """
+ dn: dc=spring,dc=org
+ objectclass: top
+ objectclass: domain
+ objectclass: extensibleObject
+ objectClass: exampleAuxiliaryClass
+ dc: spring
+ exampleAttributeName: exampleAttributeName
+ """)
void testCustomSchemaValidation() {
this.contextRunner
.withPropertyValues("spring.ldap.embedded.validation.schema:classpath:custom-schema.ldif",
@@ -144,6 +180,122 @@ class EmbeddedLdapAutoConfigurationTests {
}
@Test
+ @WithResource(name = "schema-multi-basedn.ldif", content = """
+ dn: dc=spring,dc=org
+ objectclass: top
+ objectclass: domain
+ objectclass: extensibleObject
+ dc: spring
+
+ dn: ou=groups,dc=spring,dc=org
+ objectclass: top
+ objectclass: organizationalUnit
+ ou: groups
+
+ dn: cn=ROLE_USER,ou=groups,dc=spring,dc=org
+ objectclass: top
+ objectclass: groupOfUniqueNames
+ cn: ROLE_USER
+ uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
+ uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
+ uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
+ uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=spring,dc=org
+
+ dn: cn=ROLE_ADMIN,ou=groups,dc=spring,dc=org
+ objectclass: top
+ objectclass: groupOfUniqueNames
+ cn: ROLE_ADMIN
+ uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
+
+ dn: c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: country
+ c: Sweden
+ description: The country of Sweden
+
+ dn: ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: organizationalUnit
+ ou: company1
+ description: First company in Sweden
+
+ dn: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: person
+ objectclass: organizationalPerson
+ objectclass: inetOrgPerson
+ uid: some.person
+ userPassword: password
+ cn: Some Person
+ sn: Person
+ description: Sweden, Company1, Some Person
+ telephoneNumber: +46 555-123456
+
+ dn: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: person
+ objectclass: organizationalPerson
+ objectclass: inetOrgPerson
+ uid: some.person2
+ userPassword: password
+ cn: Some Person2
+ sn: Person2
+ description: Sweden, Company1, Some Person2
+ telephoneNumber: +46 555-654321
+
+ dn: cn=Some Person3,ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: person
+ objectclass: organizationalPerson
+ objectclass: inetOrgPerson
+ uid: some.person3
+ userPassword: password
+ cn: Some Person3
+ sn: Person3
+ description: Sweden, Company1, Some Person3
+ telephoneNumber: +46 555-123654
+
+ dn: cn=Some Person4,ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: person
+ objectclass: organizationalPerson
+ objectclass: inetOrgPerson
+ uid: some.person4
+ userPassword: password
+ cn: Some Person
+ sn: Person
+ description: Sweden, Company1, Some Person
+ telephoneNumber: +46 555-456321
+
+ dn: dc=vmware,dc=com
+ objectclass: top
+ objectclass: domain
+ objectclass: extensibleObject
+ dc: vmware
+
+ dn: ou=groups,dc=vmware,dc=com
+ objectclass: top
+ objectclass: organizationalUnit
+ ou: groups
+
+ dn: c=Sweden,dc=vmware,dc=com
+ objectclass: top
+ objectclass: country
+ c: Sweden
+ description:The country of Sweden
+
+ dn: cn=Some Random Person,c=Sweden,dc=vmware,dc=com
+ objectclass: top
+ objectclass: person
+ objectclass: organizationalPerson
+ objectclass: inetOrgPerson
+ uid: some.random.person
+ userPassword: password
+ cn: Some Random Person
+ sn: Person
+ description: Sweden, VMware, Some Random Person
+ telephoneNumber: +46 555-123456
+ """)
void testMultiBaseDn() {
this.contextRunner.withPropertyValues("spring.ldap.embedded.ldif:classpath:schema-multi-basedn.ldif",
"spring.ldap.embedded.base-dn[0]:dc=spring,dc=org", "spring.ldap.embedded.base-dn[1]:dc=vmware,dc=com")
@@ -206,4 +358,97 @@ class EmbeddedLdapAutoConfigurationTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "schema.ldif", content = """
+ dn: dc=spring,dc=org
+ objectclass: top
+ objectclass: domain
+ objectclass: extensibleObject
+ dc: spring
+
+ dn: ou=groups,dc=spring,dc=org
+ objectclass: top
+ objectclass: organizationalUnit
+ ou: groups
+
+ dn: cn=ROLE_USER,ou=groups,dc=spring,dc=org
+ objectclass: top
+ objectclass: groupOfUniqueNames
+ cn: ROLE_USER
+ uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
+ uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
+ uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
+ uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=spring,dc=org
+
+ dn: cn=ROLE_ADMIN,ou=groups,dc=spring,dc=org
+ objectclass: top
+ objectclass: groupOfUniqueNames
+ cn: ROLE_ADMIN
+ uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
+
+ dn: c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: country
+ c: Sweden
+ description: The country of Sweden
+
+ dn: ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: organizationalUnit
+ ou: company1
+ description: First company in Sweden
+
+ dn: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: person
+ objectclass: organizationalPerson
+ objectclass: inetOrgPerson
+ uid: some.person
+ userPassword: password
+ cn: Some Person
+ sn: Person
+ description: Sweden, Company1, Some Person
+ telephoneNumber: +46 555-123456
+
+ dn: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: person
+ objectclass: organizationalPerson
+ objectclass: inetOrgPerson
+ uid: some.person2
+ userPassword: password
+ cn: Some Person2
+ sn: Person2
+ description: Sweden, Company1, Some Person2
+ telephoneNumber: +46 555-654321
+
+ dn: cn=Some Person3,ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: person
+ objectclass: organizationalPerson
+ objectclass: inetOrgPerson
+ uid: some.person3
+ userPassword: password
+ cn: Some Person3
+ sn: Person3
+ description: Sweden, Company1, Some Person3
+ telephoneNumber: +46 555-123654
+
+ dn: cn=Some Person4,ou=company1,c=Sweden,dc=spring,dc=org
+ objectclass: top
+ objectclass: person
+ objectclass: organizationalPerson
+ objectclass: inetOrgPerson
+ uid: some.person4
+ userPassword: password
+ cn: Some Person
+ sn: Person
+ description: Sweden, Company1, Some Person
+ telephoneNumber: +46 555-456321
+ """)
+ @interface WithSchemaLdifResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/Liquibase423AutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/Liquibase423AutoConfigurationTests.java
index 850a1e6612..f12d064a24 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/Liquibase423AutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/Liquibase423AutoConfigurationTests.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.
@@ -27,6 +27,7 @@ import org.springframework.boot.test.context.assertj.AssertableApplicationContex
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import static org.assertj.core.api.Assertions.assertThat;
@@ -43,6 +44,7 @@ class Liquibase423AutoConfigurationTests {
.withPropertyValues("spring.datasource.generate-unique-name=true");
@Test
+ @WithResource(name = "db/changelog/db.changelog-master.yaml", content = "databaseChangeLog:")
void defaultSpringLiquibase() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.run(assertLiquibase((liquibase) -> {
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java
index 87acfb7078..8a7869dc53 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.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.
@@ -18,6 +18,10 @@ package org.springframework.boot.autoconfigure.liquibase;
import java.io.File;
import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;
@@ -58,6 +62,7 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
+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;
@@ -100,6 +105,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void createsDataSourceWithNoDataSourceBeanAndLiquibaseUrl() {
String jdbcUrl = "jdbc:hsqldb:mem:liquibase" + UUID.randomUUID();
this.contextRunner.withPropertyValues("spring.liquibase.url:" + jdbcUrl).run(assertLiquibase((liquibase) -> {
@@ -116,6 +122,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void defaultSpringLiquibase() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.run(assertLiquibase((liquibase) -> {
@@ -138,6 +145,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void liquibaseDataSourceIsUsedOverJdbcConnectionDetails() {
this.contextRunner
.withUserConfiguration(LiquibaseDataSourceConfiguration.class, JdbcConnectionDetailsConfiguration.class)
@@ -150,6 +158,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void liquibaseDataSourceIsUsedOverLiquibaseConnectionDetails() {
this.contextRunner
.withUserConfiguration(LiquibaseDataSourceConfiguration.class,
@@ -163,6 +172,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void liquibasePropertiesAreUsedOverJdbcConnectionDetails() {
this.contextRunner
.withPropertyValues("spring.liquibase.url=jdbc:hsqldb:mem:liquibasetest", "spring.liquibase.user=some-user",
@@ -193,6 +203,18 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/changelog/db.changelog-override.xml",
+ content = """
+
+
+
+
+ """)
void changelogXml() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.change-log:classpath:/db/changelog/db.changelog-override.xml")
@@ -201,6 +223,11 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/changelog/db.changelog-override.json", content = """
+ {
+ "databaseChangeLog": []
+ }
+ """)
void changelogJson() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.change-log:classpath:/db/changelog/db.changelog-override.json")
@@ -209,6 +236,16 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithResource(name = "db/changelog/db.changelog-override.sql", content = """
+ --liquibase formatted sql
+
+ --changeset author:awilkinson
+
+ CREATE TABLE customer (
+ id int AUTO_INCREMENT NOT NULL PRIMARY KEY,
+ name varchar(50) NOT NULL
+ );
+ """)
void changelogSql() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.change-log:classpath:/db/changelog/db.changelog-override.sql")
@@ -217,6 +254,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void defaultValues() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.run(assertLiquibase((liquibase) -> {
@@ -235,6 +273,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideContexts() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.contexts:test, production")
@@ -242,6 +281,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideDefaultSchema() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.default-schema:public")
@@ -249,6 +289,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideLiquibaseInfrastructure() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.liquibase-schema:public",
@@ -269,6 +310,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideDropFirst() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.drop-first:true")
@@ -276,6 +318,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideClearChecksums() {
String jdbcUrl = "jdbc:hsqldb:mem:liquibase" + UUID.randomUUID();
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
@@ -287,6 +330,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideDataSource() {
String jdbcUrl = "jdbc:hsqldb:mem:liquibase" + UUID.randomUUID();
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
@@ -299,6 +343,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideDataSourceAndDriverClassName() {
String jdbcUrl = "jdbc:hsqldb:mem:liquibase" + UUID.randomUUID();
String driverClassName = "org.hsqldb.jdbcDriver";
@@ -313,6 +358,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideUser() {
String databaseName = "normal" + UUID.randomUUID();
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
@@ -327,6 +373,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideUserWhenCustom() {
this.contextRunner.withUserConfiguration(CustomDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.user:test", "spring.liquibase.password:secret")
@@ -340,6 +387,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void createDataSourceDoesNotFallbackToEmbeddedProperties() {
String jdbcUrl = "jdbc:hsqldb:mem:liquibase" + UUID.randomUUID();
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
@@ -352,6 +400,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideUserAndFallbackToEmbeddedProperties() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.user:sa")
@@ -362,6 +411,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideTestRollbackOnUpdate() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.test-rollback-on-update:true")
@@ -382,12 +432,14 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void logging(CapturedOutput output) {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.run(assertLiquibase((liquibase) -> assertThat(output).doesNotContain(": liquibase:")));
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideLabelFilter() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.label-filter:test, production")
@@ -395,6 +447,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideShowSummary() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.show-summary=off")
@@ -406,6 +459,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideShowSummaryOutput() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.show-summary-output=all")
@@ -417,6 +471,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideUiService() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.ui-service=console")
@@ -425,6 +480,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
@SuppressWarnings("unchecked")
void testOverrideParameters() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
@@ -438,6 +494,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void rollbackFile(@TempDir Path temp) throws IOException {
File file = Files.createTempFile(temp, "rollback-file", "sql").toFile();
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
@@ -451,6 +508,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void liquibaseDataSource() {
this.contextRunner
.withUserConfiguration(LiquibaseDataSourceConfiguration.class, EmbeddedDataSourceConfiguration.class)
@@ -461,6 +519,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void liquibaseDataSourceWithoutDataSourceAutoConfiguration() {
this.contextRunner.withUserConfiguration(LiquibaseDataSourceConfiguration.class).run((context) -> {
SpringLiquibase liquibase = context.getBean(SpringLiquibase.class);
@@ -469,6 +528,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void userConfigurationBeans() {
this.contextRunner
.withUserConfiguration(LiquibaseUserConfiguration.class, EmbeddedDataSourceConfiguration.class)
@@ -479,6 +539,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void userConfigurationEntityManagerFactoryDependency() {
this.contextRunner.withConfiguration(AutoConfigurations.of(HibernateJpaAutoConfiguration.class))
.withUserConfiguration(LiquibaseUserConfiguration.class, EmbeddedDataSourceConfiguration.class)
@@ -489,6 +550,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void userConfigurationJdbcTemplateDependency() {
this.contextRunner.withConfiguration(AutoConfigurations.of(JdbcTemplateAutoConfiguration.class))
.withUserConfiguration(LiquibaseUserConfiguration.class, EmbeddedDataSourceConfiguration.class)
@@ -499,6 +561,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void overrideTag() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.tag:1.0.0")
@@ -506,6 +569,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void whenLiquibaseIsAutoConfiguredThenJooqDslContextDependsOnSpringLiquibaseBeans() {
this.contextRunner.withConfiguration(AutoConfigurations.of(JooqAutoConfiguration.class))
.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
@@ -516,6 +580,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void whenCustomSpringLiquibaseIsDefinedThenJooqDslContextDependsOnSpringLiquibaseBeans() {
this.contextRunner.withConfiguration(AutoConfigurations.of(JooqAutoConfiguration.class))
.withUserConfiguration(LiquibaseUserConfiguration.class, EmbeddedDataSourceConfiguration.class)
@@ -536,6 +601,7 @@ class LiquibaseAutoConfigurationTests {
}
@Test
+ @WithDbChangelogMasterYamlResource
void whenCustomizerBeanIsDefinedThenItIsConfiguredOnSpringLiquibase() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CustomizerConfiguration.class)
.run(assertLiquibase((liquibase) -> assertThat(liquibase.getCustomizer()).isNotNull()));
@@ -691,4 +757,32 @@ class LiquibaseAutoConfigurationTests {
}
+ @WithResource(name = "db/changelog/db.changelog-master.yaml", content = """
+ 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
+ """)
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+ @interface WithDbChangelogMasterYamlResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java
index 27f4baddff..3c3452b595 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfigurationTests.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.
@@ -32,6 +32,7 @@ import org.springframework.boot.autoconfigure.jndi.JndiPropertiesHidingClassLoad
import org.springframework.boot.autoconfigure.jndi.TestableInitialContextFactory;
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
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;
import org.springframework.mail.MailSender;
@@ -64,7 +65,8 @@ class MailSenderAutoConfigurationTests {
this.initialContextFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, TestableInitialContextFactory.class.getName());
this.threadContextClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(new JndiPropertiesHidingClassLoader(getClass().getClassLoader()));
+ Thread.currentThread()
+ .setContextClassLoader(new JndiPropertiesHidingClassLoader(Thread.currentThread().getContextClassLoader()));
}
@AfterEach
@@ -254,6 +256,7 @@ class MailSenderAutoConfigurationTests {
}
@Test
+ @WithPackageResources("test.jks")
void smtpSslBundle() {
this.contextRunner
.withPropertyValues("spring.mail.host:localhost", "spring.mail.ssl.bundle:test-bundle",
@@ -282,6 +285,7 @@ class MailSenderAutoConfigurationTests {
}
@Test
+ @WithPackageResources("test.jks")
void smtpsSslBundle() {
this.contextRunner
.withPropertyValues("spring.mail.host:localhost", "spring.mail.protocol:smtps",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java
index b2122ebecc..4ba6677017 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.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.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
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;
@@ -85,6 +86,7 @@ class MongoAutoConfigurationTests {
}
@Test
+ @WithPackageResources("test.jks")
void configuresSslWithBundle() {
this.contextRunner
.withPropertyValues("spring.data.mongodb.ssl.bundle=test-bundle",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfigurationTests.java
index a3225f4fea..44ee73001b 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfigurationTests.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.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -93,6 +94,7 @@ class MongoReactiveAutoConfigurationTests {
}
@Test
+ @WithPackageResources("test.jks")
void configuresSslWithBundle() {
this.contextRunner
.withPropertyValues("spring.data.mongodb.ssl.bundle=test-bundle",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfigurationReactiveIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfigurationReactiveIntegrationTests.java
index 9f9524eaa7..0836b7d717 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfigurationReactiveIntegrationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfigurationReactiveIntegrationTests.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.
@@ -105,9 +105,10 @@ class MustacheAutoConfigurationReactiveIntegrationTests {
@Bean
MustacheViewResolver viewResolver() {
Mustache.Compiler compiler = Mustache.compiler()
- .withLoader(new MustacheResourceTemplateLoader("classpath:/mustache-templates/", ".html"));
+ .withLoader(new MustacheResourceTemplateLoader(
+ "classpath:/org/springframework/boot/autoconfigure/mustache/", ".html"));
MustacheViewResolver resolver = new MustacheViewResolver(compiler);
- resolver.setPrefix("classpath:/mustache-templates/");
+ resolver.setPrefix("classpath:/org/springframework/boot/autoconfigure/mustache/");
resolver.setSuffix(".html");
return resolver;
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfigurationServletIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfigurationServletIntegrationTests.java
index c6c892e333..aba169ffc3 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfigurationServletIntegrationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfigurationServletIntegrationTests.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.
@@ -115,9 +115,10 @@ class MustacheAutoConfigurationServletIntegrationTests {
@Bean
MustacheViewResolver viewResolver() {
Mustache.Compiler compiler = Mustache.compiler()
- .withLoader(new MustacheResourceTemplateLoader("classpath:/mustache-templates/", ".html"));
+ .withLoader(new MustacheResourceTemplateLoader(
+ "classpath:/org/springframework/boot/autoconfigure/mustache/", ".html"));
MustacheViewResolver resolver = new MustacheViewResolver(compiler);
- resolver.setPrefix("classpath:/mustache-templates/");
+ resolver.setPrefix("classpath:/org/springframework/boot/autoconfigure/mustache/");
resolver.setSuffix(".html");
return resolver;
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java
index 95b1f92f14..cc672e2f6a 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.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.
@@ -17,6 +17,10 @@
package org.springframework.boot.autoconfigure.orm.jpa;
import java.io.File;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -47,6 +51,7 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.testsupport.BuildOutput;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -209,6 +214,7 @@ abstract class AbstractJpaAutoConfigurationTests {
}
@Test
+ @WithMetaInfPersistenceXmlResource
void usesManuallyDefinedLocalContainerEntityManagerFactoryBeanUsingBuilder() {
this.contextRunner.withPropertyValues("spring.jpa.properties.a=b")
.withUserConfiguration(TestConfigurationWithEntityManagerFactoryBuilder.class)
@@ -221,6 +227,7 @@ abstract class AbstractJpaAutoConfigurationTests {
}
@Test
+ @WithMetaInfPersistenceXmlResource
void usesManuallyDefinedLocalContainerEntityManagerFactoryBeanIfAvailable() {
this.contextRunner.withUserConfiguration(TestConfigurationWithLocalContainerEntityManagerFactoryBean.class)
.run((context) -> {
@@ -232,6 +239,7 @@ abstract class AbstractJpaAutoConfigurationTests {
}
@Test
+ @WithMetaInfPersistenceXmlResource
void usesManuallyDefinedEntityManagerFactoryIfAvailable() {
this.contextRunner.withUserConfiguration(TestConfigurationWithLocalContainerEntityManagerFactoryBean.class)
.run((context) -> {
@@ -501,4 +509,20 @@ abstract class AbstractJpaAutoConfigurationTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "META-INF/persistence.xml",
+ content = """
+
+
+
+ org.springframework.boot.autoconfigure.orm.jpa.test.City
+ true
+
+
+ """)
+ @interface WithMetaInfPersistenceXmlResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/Hibernate2ndLevelCacheIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/Hibernate2ndLevelCacheIntegrationTests.java
index f3b2ff2521..274c373e0f 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/Hibernate2ndLevelCacheIntegrationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/Hibernate2ndLevelCacheIntegrationTests.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.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
@@ -41,6 +42,20 @@ class Hibernate2ndLevelCacheIntegrationTests {
.withUserConfiguration(TestConfiguration.class);
@Test
+ @WithResource(name = "hazelcast.xml", content = """
+
+ default-instance
+
+
+
+
+
+
+
+
+ """)
void hibernate2ndLevelCacheWithJCacheAndHazelcast() {
String cachingProviderFqn = HazelcastServerCachingProvider.class.getName();
String configLocation = "classpath:hazelcast.xml";
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java
index 3d0d625c33..e5d5b141df 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.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.
@@ -72,6 +72,7 @@ import org.springframework.boot.orm.jpa.hibernate.SpringJtaPlatform;
import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitialization;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ContextConsumer;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
@@ -129,6 +130,8 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
}
@Test
+ @WithResource(name = "city.sql",
+ content = "INSERT INTO CITY (ID, NAME, STATE, COUNTRY, MAP) values (2000, 'Washington', 'DC', 'US', 'Google')")
void testDmlScriptRunsEarly() {
contextRunner().withUserConfiguration(TestInitializedJpaConfiguration.class)
.withClassLoader(new HideDataScriptClassLoader())
@@ -139,6 +142,16 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
}
@Test
+ @WithResource(name = "db/city/V1__init.sql", content = """
+ CREATE SEQUENCE city_seq INCREMENT BY 50;
+ CREATE TABLE CITY (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY,
+ name VARCHAR(30),
+ state VARCHAR(30),
+ country VARCHAR(30),
+ map VARCHAR(30)
+ );
+ """)
void testFlywaySwitchOffDdlAuto() {
contextRunner().withPropertyValues("spring.sql.init.mode:never", "spring.flyway.locations:classpath:db/city")
.withConfiguration(AutoConfigurations.of(FlywayAutoConfiguration.class))
@@ -146,6 +159,17 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
}
@Test
+ @WithResource(name = "db/city/V1__init.sql", content = """
+ CREATE SEQUENCE city_seq INCREMENT BY 50;
+
+ CREATE TABLE CITY (
+ id BIGINT GENERATED BY DEFAULT AS IDENTITY,
+ name VARCHAR(30),
+ state VARCHAR(30),
+ country VARCHAR(30),
+ map VARCHAR(30)
+ );
+ """)
void testFlywayPlusValidation() {
contextRunner()
.withPropertyValues("spring.sql.init.mode:never", "spring.flyway.locations:classpath:db/city",
@@ -155,6 +179,46 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
}
@Test
+ @WithResource(name = "db/changelog/db.changelog-city.yaml", content = """
+ databaseChangeLog:
+ - changeSet:
+ id: 1
+ author: dsyer
+ changes:
+ - createSequence:
+ sequenceName: city_seq
+ incrementBy: 50
+ - createTable:
+ tableName: city
+ columns:
+ - column:
+ name: id
+ type: bigint
+ autoIncrement: true
+ constraints:
+ primaryKey: true
+ nullable: false
+ - column:
+ name: name
+ type: varchar(50)
+ constraints:
+ nullable: false
+ - column:
+ name: state
+ type: varchar(50)
+ constraints:
+ nullable: false
+ - column:
+ name: country
+ type: varchar(50)
+ constraints:
+ nullable: false
+ - column:
+ name: map
+ type: varchar(50)
+ constraints:
+ nullable: true
+ """)
void testLiquibasePlusValidation() {
contextRunner()
.withPropertyValues("spring.liquibase.change-log:classpath:db/changelog/db.changelog-city.yaml",
@@ -296,9 +360,32 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
}
@Test
+ @WithResource(name = "META-INF/mappings/non-annotated.xml",
+ content = """
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ """)
+ @WithResource(name = "non-annotated-data.sql",
+ content = "INSERT INTO NON_ANNOTATED (id, item) values (2000, 'Test');")
void customResourceMapping() {
contextRunner().withClassLoader(new HideDataScriptClassLoader())
- .withPropertyValues("spring.sql.init.data-locations:classpath:/db/non-annotated-data.sql",
+ .withPropertyValues("spring.sql.init.data-locations:classpath:non-annotated-data.sql",
"spring.jpa.mapping-resources=META-INF/mappings/non-annotated.xml",
"spring.jpa.defer-datasource-initialization=true")
.run((context) -> {
@@ -368,6 +455,8 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
}
@Test
+ @WithResource(name = "city.sql",
+ content = "INSERT INTO CITY (ID, NAME, STATE, COUNTRY, MAP) values (2000, 'Washington', 'DC', 'US', 'Google')")
void eventListenerCanBeRegisteredAsBeans() {
contextRunner().withUserConfiguration(TestInitializedJpaConfiguration.class)
.withClassLoader(new HideDataScriptClassLoader())
@@ -478,6 +567,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
}
@Test
+ @WithMetaInfPersistenceXmlResource
void whenLocalContainerEntityManagerFactoryBeanHasNoJpaVendorAdapterAutoConfigurationSucceeds() {
contextRunner()
.withUserConfiguration(
@@ -698,7 +788,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
private static final List HIDDEN_RESOURCES = Arrays.asList("schema-all.sql", "schema.sql");
HideDataScriptClassLoader() {
- super(new URL[0], HideDataScriptClassLoader.class.getClassLoader());
+ super(new URL[0], Thread.currentThread().getContextClassLoader());
}
@Override
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcAutoConfigurationTests.java
index 9ef8ee88f3..fb4f3eb4f1 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcAutoConfigurationTests.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.
@@ -44,6 +44,8 @@ import org.springframework.boot.r2dbc.EmbeddedDatabaseConnection;
import org.springframework.boot.r2dbc.OptionsCapableConnectionFactory;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.ForkedClassPath;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.r2dbc.core.DatabaseClient;
@@ -237,6 +239,9 @@ class R2dbcAutoConfigurationTests {
}
@Test
+ @WithResource(name = "META-INF/services/io.r2dbc.spi.ConnectionFactoryProvider",
+ content = "org.springframework.boot.autoconfigure.r2dbc.SimpleConnectionFactoryProvider")
+ @ForkedClassPath
void configureWithPoolShouldApplyAdditionalProperties() {
this.contextRunner
.withPropertyValues("spring.r2dbc.url:r2dbc:simple://foo", "spring.r2dbc.properties.test=value",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfigurationTests.java
index 62569319c3..7362a2aebc 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfigurationTests.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.
@@ -29,6 +29,7 @@ import org.springframework.boot.ssl.NoSuchSslBundleException;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -126,30 +127,32 @@ class RSocketServerAutoConfigurationTests {
}
@Test
+ @WithPackageResources("test.jks")
void shouldUseSslWhenRocketServerSslIsConfigured() {
reactiveWebContextRunner()
- .withPropertyValues("spring.rsocket.server.ssl.keyStore=classpath:rsocket/test.jks",
+ .withPropertyValues("spring.rsocket.server.ssl.keyStore=classpath:test.jks",
"spring.rsocket.server.ssl.keyPassword=password", "spring.rsocket.server.port=0")
.run((context) -> assertThat(context).hasSingleBean(RSocketServerFactory.class)
.hasSingleBean(RSocketServerBootstrap.class)
.hasSingleBean(RSocketServerCustomizer.class)
.getBean(RSocketServerFactory.class)
- .hasFieldOrPropertyWithValue("ssl.keyStore", "classpath:rsocket/test.jks")
+ .hasFieldOrPropertyWithValue("ssl.keyStore", "classpath:test.jks")
.hasFieldOrPropertyWithValue("ssl.keyPassword", "password"));
}
@Test
@Disabled
+ @WithPackageResources("test.jks")
void shouldUseSslWhenRocketServerSslIsConfiguredWithSslBundle() {
reactiveWebContextRunner()
.withPropertyValues("spring.rsocket.server.port=0", "spring.rsocket.server.ssl.bundle=test-bundle",
- "spring.ssl.bundle.jks.test-bundle.keystore.location=classpath:rsocket/test.jks",
+ "spring.ssl.bundle.jks.test-bundle.keystore.location=classpath:test.jks",
"spring.ssl.bundle.jks.test-bundle.key.password=password")
.run((context) -> assertThat(context).hasSingleBean(RSocketServerFactory.class)
.hasSingleBean(RSocketServerBootstrap.class)
.hasSingleBean(RSocketServerCustomizer.class)
.getBean(RSocketServerFactory.class)
- .hasFieldOrPropertyWithValue("sslBundle.details.keyStore", "classpath:rsocket/test.jks")
+ .hasFieldOrPropertyWithValue("sslBundle.details.keyStore", "classpath:test.jks")
.hasFieldOrPropertyWithValue("sslBundle.details.keyPassword", "password"));
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.java
index 771c5cb4b6..3e84572712 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.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.
@@ -17,6 +17,10 @@
package org.springframework.boot.autoconfigure.security.oauth2.resource.reactive;
import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.net.URI;
import java.net.URL;
import java.time.Duration;
@@ -49,6 +53,7 @@ import org.springframework.boot.autoconfigure.security.oauth2.resource.JwtConver
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
@@ -173,6 +178,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void autoConfigurationUsingPublicKeyValueShouldConfigureResourceServerUsingSingleJwsAlgorithm() {
this.contextRunner
.withPropertyValues(
@@ -186,6 +192,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void autoConfigurationUsingPublicKeyValueWithMultipleJwsAlgorithmsShouldFail() {
this.contextRunner
.withPropertyValues(
@@ -284,6 +291,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void autoConfigurationShouldConfigureResourceServerUsingPublicKeyValue() {
this.contextRunner
.withPropertyValues(
@@ -539,6 +547,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void autoConfigurationShouldConfigureAudienceValidatorIfPropertyProvidedAndPublicKey() throws Exception {
this.server = new MockWebServer();
this.server.start();
@@ -891,4 +900,18 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "public-key-location", content = """
+ -----BEGIN PUBLIC KEY-----
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdlatRjRjogo3WojgGHFHYLugd
+ UWAY9iR3fy4arWNA1KoS8kVw33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQs
+ HUfQrSDv+MuSUMAe8jzKE4qW+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5D
+ o2kQ+X5xK9cipRgEKwIDAQAB
+ -----END PUBLIC KEY-----
+ """)
+ @interface WithPublicKeyResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java
index 9de6d030a8..776615eb2d 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.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.
@@ -16,6 +16,10 @@
package org.springframework.boot.autoconfigure.security.oauth2.resource.servlet;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.net.URI;
import java.net.URL;
import java.time.Instant;
@@ -48,6 +52,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.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
@@ -174,6 +179,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void autoConfigurationUsingPublicKeyValueShouldConfigureResourceServerUsingSingleJwsAlgorithm() {
this.contextRunner
.withPropertyValues(
@@ -187,6 +193,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void autoConfigurationUsingPublicKeyValueWithMultipleJwsAlgorithmsShouldFail() {
this.contextRunner
.withPropertyValues(
@@ -277,6 +284,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void autoConfigurationShouldConfigureResourceServerUsingPublicKeyValue() throws Exception {
this.server = new MockWebServer();
this.server.start();
@@ -304,6 +312,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void autoConfigurationShouldFailIfAlgorithmIsInvalid() {
this.contextRunner
.withPropertyValues(
@@ -583,6 +592,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void autoConfigurationShouldConfigureAudienceValidatorIfPropertyProvidedAndPublicKey() throws Exception {
this.server = new MockWebServer();
this.server.start();
@@ -877,4 +887,18 @@ class OAuth2ResourceServerAutoConfigurationTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "public-key-location", content = """
+ -----BEGIN PUBLIC KEY-----
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdlatRjRjogo3WojgGHFHYLugd
+ UWAY9iR3fy4arWNA1KoS8kVw33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQs
+ HUfQrSDv+MuSUMAe8jzKE4qW+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5D
+ o2kQ+X5xK9cipRgEKwIDAQAB
+ -----END PUBLIC KEY-----
+ """)
+ @interface WithPublicKeyResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.java
index 07aab477a6..8ad935049d 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.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.
@@ -32,6 +32,7 @@ import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
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.io.ClassPathResource;
@@ -90,6 +91,7 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources({ "certificate-location", "private-key-location" })
void relyingPartyRegistrationRepositoryBeanShouldBeCreatedWhenPropertiesPresent() {
this.contextRunner.withPropertyValues(getPropertyValues()).run((context) -> {
RelyingPartyRegistrationRepository repository = context.getBean(RelyingPartyRegistrationRepository.class);
@@ -124,6 +126,7 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources({ "certificate-location", "private-key-location" })
void autoConfigurationWhenSignRequestsTrueAndNoSigningCredentialsShouldThrowException() {
this.contextRunner.withPropertyValues(getPropertyValuesWithoutSigningCredentials(true)).run((context) -> {
assertThat(context).hasFailed();
@@ -133,17 +136,19 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources({ "certificate-location", "private-key-location" })
void autoConfigurationWhenSignRequestsFalseAndNoSigningCredentialsShouldNotThrowException() {
this.contextRunner.withPropertyValues(getPropertyValuesWithoutSigningCredentials(false))
.run((context) -> assertThat(context).hasSingleBean(RelyingPartyRegistrationRepository.class));
}
@Test
+ @WithPackageResources("idp-metadata")
void autoconfigurationShouldQueryAssertingPartyMetadataWhenMetadataUrlIsPresent() throws Exception {
try (MockWebServer server = new MockWebServer()) {
server.start();
String metadataUrl = server.url("").toString();
- setupMockResponse(server, new ClassPathResource("saml/idp-metadata"));
+ setupMockResponse(server, new ClassPathResource("idp-metadata"));
this.contextRunner.withPropertyValues(PREFIX + ".foo.assertingparty.metadata-uri=" + metadataUrl)
.run((context) -> {
assertThat(context).hasSingleBean(RelyingPartyRegistrationRepository.class);
@@ -153,11 +158,12 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources("idp-metadata")
void autoconfigurationShouldUseBindingFromMetadataUrlIfPresent() throws Exception {
try (MockWebServer server = new MockWebServer()) {
server.start();
String metadataUrl = server.url("").toString();
- setupMockResponse(server, new ClassPathResource("saml/idp-metadata"));
+ setupMockResponse(server, new ClassPathResource("idp-metadata"));
this.contextRunner.withPropertyValues(PREFIX + ".foo.assertingparty.metadata-uri=" + metadataUrl)
.run((context) -> {
RelyingPartyRegistrationRepository repository = context
@@ -170,11 +176,12 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources("idp-metadata")
void autoconfigurationWhenMetadataUrlAndPropertyPresentShouldUseBindingFromProperty() throws Exception {
try (MockWebServer server = new MockWebServer()) {
server.start();
String metadataUrl = server.url("").toString();
- setupMockResponse(server, new ClassPathResource("saml/idp-metadata"));
+ setupMockResponse(server, new ClassPathResource("idp-metadata"));
this.contextRunner
.withPropertyValues(PREFIX + ".foo.assertingparty.metadata-uri=" + metadataUrl,
PREFIX + ".foo.assertingparty.singlesignon.binding=redirect")
@@ -189,6 +196,7 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources({ "certificate-location", "private-key-location" })
void autoconfigurationWhenNoMetadataUrlOrPropertyPresentShouldUseRedirectBinding() {
this.contextRunner.withPropertyValues(getPropertyValuesWithoutSsoBinding()).run((context) -> {
RelyingPartyRegistrationRepository repository = context.getBean(RelyingPartyRegistrationRepository.class);
@@ -209,12 +217,14 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources({ "certificate-location", "private-key-location" })
void samlLoginShouldBeConfigured() {
this.contextRunner.withPropertyValues(getPropertyValues())
.run((context) -> assertThat(hasSecurityFilter(context, Saml2WebSsoAuthenticationFilter.class)).isTrue());
}
@Test
+ @WithPackageResources({ "private-key-location", "certificate-location" })
void samlLoginShouldBackOffWhenASecurityFilterChainBeanIsPresent() {
this.contextRunner.withConfiguration(AutoConfigurations.of(WebMvcAutoConfiguration.class))
.withUserConfiguration(TestSecurityFilterChainConfig.class)
@@ -223,13 +233,17 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources({ "certificate-location", "private-key-location" })
void samlLoginShouldShouldBeConditionalOnSecurityWebFilterClass() {
- this.contextRunner.withClassLoader(new FilteredClassLoader(SecurityFilterChain.class))
+ this.contextRunner
+ .withClassLoader(
+ new FilteredClassLoader(Thread.currentThread().getContextClassLoader(), SecurityFilterChain.class))
.withPropertyValues(getPropertyValues())
.run((context) -> assertThat(context).doesNotHaveBean(SecurityFilterChain.class));
}
@Test
+ @WithPackageResources({ "certificate-location", "private-key-location" })
void samlLogoutShouldBeConfigured() {
this.contextRunner.withPropertyValues(getPropertyValues())
.run((context) -> assertThat(hasSecurityFilter(context, Saml2LogoutRequestFilter.class)).isTrue());
@@ -241,26 +255,29 @@ class Saml2RelyingPartyAutoConfigurationTests {
PREFIX + ".foo.assertingparty.singlesignon.binding=post",
PREFIX + ".foo.assertingparty.singlesignon.sign-request=" + signRequests,
PREFIX + ".foo.assertingparty.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
- PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:saml/certificate-location" };
+ PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:certificate-location" };
}
@Test
+ @WithPackageResources("idp-metadata-with-multiple-providers")
void autoconfigurationWhenMultipleProvidersAndNoSpecifiedEntityId() throws Exception {
testMultipleProviders(null, "https://idp.example.com/idp/shibboleth");
}
@Test
+ @WithPackageResources("idp-metadata-with-multiple-providers")
void autoconfigurationWhenMultipleProvidersAndSpecifiedEntityId() throws Exception {
testMultipleProviders("https://idp.example.com/idp/shibboleth", "https://idp.example.com/idp/shibboleth");
testMultipleProviders("https://idp2.example.com/idp/shibboleth", "https://idp2.example.com/idp/shibboleth");
}
@Test
+ @WithPackageResources("idp-metadata")
void signRequestShouldApplyIfMetadataUriIsSet() throws Exception {
try (MockWebServer server = new MockWebServer()) {
server.start();
String metadataUrl = server.url("").toString();
- setupMockResponse(server, new ClassPathResource("saml/idp-metadata"));
+ setupMockResponse(server, new ClassPathResource("idp-metadata"));
this.contextRunner.withPropertyValues(PREFIX + ".foo.assertingparty.metadata-uri=" + metadataUrl,
PREFIX + ".foo.assertingparty.singlesignon.sign-request=true",
PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:org/springframework/boot/autoconfigure/security/saml2/rsa.key",
@@ -275,15 +292,16 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources("certificate-location")
void autoconfigurationWithInvalidPrivateKeyShouldFail() {
this.contextRunner.withPropertyValues(
- PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:saml/certificate-location",
- PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:saml/certificate-location",
+ PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:certificate-location",
+ PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:certificate-location",
PREFIX + ".foo.assertingparty.singlesignon.url=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php",
PREFIX + ".foo.assertingparty.singlesignon.binding=post",
PREFIX + ".foo.assertingparty.singlesignon.sign-request=false",
PREFIX + ".foo.assertingparty.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
- PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:saml/certificate-location")
+ PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:certificate-location")
.run((context) -> assertThat(context).hasFailed()
.getFailure()
.rootCause()
@@ -291,15 +309,16 @@ class Saml2RelyingPartyAutoConfigurationTests {
}
@Test
+ @WithPackageResources("private-key-location")
void autoconfigurationWithInvalidCertificateShouldFail() {
this.contextRunner.withPropertyValues(
- PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:saml/private-key-location",
- PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:saml/private-key-location",
+ PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:private-key-location",
+ PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:private-key-location",
PREFIX + ".foo.assertingparty.singlesignon.url=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php",
PREFIX + ".foo.assertingparty.singlesignon.binding=post",
PREFIX + ".foo.assertingparty.singlesignon.sign-request=false",
PREFIX + ".foo.assertingparty.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
- PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:saml/certificate-location")
+ PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:private-key-location")
.run((context) -> assertThat(context).hasFailed()
.getFailure()
.rootCause()
@@ -310,7 +329,7 @@ class Saml2RelyingPartyAutoConfigurationTests {
try (MockWebServer server = new MockWebServer()) {
server.start();
String metadataUrl = server.url("").toString();
- setupMockResponse(server, new ClassPathResource("saml/idp-metadata-with-multiple-providers"));
+ setupMockResponse(server, new ClassPathResource("idp-metadata-with-multiple-providers"));
WebApplicationContextRunner contextRunner = this.contextRunner
.withPropertyValues(PREFIX + ".foo.assertingparty.metadata-uri=" + metadataUrl);
if (specifiedEntityId != null) {
@@ -333,15 +352,15 @@ class Saml2RelyingPartyAutoConfigurationTests {
+ ".foo.assertingparty.singlesignon.url=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php",
PREFIX + ".foo.assertingparty.singlesignon.sign-request=false",
PREFIX + ".foo.assertingparty.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
- PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:saml/certificate-location" };
+ PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:certificate-location" };
}
private String[] getPropertyValues() {
return new String[] {
- PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:saml/private-key-location",
- PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:saml/certificate-location",
- PREFIX + ".foo.decryption.credentials[0].private-key-location=classpath:saml/private-key-location",
- PREFIX + ".foo.decryption.credentials[0].certificate-location=classpath:saml/certificate-location",
+ PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:private-key-location",
+ PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:certificate-location",
+ PREFIX + ".foo.decryption.credentials[0].private-key-location=classpath:private-key-location",
+ PREFIX + ".foo.decryption.credentials[0].certificate-location=classpath:certificate-location",
PREFIX + ".foo.singlelogout.url=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SLOService.php",
PREFIX + ".foo.singlelogout.response-url=https://simplesaml-for-spring-saml.cfapps.io/",
PREFIX + ".foo.singlelogout.binding=post",
@@ -349,7 +368,7 @@ class Saml2RelyingPartyAutoConfigurationTests {
PREFIX + ".foo.assertingparty.singlesignon.binding=post",
PREFIX + ".foo.assertingparty.singlesignon.sign-request=false",
PREFIX + ".foo.assertingparty.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
- PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:saml/certificate-location",
+ PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:certificate-location",
PREFIX + ".foo.asserting-party.singlelogout.url=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SLOService.php",
PREFIX + ".foo.asserting-party.singlelogout.response-url=https://simplesaml-for-spring-saml.cfapps.io/",
PREFIX + ".foo.asserting-party.singlelogout.binding=post",
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java
index 3a75d04394..3a26ce94b7 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.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.
@@ -16,6 +16,10 @@
package org.springframework.boot.autoconfigure.security.servlet;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import java.security.interfaces.RSAPublicKey;
import java.util.EnumSet;
@@ -36,6 +40,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.convert.ApplicationConversionService;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean;
import org.springframework.boot.web.servlet.filter.OrderedFilter;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -193,6 +198,7 @@ class SecurityAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void whenAConfigurationPropertyBindingConverterIsDefinedThenBindingToAnRsaKeySucceeds() {
this.contextRunner.withUserConfiguration(ConverterConfiguration.class, PropertiesConfiguration.class)
.withPropertyValues("jwt.public-key=classpath:public-key-location")
@@ -200,6 +206,7 @@ class SecurityAutoConfigurationTests {
}
@Test
+ @WithPublicKeyResource
void whenTheBeanFactoryHasAConversionServiceAndAConfigurationPropertyBindingConverterIsDefinedThenBindingToAnRsaKeySucceeds() {
this.contextRunner
.withInitializer(
@@ -295,4 +302,18 @@ class SecurityAutoConfigurationTests {
}
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @WithResource(name = "public-key-location", content = """
+ -----BEGIN PUBLIC KEY-----
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdlatRjRjogo3WojgGHFHYLugd
+ UWAY9iR3fy4arWNA1KoS8kVw33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQs
+ HUfQrSDv+MuSUMAe8jzKE4qW+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5D
+ o2kQ+X5xK9cipRgEKwIDAQAB
+ -----END PUBLIC KEY-----
+ """)
+ @interface WithPublicKeyResource {
+
+ }
+
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.java
index 30202631d8..047e06369a 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationJdbcTests.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 java.time.Duration;
import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -37,6 +38,7 @@ import org.springframework.boot.sql.init.DatabaseInitializationSettings;
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.WithResource;
import org.springframework.boot.web.servlet.AbstractFilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -63,13 +65,19 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*/
class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfigurationTests {
- private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
- .withClassLoader(new FilteredClassLoader(HazelcastIndexedSessionRepository.class,
- MongoIndexedSessionRepository.class, RedisIndexedSessionRepository.class))
- .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class,
- DataSourceTransactionManagerAutoConfiguration.class, JdbcTemplateAutoConfiguration.class,
- SessionAutoConfiguration.class))
- .withPropertyValues("spring.datasource.generate-unique-name=true");
+ private WebApplicationContextRunner contextRunner;
+
+ @BeforeEach
+ void prepareRunner() {
+ this.contextRunner = new WebApplicationContextRunner()
+ .withClassLoader(new FilteredClassLoader(Thread.currentThread().getContextClassLoader(),
+ HazelcastIndexedSessionRepository.class, MongoIndexedSessionRepository.class,
+ RedisIndexedSessionRepository.class))
+ .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class,
+ DataSourceTransactionManagerAutoConfiguration.class, JdbcTemplateAutoConfiguration.class,
+ SessionAutoConfiguration.class))
+ .withPropertyValues("spring.datasource.generate-unique-name=true");
+ }
@Test
void defaultConfig() {
@@ -127,9 +135,8 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration
@Test
void customTableName() {
- this.contextRunner
- .withPropertyValues("spring.session.jdbc.table-name=FOO_BAR",
- "spring.session.jdbc.schema=classpath:session/custom-schema-h2.sql")
+ this.contextRunner.withPropertyValues("spring.session.jdbc.table-name=FOO_BAR",
+ "spring.session.jdbc.schema=classpath:org/springframework/boot/autoconfigure/session/custom-schema-h2.sql")
.run((context) -> {
JdbcIndexedSessionRepository repository = validateSessionRepository(context,
JdbcIndexedSessionRepository.class);
@@ -211,6 +218,7 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration
}
@Test
+ @WithResource(name = "db/changelog/db.changelog-master.yaml", content = "databaseChangeLog:")
void sessionRepositoryBeansDependOnLiquibase() {
this.contextRunner.withConfiguration(AutoConfigurations.of(LiquibaseAutoConfiguration.class))
.withPropertyValues("spring.session.jdbc.initialize-schema=never")
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/SslPropertiesBundleRegistrarTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/SslPropertiesBundleRegistrarTests.java
index dafabd8801..19df0b1f9a 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/SslPropertiesBundleRegistrarTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/SslPropertiesBundleRegistrarTests.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.
@@ -67,9 +67,9 @@ class SslPropertiesBundleRegistrarTests {
void shouldWatchJksBundles() {
JksSslBundleProperties jks = new JksSslBundleProperties();
jks.setReloadOnUpdate(true);
- jks.getKeystore().setLocation("classpath:test.jks");
+ jks.getKeystore().setLocation("classpath:org/springframework/boot/autoconfigure/ssl/test.jks");
jks.getKeystore().setPassword("secret");
- jks.getTruststore().setLocation("classpath:test.jks");
+ jks.getTruststore().setLocation("classpath:org/springframework/boot/autoconfigure/ssl/test.jks");
jks.getTruststore().setPassword("secret");
this.properties.getBundle().getJks().put("bundle1", jks);
this.registrar.registerBundles(this.registry);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java
index 6d17a0ef75..af84fb8f71 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.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.
@@ -43,6 +43,7 @@ import org.springframework.boot.test.context.runner.ReactiveWebApplicationContex
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.boot.testsupport.BuildOutput;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
@@ -70,6 +71,7 @@ class ThymeleafReactiveAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(ThymeleafAutoConfiguration.class));
@Test
+ @WithResource(name = "templates/template.html", content = "foo")
void createFromConfigClass() {
this.contextRunner.withPropertyValues("spring.thymeleaf.suffix:.html").run((context) -> {
TemplateEngine engine = context.getBean(TemplateEngine.class);
@@ -188,6 +190,7 @@ class ThymeleafReactiveAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/data-dialect.html", content = "")
void useDataDialect() {
this.contextRunner.run((context) -> {
ISpringWebFluxTemplateEngine engine = context.getBean(ISpringWebFluxTemplateEngine.class);
@@ -198,6 +201,8 @@ class ThymeleafReactiveAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/java8time-dialect.html",
+ content = "")
void useJava8TimeDialect() {
this.contextRunner.run((context) -> {
ISpringWebFluxTemplateEngine engine = context.getBean(ISpringWebFluxTemplateEngine.class);
@@ -208,6 +213,8 @@ class ThymeleafReactiveAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/security-dialect.html",
+ content = "\n")
void useSecurityDialect() {
this.contextRunner.run((context) -> {
ISpringWebFluxTemplateEngine engine = context.getBean(ISpringWebFluxTemplateEngine.class);
@@ -229,6 +236,7 @@ class ThymeleafReactiveAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/home.html", content = "Home")
void renderTemplate() {
this.contextRunner.run((context) -> {
ISpringWebFluxTemplateEngine engine = context.getBean(ISpringWebFluxTemplateEngine.class);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java
index 9f58eefb4a..47c5300119 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java
@@ -46,6 +46,7 @@ import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.boot.testsupport.BuildOutput;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;
import org.springframework.context.annotation.Bean;
@@ -89,6 +90,7 @@ class ThymeleafServletAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/template.html", content = "foo")
void createFromConfigClass() {
this.contextRunner.withPropertyValues("spring.thymeleaf.mode:HTML", "spring.thymeleaf.suffix:")
.run((context) -> {
@@ -184,6 +186,19 @@ class ThymeleafServletAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/view.html",
+ content = """
+
+
+ Content
+
+
+
+ foo
+
+
+
+ """)
void createLayoutFromConfigClass() {
this.contextRunner.run((context) -> {
ThymeleafView view = (ThymeleafView) context.getBean(ThymeleafViewResolver.class)
@@ -200,6 +215,7 @@ class ThymeleafServletAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/data-dialect.html", content = "")
void useDataDialect() {
this.contextRunner.run((context) -> {
TemplateEngine engine = context.getBean(TemplateEngine.class);
@@ -210,6 +226,8 @@ class ThymeleafServletAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/java8time-dialect.html",
+ content = "")
void useJava8TimeDialect() {
this.contextRunner.run((context) -> {
TemplateEngine engine = context.getBean(TemplateEngine.class);
@@ -220,6 +238,8 @@ class ThymeleafServletAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/security-dialect.html",
+ content = "\n")
void useSecurityDialect() {
this.contextRunner.run((context) -> {
TemplateEngine engine = context.getBean(TemplateEngine.class);
@@ -246,6 +266,7 @@ class ThymeleafServletAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/home.html", content = "Home")
void renderTemplate() {
this.contextRunner.run((context) -> {
TemplateEngine engine = context.getBean(TemplateEngine.class);
@@ -256,6 +277,8 @@ class ThymeleafServletAutoConfigurationTests {
}
@Test
+ @WithResource(name = "templates/message.html",
+ content = "Message: Hello")
void renderNonWebAppTemplate() {
new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(ThymeleafAutoConfiguration.class))
.run((context) -> {
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProviderTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProviderTests.java
index 7861c74fc1..406dc9b104 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProviderTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProviderTests.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.
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.thymeleaf;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.mock.env.MockEnvironment;
@@ -39,6 +40,7 @@ class ThymeleafTemplateAvailabilityProviderTests {
private final MockEnvironment environment = new MockEnvironment();
@Test
+ @WithResource(name = "templates/home.html")
void availabilityOfTemplateInDefaultLocation() {
assertThat(this.provider.isTemplateAvailable("home", this.environment, getClass().getClassLoader(),
this.resourceLoader))
@@ -53,6 +55,7 @@ class ThymeleafTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "custom-templates/custom.html")
void availabilityOfTemplateWithCustomPrefix() {
this.environment.setProperty("spring.thymeleaf.prefix", "classpath:/custom-templates/");
assertThat(this.provider.isTemplateAvailable("custom", this.environment, getClass().getClassLoader(),
@@ -61,6 +64,7 @@ class ThymeleafTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "templates/suffixed.thymeleaf")
void availabilityOfTemplateWithCustomSuffix() {
this.environment.setProperty("spring.thymeleaf.suffix", ".thymeleaf");
assertThat(this.provider.isTemplateAvailable("suffixed", this.environment, getClass().getClassLoader(),
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebResourcesRuntimeHintsTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebResourcesRuntimeHintsTests.java
index 9c4f337bab..29cb54d08c 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebResourcesRuntimeHintsTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebResourcesRuntimeHintsTests.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.
@@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.web;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
@@ -27,6 +26,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.ResourcePatternHint;
import org.springframework.aot.hint.ResourcePatternHints;
import org.springframework.aot.hint.RuntimeHints;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
*/
+@WithResource(name = "web/custom-resource.txt")
class WebResourcesRuntimeHintsTests {
@Test
@@ -71,12 +72,12 @@ class WebResourcesRuntimeHintsTests {
};
}
- private static class TestClassLoader extends URLClassLoader {
+ private static class TestClassLoader extends ClassLoader {
private final List availableResources;
TestClassLoader(List availableResources) {
- super(new URL[0], TestClassLoader.class.getClassLoader());
+ super(Thread.currentThread().getContextClassLoader());
this.availableResources = availableResources;
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java
index 09f3c40478..2d09358f02 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.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.
@@ -57,6 +57,7 @@ import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfigurat
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.codec.CodecCustomizer;
import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
import org.springframework.boot.web.reactive.filter.OrderedHiddenHttpMethodFilter;
@@ -530,6 +531,7 @@ class WebFluxAutoConfigurationTests {
}
@Test
+ @WithResource(name = "welcome-page/index.html", content = "welcome-page-static")
void welcomePageHandlerMapping() {
this.contextRunner.withPropertyValues("spring.web.resources.static-locations=classpath:/welcome-page/")
.run((context) -> {
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WelcomePageRouterFunctionFactoryTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WelcomePageRouterFunctionFactoryTests.java
index 7a464da43e..996956eede 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WelcomePageRouterFunctionFactoryTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WelcomePageRouterFunctionFactoryTests.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.
@@ -27,6 +27,7 @@ import reactor.core.publisher.Mono;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
@@ -46,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Brian Clozel
*/
+@WithResource(name = "welcome-page/index.html", content = "welcome-page-static")
class WelcomePageRouterFunctionFactoryTests {
private StaticApplicationContext applicationContext;
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java
index 838055707b..01c1481f91 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.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.
@@ -22,9 +22,12 @@ import java.util.LinkedHashMap;
import java.util.Map;
import jakarta.validation.Valid;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -39,6 +42,7 @@ import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplic
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.error.ErrorAttributeOptions.Include;
import org.springframework.boot.web.reactive.error.DefaultErrorAttributes;
@@ -88,6 +92,12 @@ class DefaultErrorWebExceptionHandlerIntegrationTests {
.withPropertyValues("spring.main.web-application-type=reactive", "server.port=0")
.withUserConfiguration(Application.class);
+ @BeforeEach
+ @AfterEach
+ void clearReactorSchedulers() {
+ Schedulers.shutdownNow();
+ }
+
@Test
void jsonError(CapturedOutput output) {
this.contextRunner.run((context) -> {
@@ -141,7 +151,18 @@ class DefaultErrorWebExceptionHandlerIntegrationTests {
}
@Test
+ @WithResource(name = "templates/error/error.mustache", content = """
+
+
+
+ - status: {{status}}
+ - message: {{message}}
+
+
+
+ """)
void htmlError() {
+ Schedulers.shutdownNow();
this.contextRunner.withPropertyValues("server.error.include-message=always").run((context) -> {
WebTestClient client = getWebClient(context);
String body = client.get()
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerTests.java
index 0d36831394..51970676f0 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerTests.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.
@@ -24,6 +24,7 @@ import reactor.core.publisher.Mono;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext;
import org.springframework.boot.web.reactive.error.ErrorAttributes;
import org.springframework.context.ApplicationContext;
@@ -52,6 +53,16 @@ import static org.mockito.Mockito.mock;
class DefaultErrorWebExceptionHandlerTests {
@Test
+ @WithResource(name = "templates/error/error.mustache", content = """
+
+
+
+ - status: {{status}}
+ - message: {{message}}
+
+
+
+ """)
void nonStandardErrorStatusCodeShouldNotFail() {
ErrorAttributes errorAttributes = mock(ErrorAttributes.class);
given(errorAttributes.getErrorAttributes(any(), any())).willReturn(Collections.singletonMap("status", 498));
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/AbstractClientHttpConnectorFactoryTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/AbstractClientHttpConnectorFactoryTests.java
index 5210a61028..44f573b737 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/AbstractClientHttpConnectorFactoryTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/AbstractClientHttpConnectorFactoryTests.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.
@@ -22,6 +22,7 @@ import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslBundleKey;
import org.springframework.boot.ssl.jks.JksSslStoreBundle;
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
+import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.server.Ssl.ClientAuth;
@@ -62,6 +63,7 @@ abstract class AbstractClientHttpConnectorFactoryTests {
}
@Test
+ @WithPackageResources("test.jks")
void secureConnection() throws Exception {
TomcatServletWebServerFactory webServerFactory = new TomcatServletWebServerFactory(0);
Ssl ssl = new Ssl();
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorFactoryConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorFactoryConfigurationTests.java
index 5d7fd0fab6..78b02ef97d 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorFactoryConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorFactoryConfigurationTests.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.ssl.jks.JksSslStoreBundle;
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.reactive.HttpComponentsClientHttpConnector;
@@ -42,6 +43,7 @@ import static org.mockito.Mockito.spy;
class ClientHttpConnectorFactoryConfigurationTests {
@Test
+ @WithPackageResources("test.jks")
void shouldApplyHttpClientMapper() {
JksSslStoreDetails storeDetails = JksSslStoreDetails.forLocation("classpath:test.jks");
JksSslStoreBundle stores = new JksSslStoreBundle(storeDetails, storeDetails);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/JspTemplateAvailabilityProviderTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/JspTemplateAvailabilityProviderTests.java
index 01ea06f34d..ccb3b7bca5 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/JspTemplateAvailabilityProviderTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/JspTemplateAvailabilityProviderTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2019 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.
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.web.servlet;
import org.junit.jupiter.api.Test;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.mock.env.MockEnvironment;
@@ -43,15 +44,16 @@ class JspTemplateAvailabilityProviderTests {
}
@Test
+ @WithResource(name = "custom-templates/custom.jsp")
void availabilityOfTemplateWithCustomPrefix() {
this.environment.setProperty("spring.mvc.view.prefix", "classpath:/custom-templates/");
assertThat(isTemplateAvailable("custom.jsp")).isTrue();
}
@Test
+ @WithResource(name = "suffixed.java-server-pages")
void availabilityOfTemplateWithCustomSuffix() {
- this.environment.setProperty("spring.mvc.view.prefix", "classpath:/custom-templates/");
- this.environment.setProperty("spring.mvc.view.suffix", ".jsp");
+ this.environment.setProperty("spring.mvc.view.suffix", ".java-server-pages");
assertThat(isTemplateAvailable("suffixed")).isTrue();
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java
index 474c049e35..52d920e34c 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.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.
@@ -57,6 +57,7 @@ import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguratio
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
@@ -678,6 +679,7 @@ class WebMvcAutoConfigurationTests {
}
@Test
+ @WithResource(name = "welcome-page/index.html", content = "welcome-page-static")
void welcomePageHandlerMappingIsAutoConfigured() {
this.contextRunner.withPropertyValues("spring.web.resources.static-locations:classpath:/welcome-page/")
.run((context) -> {
@@ -688,6 +690,7 @@ class WebMvcAutoConfigurationTests {
}
@Test
+ @WithResource(name = "welcome-page/index.html", content = "welcome-page-static")
void welcomePageHandlerIncludesCorsConfiguration() {
this.contextRunner.withPropertyValues("spring.web.resources.static-locations:classpath:/welcome-page/")
.withUserConfiguration(CorsConfigurer.class)
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageHandlerMappingTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageHandlerMappingTests.java
index 52397e4e4e..8e9be182b5 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageHandlerMappingTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageHandlerMappingTests.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.
@@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.web.servlet;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Map;
@@ -39,7 +40,7 @@ import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@@ -173,7 +174,7 @@ class WelcomePageHandlerMappingTests {
@Bean
Resource staticIndexPage() {
- return new FileSystemResource("src/test/resources/welcome-page/index.html");
+ return new ByteArrayResource("welcome-page-static".getBytes(StandardCharsets.UTF_8));
}
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageIntegrationTests.java
index 14fe385838..a34b15f8be 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageIntegrationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WelcomePageIntegrationTests.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,9 +41,10 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Madhura Bhave
*/
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
- properties = { "spring.web.resources.chain.strategy.content.enabled=true",
- "spring.thymeleaf.prefix=classpath:/templates/thymeleaf/" })
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
+ "spring.web.resources.chain.strategy.content.enabled=true",
+ "spring.thymeleaf.prefix=classpath:/org/springframework/boot/autoconfigure/web/servlet/",
+ "spring.web.resources.static-locations=classpath:/org/springframework/boot/autoconfigure/web/servlet/static" })
class WelcomePageIntegrationTests {
@LocalServerPort
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.java
index 909e590870..5baf1f67c3 100755
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.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.
@@ -46,6 +46,7 @@ import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoC
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.error.ErrorAttributeOptions.Include;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
@@ -326,6 +327,7 @@ class BasicErrorControllerIntegrationTests {
}
@Test
+ @WithResource(name = "templates/error/507.ftlh", content = "We are out of storage")
void testConventionTemplateMapping() {
load();
RequestEntity> request = RequestEntity.get(URI.create(createUrl("/noStorage")))
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java
index 89aed095a3..d00d451819 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.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.
@@ -19,10 +19,13 @@ package org.springframework.boot.autoconfigure.webservices;
import java.util.Collection;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
+import org.springframework.boot.testsupport.classpath.resources.WithResource;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition;
@@ -87,17 +90,67 @@ class WebServicesAutoConfigurationTests {
.containsEntry("key2", "value2"));
}
- @Test
- void withWsdlBeans() {
- this.contextRunner.withPropertyValues("spring.webservices.wsdl-locations=classpath:/wsdl").run((context) -> {
- assertThat(context.getBeansOfType(SimpleWsdl11Definition.class)).containsOnlyKeys("service");
- assertThat(context.getBeansOfType(SimpleXsdSchema.class)).containsOnlyKeys("types");
- });
- }
-
- @Test
- void withWsdlBeansAsList() {
- this.contextRunner.withPropertyValues("spring.webservices.wsdl-locations[0]=classpath:/wsdl").run((context) -> {
+ @ParameterizedTest
+ @WithResource(name = "wsdl/service.wsdl", content = """
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ """)
+ @WithResource(name = "wsdl/types.xsd", content = """
+
+
+
+
+
+ """)
+ @ValueSource(strings = { "spring.webservices.wsdl-locations", "spring.webservices.wsdl-locations[0]" })
+ void withWsdlBeans(String propertyName) {
+ this.contextRunner.withPropertyValues(propertyName + "=classpath:/wsdl").run((context) -> {
assertThat(context.getBeansOfType(SimpleWsdl11Definition.class)).containsOnlyKeys("service");
assertThat(context.getBeansOfType(SimpleXsdSchema.class)).containsOnlyKeys("types");
});
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/AutoConfigurationMetadataLoaderTests.properties b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/AutoConfigurationMetadataLoaderTests.properties
deleted file mode 100644
index 2dc12708ce..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/AutoConfigurationMetadataLoaderTests.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-test=
-test.string=abc
-test.int=123
-test.set=a,b,b,c
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/build-info.properties b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/build-info.properties
deleted file mode 100644
index c0ad96bbba..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/build-info.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-build.group=com.example
-build.artifact=demo
-build.name=Demo Project
-build.version=0.0.1-SNAPSHOT
-build.time=2016-03-04T14:16:05.000Z
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/mappings/non-annotated.xml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/mappings/non-annotated.xml
deleted file mode 100644
index 3b33b0dff3..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/mappings/non-annotated.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/persistence.xml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index 439d601d8f..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- org.springframework.boot.autoconfigure.orm.jpa.test.City
- true
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring.integration.properties b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring.integration.properties
deleted file mode 100644
index 2b2aca228b..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring.integration.properties
+++ /dev/null
@@ -1 +0,0 @@
-spring.integration.endpoints.noAutoStartup=testService*
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.imports b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.imports
deleted file mode 100644
index 3d625bcf41..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.imports
+++ /dev/null
@@ -1,3 +0,0 @@
-org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$AfterDeprecatedAutoConfiguration
-org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$ReplacementAutoConfiguration
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.replacements b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.replacements
deleted file mode 100644
index b63c6b88df..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.replacements
+++ /dev/null
@@ -1,2 +0,0 @@
-org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$DeprecatedAutoConfiguration=\
-org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$ReplacementAutoConfiguration
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationReplacementsTests$TestAutoConfigurationReplacements.replacements b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationReplacementsTests$TestAutoConfigurationReplacements.replacements
deleted file mode 100644
index 9924a4a0c1..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationReplacementsTests$TestAutoConfigurationReplacements.replacements
+++ /dev/null
@@ -1,2 +0,0 @@
-com.example.A1=com.example.A2
-com.example.B1=com.example.B2
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFile.imports b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFile.imports
deleted file mode 100644
index 951bbd8f24..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFile.imports
+++ /dev/null
@@ -1,2 +0,0 @@
-org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$ImportedAutoConfiguration
-org.springframework.boot.autoconfigure.missing.MissingAutoConfiguration
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFileIgnoresMissingOptionalClasses.imports b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFileIgnoresMissingOptionalClasses.imports
deleted file mode 100644
index c76445a839..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFileIgnoresMissingOptionalClasses.imports
+++ /dev/null
@@ -1,3 +0,0 @@
-optional:org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$ImportedAutoConfiguration
-optional:org.springframework.boot.autoconfigure.missing.MissingAutoConfiguration
-org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$AnotherImportedAutoConfiguration
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/application.properties b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/application.properties
deleted file mode 100644
index a8d63792d0..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/application.properties
+++ /dev/null
@@ -1 +0,0 @@
-foo: bucket
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/cache/ehcache-override.xml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/cache/ehcache-override.xml
deleted file mode 100644
index e902bdeba1..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/cache/ehcache-override.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/city.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/city.sql
deleted file mode 100644
index eb08623b4c..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/city.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-autoconfigure/src/test/resources/custom-schema-sample.ldif b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-schema-sample.ldif
deleted file mode 100644
index 91159a86b0..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-schema-sample.ldif
+++ /dev/null
@@ -1,7 +0,0 @@
-dn: dc=spring,dc=org
-objectclass: top
-objectclass: domain
-objectclass: extensibleObject
-objectClass: exampleAuxiliaryClass
-dc: spring
-exampleAttributeName: exampleAttributeName
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-schema.ldif b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-schema.ldif
deleted file mode 100644
index ca6a82170d..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-schema.ldif
+++ /dev/null
@@ -1,17 +0,0 @@
-dn: cn=schema
-attributeTypes: ( 1.3.6.1.4.1.32473.1.1.1
- NAME 'exampleAttributeName'
- DESC 'An example attribute type definition'
- EQUALITY caseIgnoreMatch
- ORDERING caseIgnoreOrderingMatch
- SUBSTR caseIgnoreSubstringsMatch
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
- SINGLE-VALUE
- X-ORIGIN 'Managing Schema Document' )
-objectClasses: ( 1.3.6.1.4.1.32473.1.2.2
- NAME 'exampleAuxiliaryClass'
- DESC 'An example auxiliary object class definition'
- SUP top
- AUXILIARY
- MAY exampleAttributeName
- X-ORIGIN 'Managing Schema Document' )
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.ftlh b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.ftlh
deleted file mode 100644
index 0d82d79c85..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.ftlh
+++ /dev/null
@@ -1 +0,0 @@
-custom
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.html
deleted file mode 100644
index 8b13789179..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.tpl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.tpl
deleted file mode 100644
index cd07d3d3c6..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.tpl
+++ /dev/null
@@ -1 +0,0 @@
-yield "custom"
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.vm b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.vm
deleted file mode 100644
index 0d82d79c85..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.vm
+++ /dev/null
@@ -1 +0,0 @@
-custom
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/suffixed.jsp b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/suffixed.jsp
deleted file mode 100755
index e69de29bb2..0000000000
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/data-city-schema.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/data-city-schema.sql
deleted file mode 100644
index b2a4112add..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/data-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-autoconfigure/src/test/resources/data.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/data.sql
deleted file mode 100644
index 487614d440..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/data.sql
+++ /dev/null
@@ -1 +0,0 @@
-INSERT INTO BAR VALUES (1, 'Andy');
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-city.yaml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-city.yaml
deleted file mode 100644
index c46dc1dacb..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-city.yaml
+++ /dev/null
@@ -1,38 +0,0 @@
-databaseChangeLog:
- - changeSet:
- id: 1
- author: dsyer
- changes:
- - createSequence:
- sequenceName: city_seq
- incrementBy: 50
- - createTable:
- tableName: city
- columns:
- - column:
- name: id
- type: bigint
- autoIncrement: true
- constraints:
- primaryKey: true
- nullable: false
- - column:
- name: name
- type: varchar(50)
- constraints:
- nullable: false
- - column:
- name: state
- type: varchar(50)
- constraints:
- nullable: false
- - column:
- name: country
- type: varchar(50)
- constraints:
- nullable: false
- - column:
- name: map
- type: varchar(50)
- constraints:
- nullable: true
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-master.yaml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-master.yaml
deleted file mode 100644
index 134b17b543..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/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-autoconfigure/src/test/resources/db/changelog/db.changelog-override.json b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.json
deleted file mode 100644
index acaa0e2118..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "databaseChangeLog": [
- {
- "changeSet": {
- "author": "awilkinson",
- "id": "1",
- "changes": [
- {
- "createTable": {
- "tableName": "customer",
- "columns": [
- {
- "column": {
- "name": "id",
- "type": "int",
- "autoIncrement": true,
- "constraints": {
- "nullable": false,
- "primaryKey": true
- }
- }
- },
- {
- "column": {
- "name": "name",
- "type": "varchar(50)",
- "constraints": {
- "nullable": false
- }
- }
- }
- ]
- }
- }
- ]
- }
- }
- ]
-}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.sql
deleted file mode 100644
index cd68b45850..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.sql
+++ /dev/null
@@ -1,8 +0,0 @@
---liquibase formatted sql
-
---changeset author:awilkinson
-
-CREATE TABLE customer (
- id int AUTO_INCREMENT NOT NULL PRIMARY KEY,
- name varchar(50) NOT NULL
-);
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.xml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.xml
deleted file mode 100644
index 77c318e582..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/changelog/db.changelog-override.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/city/V1__init.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/city/V1__init.sql
deleted file mode 100644
index 571f6fa46e..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/city/V1__init.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE SEQUENCE city_seq INCREMENT BY 50;
-
-CREATE TABLE CITY (
- id BIGINT GENERATED BY DEFAULT AS IDENTITY,
- name VARCHAR(30),
- state VARCHAR(30),
- country VARCHAR(30),
- map VARCHAR(30)
-);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/migration/V1__init.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/migration/V1__init.sql
deleted file mode 100644
index 867c7c24f5..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/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-autoconfigure/src/test/resources/db/non-annotated-data.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/non-annotated-data.sql
deleted file mode 100644
index b741d23ccf..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/non-annotated-data.sql
+++ /dev/null
@@ -1 +0,0 @@
-INSERT INTO NON_ANNOTATED (id, item) values (2000, 'Test');
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/vendors/h2/V1__init.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/vendors/h2/V1__init.sql
deleted file mode 100644
index 867c7c24f5..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/db/vendors/h2/V1__init.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS TEST;
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ehcache.xml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ehcache.xml
deleted file mode 100644
index f3653ed789..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ehcache.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ehcache3.xml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ehcache3.xml
deleted file mode 100644
index 5f048f2186..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ehcache3.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
- 200
-
-
-
-
- 600
-
-
-
-
-
-
- 400
-
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/graphql/schema.graphqls b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/graphql/schema.graphqls
deleted file mode 100644
index dc80e899dd..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/graphql/schema.graphqls
+++ /dev/null
@@ -1,9 +0,0 @@
-type Query {
- greeting(name: String! = "Spring"): String!
- bookById(id: ID): Book
- books: BookConnection
-}
-
-type Subscription {
- booksOnSale(minPages: Int) : Book!
-}
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/graphql/types/book.graphqls b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/graphql/types/book.graphqls
deleted file mode 100644
index 16217d759b..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/graphql/types/book.graphqls
+++ /dev/null
@@ -1,6 +0,0 @@
-type Book {
- id: ID
- name: String
- pageCount: Int
- author: String
-}
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/graphql/types/person.custom b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/graphql/types/person.custom
deleted file mode 100644
index 8cff728ad1..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/graphql/types/person.custom
+++ /dev/null
@@ -1,4 +0,0 @@
-type Person {
- id: ID
- name: String
-}
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.xml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.xml
deleted file mode 100644
index cd69939118..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
- default-instance
-
-
-
-
-
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.yaml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.yaml
deleted file mode 100644
index 686d75638a..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-hazelcast:
- network:
- join:
- auto-detection:
- enabled: false
- multicast:
- enabled: false
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.yml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.yml
deleted file mode 100644
index 686d75638a..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/hazelcast.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-hazelcast:
- network:
- join:
- auto-detection:
- enabled: false
- multicast:
- enabled: false
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/infinispan.xml b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/infinispan.xml
deleted file mode 100644
index 55f7b2ec2d..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/infinispan.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ksLoc b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ksLoc
deleted file mode 100644
index 696f2109e6..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ksLoc
+++ /dev/null
@@ -1 +0,0 @@
-Test file for Kafka.
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ksLocP b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ksLocP
deleted file mode 100644
index 696f2109e6..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/ksLocP
+++ /dev/null
@@ -1 +0,0 @@
-Test file for Kafka.
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/logging.properties b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/logging.properties
deleted file mode 100644
index b69c75b038..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/logging.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-# Enable this by setting -Djava.util.logging.config.file=src/test/resources/logging.properties
-handlers = java.util.logging.ConsoleHandler
-.level = INFO
-java.util.logging.ConsoleHandler.level = FINE
-org.springframework.security.level = ALL
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/batch/custom-schema.sql
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/batch/custom-schema.sql
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/rsocket/test.jks b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/test.jks
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/rsocket/test.jks
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/cassandra/test.jks
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test.jks b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/couchbase/test.jks
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/test.jks
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/couchbase/test.jks
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/data/redis/test.jks b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/data/redis/test.jks
new file mode 100644
index 0000000000..0fc3e802f7
Binary files /dev/null and b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/data/redis/test.jks differ
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/elasticsearch/test.jks b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/elasticsearch/test.jks
new file mode 100644
index 0000000000..0fc3e802f7
Binary files /dev/null and b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/elasticsearch/test.jks differ
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mail/test.jks b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mail/test.jks
new file mode 100644
index 0000000000..0fc3e802f7
Binary files /dev/null and b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mail/test.jks differ
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mongo/test.jks b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mongo/test.jks
new file mode 100644
index 0000000000..0fc3e802f7
Binary files /dev/null and b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mongo/test.jks differ
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/content.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/content.html
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/content.html
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/content.html
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/foo.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/foo.html
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/foo.html
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/foo.html
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/foo_de.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/foo_de.html
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/foo_de.html
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/foo_de.html
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/home.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/home.html
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/home.html
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/home.html
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/layout.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/layout.html
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/layout.html
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/layout.html
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/partial.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/partial.html
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/mustache-templates/partial.html
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/mustache/partial.html
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/rsocket/test.jks b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/rsocket/test.jks
new file mode 100644
index 0000000000..0fc3e802f7
Binary files /dev/null and b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/rsocket/test.jks differ
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/saml/certificate-location b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/security/saml2/certificate-location
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/saml/certificate-location
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/security/saml2/certificate-location
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/saml/idp-metadata b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/security/saml2/idp-metadata
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/saml/idp-metadata
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/security/saml2/idp-metadata
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/saml/idp-metadata-with-multiple-providers b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/security/saml2/idp-metadata-with-multiple-providers
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/saml/idp-metadata-with-multiple-providers
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/security/saml2/idp-metadata-with-multiple-providers
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/saml/private-key-location b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/security/saml2/private-key-location
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/saml/private-key-location
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/security/saml2/private-key-location
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/session/custom-schema-h2.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/session/custom-schema-h2.sql
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/session/custom-schema-h2.sql
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/session/custom-schema-h2.sql
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/ssl/test.jks b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/ssl/test.jks
new file mode 100644
index 0000000000..0fc3e802f7
Binary files /dev/null and b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/ssl/test.jks differ
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/web/reactive/function/client/test.jks b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/web/reactive/function/client/test.jks
new file mode 100644
index 0000000000..0fc3e802f7
Binary files /dev/null and b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/web/reactive/function/client/test.jks differ
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/thymeleaf/index.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/web/servlet/index.html
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/thymeleaf/index.html
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/web/servlet/index.html
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.jsp b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/web/servlet/static/custom.css
old mode 100755
new mode 100644
similarity index 100%
rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.jsp
rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/web/servlet/static/custom.css
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/public-key-location b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/public-key-location
deleted file mode 100644
index c6bbd08e3a..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/public-key-location
+++ /dev/null
@@ -1,6 +0,0 @@
------BEGIN PUBLIC KEY-----
-MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdlatRjRjogo3WojgGHFHYLugd
-UWAY9iR3fy4arWNA1KoS8kVw33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQs
-HUfQrSDv+MuSUMAe8jzKE4qW+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5D
-o2kQ+X5xK9cipRgEKwIDAQAB
------END PUBLIC KEY-----
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/public/custom.css b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/public/custom.css
deleted file mode 100644
index 139597f9cb..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/public/custom.css
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema-multi-basedn.ldif b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema-multi-basedn.ldif
deleted file mode 100644
index 42380080c9..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema-multi-basedn.ldif
+++ /dev/null
@@ -1,114 +0,0 @@
-dn: dc=spring,dc=org
-objectclass: top
-objectclass: domain
-objectclass: extensibleObject
-dc: spring
-
-dn: ou=groups,dc=spring,dc=org
-objectclass: top
-objectclass: organizationalUnit
-ou: groups
-
-dn: cn=ROLE_USER,ou=groups,dc=spring,dc=org
-objectclass: top
-objectclass: groupOfUniqueNames
-cn: ROLE_USER
-uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
-uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
-uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
-uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=spring,dc=org
-
-dn: cn=ROLE_ADMIN,ou=groups,dc=spring,dc=org
-objectclass: top
-objectclass: groupOfUniqueNames
-cn: ROLE_ADMIN
-uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
-
-dn: c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: country
-c: Sweden
-description: The country of Sweden
-
-dn: ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: organizationalUnit
-ou: company1
-description: First company in Sweden
-
-dn: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: some.person
-userPassword: password
-cn: Some Person
-sn: Person
-description: Sweden, Company1, Some Person
-telephoneNumber: +46 555-123456
-
-dn: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: some.person2
-userPassword: password
-cn: Some Person2
-sn: Person2
-description: Sweden, Company1, Some Person2
-telephoneNumber: +46 555-654321
-
-dn: cn=Some Person3,ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: some.person3
-userPassword: password
-cn: Some Person3
-sn: Person3
-description: Sweden, Company1, Some Person3
-telephoneNumber: +46 555-123654
-
-dn: cn=Some Person4,ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: some.person4
-userPassword: password
-cn: Some Person
-sn: Person
-description: Sweden, Company1, Some Person
-telephoneNumber: +46 555-456321
-
-dn: dc=vmware,dc=com
-objectclass: top
-objectclass: domain
-objectclass: extensibleObject
-dc: vmware
-
-dn: ou=groups,dc=vmware,dc=com
-objectclass: top
-objectclass: organizationalUnit
-ou: groups
-
-dn: c=Sweden,dc=vmware,dc=com
-objectclass: top
-objectclass: country
-c: Sweden
-description:The country of Sweden
-
-dn: cn=Some Random Person,c=Sweden,dc=vmware,dc=com
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: some.random.person
-userPassword: password
-cn: Some Random Person
-sn: Person
-description: Sweden, VMware, Some Random Person
-telephoneNumber: +46 555-123456
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.ldif b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.ldif
deleted file mode 100644
index df76aace51..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.ldif
+++ /dev/null
@@ -1,85 +0,0 @@
-dn: dc=spring,dc=org
-objectclass: top
-objectclass: domain
-objectclass: extensibleObject
-dc: spring
-
-dn: ou=groups,dc=spring,dc=org
-objectclass: top
-objectclass: organizationalUnit
-ou: groups
-
-dn: cn=ROLE_USER,ou=groups,dc=spring,dc=org
-objectclass: top
-objectclass: groupOfUniqueNames
-cn: ROLE_USER
-uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
-uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
-uniqueMember: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
-uniqueMember: cn=Some Person3,ou=company1,c=Sweden,dc=spring,dc=org
-
-dn: cn=ROLE_ADMIN,ou=groups,dc=spring,dc=org
-objectclass: top
-objectclass: groupOfUniqueNames
-cn: ROLE_ADMIN
-uniqueMember: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
-
-dn: c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: country
-c: Sweden
-description: The country of Sweden
-
-dn: ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: organizationalUnit
-ou: company1
-description: First company in Sweden
-
-dn: cn=Some Person,ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: some.person
-userPassword: password
-cn: Some Person
-sn: Person
-description: Sweden, Company1, Some Person
-telephoneNumber: +46 555-123456
-
-dn: cn=Some Person2,ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: some.person2
-userPassword: password
-cn: Some Person2
-sn: Person2
-description: Sweden, Company1, Some Person2
-telephoneNumber: +46 555-654321
-
-dn: cn=Some Person3,ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: some.person3
-userPassword: password
-cn: Some Person3
-sn: Person3
-description: Sweden, Company1, Some Person3
-telephoneNumber: +46 555-123654
-
-dn: cn=Some Person4,ou=company1,c=Sweden,dc=spring,dc=org
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: some.person4
-userPassword: password
-cn: Some Person
-sn: Person
-description: Sweden, Company1, Some Person
-telephoneNumber: +46 555-456321
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.sql
deleted file mode 100644
index 7f7a6f01a5..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-CREATE TABLE BAR (
- id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
- name VARCHAR(30)
-);
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/data-dialect.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/data-dialect.html
deleted file mode 100644
index f1a6716764..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/data-dialect.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/507.ftlh b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/507.ftlh
deleted file mode 100644
index a562b8fe9c..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/507.ftlh
+++ /dev/null
@@ -1 +0,0 @@
-We are out of storage
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/error.mustache b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/error.mustache
deleted file mode 100644
index c29c825d82..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/error.mustache
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- - status: {{status}}
- - message: {{message}}
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.ftlh b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.ftlh
deleted file mode 100644
index 5e72f75cb4..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.ftlh
+++ /dev/null
@@ -1 +0,0 @@
-home
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.html
deleted file mode 100644
index d8a1185cc0..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.html
+++ /dev/null
@@ -1 +0,0 @@
-Home
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.tpl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.tpl
deleted file mode 100644
index eb07ff6f93..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.tpl
+++ /dev/null
@@ -1 +0,0 @@
-yield "home"
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.vm b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.vm
deleted file mode 100644
index 5e72f75cb4..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.vm
+++ /dev/null
@@ -1 +0,0 @@
-home
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/included.tpl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/included.tpl
deleted file mode 100644
index a1bbaa02e9..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/included.tpl
+++ /dev/null
@@ -1 +0,0 @@
-yield "here"
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/included_fr.tpl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/included_fr.tpl
deleted file mode 100644
index 035e2e9575..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/included_fr.tpl
+++ /dev/null
@@ -1 +0,0 @@
-yield "voila"
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/includes.tpl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/includes.tpl
deleted file mode 100644
index 9ea4039123..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/includes.tpl
+++ /dev/null
@@ -1,2 +0,0 @@
-yield "include"
-include template: "included.tpl"
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/java8time-dialect.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/java8time-dialect.html
deleted file mode 100644
index 2c2bce877b..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/java8time-dialect.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/layout.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/layout.html
deleted file mode 100644
index 57add3758e..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/layout.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- Layout
-
-
-
-
Layout
-
- Fake content
-
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.ftlh b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.ftlh
deleted file mode 100644
index b3992342b2..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.ftlh
+++ /dev/null
@@ -1 +0,0 @@
-Message: ${greeting}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.html
deleted file mode 100644
index ba236128ec..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.html
+++ /dev/null
@@ -1 +0,0 @@
-Message: Hello
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.tpl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.tpl
deleted file mode 100644
index 6a9df3b50d..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.tpl
+++ /dev/null
@@ -1 +0,0 @@
-yield "Message: ${greeting}"
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.vm b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.vm
deleted file mode 100644
index b3992342b2..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.vm
+++ /dev/null
@@ -1 +0,0 @@
-Message: ${greeting}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.ftlh b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.ftlh
deleted file mode 100644
index 278ed40333..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.ftlh
+++ /dev/null
@@ -1 +0,0 @@
-prefixed
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.tpl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.tpl
deleted file mode 100644
index 05426ef699..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.tpl
+++ /dev/null
@@ -1 +0,0 @@
-yield "prefixed"
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.vm b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.vm
deleted file mode 100644
index 278ed40333..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.vm
+++ /dev/null
@@ -1 +0,0 @@
-prefixed
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/security-dialect.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/security-dialect.html
deleted file mode 100644
index a22a79e607..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/security-dialect.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/suffixed.freemarker b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/suffixed.freemarker
deleted file mode 100644
index cfe8d439ab..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/suffixed.freemarker
+++ /dev/null
@@ -1 +0,0 @@
-suffixed
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/suffixed.groovytemplate b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/suffixed.groovytemplate
deleted file mode 100644
index 3539f6d6f4..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/suffixed.groovytemplate
+++ /dev/null
@@ -1,3 +0,0 @@
-yield """
-suffixed
-"""
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/suffixed.thymeleaf b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/suffixed.thymeleaf
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/template.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/template.html
deleted file mode 100644
index 123f6966f7..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/template.html
+++ /dev/null
@@ -1 +0,0 @@
-foo
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/view.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/view.html
deleted file mode 100644
index 4ff0e13352..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/view.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- Content
-
-
-
- foo
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/common-messages.properties b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/common-messages.properties
deleted file mode 100644
index 432ea47945..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/common-messages.properties
+++ /dev/null
@@ -1 +0,0 @@
-hello=world
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/messages.properties b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/messages.properties
deleted file mode 100644
index 74d0a43fcc..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/messages.properties
+++ /dev/null
@@ -1 +0,0 @@
-foo=bar
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/messages2.properties b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/messages2.properties
deleted file mode 100644
index 46858857b9..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/messages2.properties
+++ /dev/null
@@ -1 +0,0 @@
-foo-foo=bar-bar
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/swedish.properties b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/swedish.properties
deleted file mode 100644
index 9a876aade9..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/test/swedish.properties
+++ /dev/null
@@ -1 +0,0 @@
-foo=Some text with some swedish öäå!
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/tsLoc b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/tsLoc
deleted file mode 100644
index 696f2109e6..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/tsLoc
+++ /dev/null
@@ -1 +0,0 @@
-Test file for Kafka.
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/tsLocP b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/tsLocP
deleted file mode 100644
index 696f2109e6..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/tsLocP
+++ /dev/null
@@ -1 +0,0 @@
-Test file for Kafka.
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/web/custom-resource.txt b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/web/custom-resource.txt
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/welcome-page/index.html b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/welcome-page/index.html
deleted file mode 100644
index 10babc6511..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/welcome-page/index.html
+++ /dev/null
@@ -1 +0,0 @@
-welcome-page-static
\ No newline at end of file
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/wsdl/service.wsdl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/wsdl/service.wsdl
deleted file mode 100644
index ec828428ac..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/wsdl/service.wsdl
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/wsdl/types.xsd b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/wsdl/types.xsd
deleted file mode 100644
index dc559d26b7..0000000000
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/wsdl/types.xsd
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/FilteredClassLoader.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/FilteredClassLoader.java
index 39d498e642..e92455173a 100644
--- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/FilteredClassLoader.java
+++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/FilteredClassLoader.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2022 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.
@@ -53,6 +53,16 @@ public class FilteredClassLoader extends URLClassLoader implements SmartClassLoa
this(Collections.singleton(ClassFilter.of(hiddenClasses)), Collections.emptyList());
}
+ /**
+ * Create a {@link FilteredClassLoader} with the given {@code parent} that hides the
+ * given classes.
+ * @param parent the parent class loader
+ * @param hiddenClasses the classes to hide
+ */
+ public FilteredClassLoader(ClassLoader parent, Class>... hiddenClasses) {
+ this(parent, Collections.singleton(ClassFilter.of(hiddenClasses)), Collections.emptyList());
+ }
+
/**
* Create a {@link FilteredClassLoader} that hides classes from the given packages.
* @param hiddenPackages the packages to hide
@@ -86,7 +96,12 @@ public class FilteredClassLoader extends URLClassLoader implements SmartClassLoa
private FilteredClassLoader(Collection> classesFilters,
Collection> resourcesFilters) {
- super(new URL[0], FilteredClassLoader.class.getClassLoader());
+ this(FilteredClassLoader.class.getClassLoader(), classesFilters, resourcesFilters);
+ }
+
+ private FilteredClassLoader(ClassLoader parent, Collection> classesFilters,
+ Collection> resourcesFilters) {
+ super(new URL[0], parent);
this.classesFilters = classesFilters;
this.resourcesFilters = resourcesFilters;
}