Skip to content

Commit dafcef3

Browse files
committed
Merge branch '3.3.x' into 3.4.x
Closes gh-44579
2 parents 1eef438 + 55c410a commit dafcef3

File tree

189 files changed

+1722
-842
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+1722
-842
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ void combinedExclusionsAreApplied() {
166166
}
167167

168168
@Test
169+
@WithTestAutoConfigurationImportsResource
170+
@WithTestAutoConfigurationReplacementsResource
169171
void removedExclusionsAreApplied() {
170172
TestAutoConfigurationImportSelector importSelector = new TestAutoConfigurationImportSelector(
171173
TestAutoConfiguration.class);
@@ -234,7 +236,9 @@ void getExclusionFilterReuseFilters() {
234236
}
235237

236238
@Test
237-
void soringConsidersReplacements() {
239+
@WithTestAutoConfigurationImportsResource
240+
@WithTestAutoConfigurationReplacementsResource
241+
void sortingConsidersReplacements() {
238242
TestAutoConfigurationImportSelector importSelector = new TestAutoConfigurationImportSelector(
239243
TestAutoConfiguration.class);
240244
setupImportSelector(importSelector);
@@ -397,4 +401,28 @@ static class SeventhAutoConfiguration {
397401

398402
}
399403

404+
@Target(ElementType.METHOD)
405+
@Retention(RetentionPolicy.RUNTIME)
406+
@WithResource(
407+
name = "META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.imports",
408+
content = """
409+
org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$AfterDeprecatedAutoConfiguration
410+
org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$ReplacementAutoConfiguration
411+
""")
412+
@interface WithTestAutoConfigurationImportsResource {
413+
414+
}
415+
416+
@Target(ElementType.METHOD)
417+
@Retention(RetentionPolicy.RUNTIME)
418+
@WithResource(
419+
name = "META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$TestAutoConfiguration.replacements",
420+
content = """
421+
org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$DeprecatedAutoConfiguration=\
422+
org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests$ReplacementAutoConfiguration
423+
""")
424+
@interface WithTestAutoConfigurationReplacementsResource {
425+
426+
}
427+
400428
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoaderTests.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,13 +20,21 @@
2020

2121
import org.junit.jupiter.api.Test;
2222

23+
import org.springframework.boot.testsupport.classpath.resources.WithResource;
24+
2325
import static org.assertj.core.api.Assertions.assertThat;
2426

2527
/**
2628
* Test for {@link AutoConfigurationMetadataLoader}.
2729
*
2830
* @author Phillip Webb
2931
*/
32+
@WithResource(name = "metadata.properties", content = """
33+
test=
34+
test.string=abc
35+
test.int=123
36+
test.set=a,b,b,c
37+
""")
3038
class AutoConfigurationMetadataLoaderTests {
3139

3240
@Test
@@ -90,8 +98,8 @@ void getWithDefaultWhenMissingShouldReturnDefault() {
9098
}
9199

92100
private AutoConfigurationMetadata load() {
93-
return AutoConfigurationMetadataLoader.loadMetadata(null,
94-
"META-INF/AutoConfigurationMetadataLoaderTests.properties");
101+
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
102+
return AutoConfigurationMetadataLoader.loadMetadata(classLoader, "metadata.properties");
95103
}
96104

97105
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationReplacementsTests.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,19 +24,33 @@
2424
import java.util.List;
2525
import java.util.Set;
2626

27+
import org.junit.jupiter.api.BeforeEach;
2728
import org.junit.jupiter.api.Test;
2829

30+
import org.springframework.boot.testsupport.classpath.resources.WithResource;
31+
2932
import static org.assertj.core.api.Assertions.assertThat;
3033

3134
/**
3235
* Tests for {@link AutoConfigurationReplacements}.
3336
*
3437
* @author Phillip Webb
3538
*/
39+
@WithResource(
40+
name = "META-INF/spring/org.springframework.boot.autoconfigure.AutoConfigurationReplacementsTests$TestAutoConfigurationReplacements.replacements",
41+
content = """
42+
com.example.A1=com.example.A2
43+
com.example.B1=com.example.B2
44+
""")
3645
class AutoConfigurationReplacementsTests {
3746

38-
private final AutoConfigurationReplacements replacements = AutoConfigurationReplacements
39-
.load(TestAutoConfigurationReplacements.class, null);
47+
private AutoConfigurationReplacements replacements;
48+
49+
@BeforeEach
50+
void loadReplacements() {
51+
this.replacements = AutoConfigurationReplacements.load(TestAutoConfigurationReplacements.class,
52+
Thread.currentThread().getContextClassLoader());
53+
}
4054

4155
@Test
4256
void replaceWhenMatchReplacesClassName() {

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelectorTests.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
3030
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
31+
import org.springframework.boot.testsupport.classpath.resources.WithResource;
3132
import org.springframework.core.annotation.AliasFor;
3233
import org.springframework.core.io.DefaultResourceLoader;
3334
import org.springframework.core.type.AnnotationMetadata;
@@ -74,6 +75,12 @@ void importsAreSelectedUsingClassesAttribute() throws Exception {
7475
}
7576

7677
@Test
78+
@WithResource(
79+
name = "META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFile.imports",
80+
content = """
81+
org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$ImportedAutoConfiguration
82+
org.springframework.boot.autoconfigure.missing.MissingAutoConfiguration
83+
""")
7784
void importsAreSelectedFromImportsFile() throws Exception {
7885
AnnotationMetadata annotationMetadata = getAnnotationMetadata(FromImportsFile.class);
7986
String[] imports = this.importSelector.selectImports(annotationMetadata);
@@ -83,9 +90,15 @@ void importsAreSelectedFromImportsFile() throws Exception {
8390
}
8491

8592
@Test
93+
@WithResource(
94+
name = "META-INF/spring/org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$FromImportsFile.imports",
95+
content = """
96+
optional:org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$ImportedAutoConfiguration
97+
optional:org.springframework.boot.autoconfigure.missing.MissingAutoConfiguration
98+
org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$AnotherImportedAutoConfiguration
99+
""")
86100
void importsSelectedFromImportsFileIgnoreMissingOptionalClasses() throws Exception {
87-
AnnotationMetadata annotationMetadata = getAnnotationMetadata(
88-
FromImportsFileIgnoresMissingOptionalClasses.class);
101+
AnnotationMetadata annotationMetadata = getAnnotationMetadata(FromImportsFile.class);
89102
String[] imports = this.importSelector.selectImports(annotationMetadata);
90103
assertThat(imports).containsExactly(
91104
"org.springframework.boot.autoconfigure.ImportAutoConfigurationImportSelectorTests$ImportedAutoConfiguration",

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -910,9 +910,8 @@ void enableSslWithInvalidTrustStoreTypeShouldFail() {
910910
void enableSslWithBundle() {
911911
this.contextRunner.withUserConfiguration(TestConfiguration.class)
912912
.withPropertyValues("spring.rabbitmq.ssl.bundle=test-bundle",
913-
"spring.ssl.bundle.jks.test-bundle.keystore.location=classpath:test.jks",
914-
"spring.ssl.bundle.jks.test-bundle.keystore.password=secret",
915-
"spring.ssl.bundle.jks.test-bundle.key.password=password")
913+
"spring.ssl.bundle.jks.test-bundle.keystore.location=classpath:org/springframework/boot/autoconfigure/amqp/test.jks",
914+
"spring.ssl.bundle.jks.test-bundle.keystore.password=secret")
916915
.run((context) -> {
917916
com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = getTargetConnectionFactory(context);
918917
assertThat(rabbitConnectionFactory.isSSL()).isTrue();

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,6 +72,8 @@
7272
import org.springframework.boot.test.context.FilteredClassLoader;
7373
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
7474
import org.springframework.boot.test.system.OutputCaptureExtension;
75+
import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
76+
import org.springframework.boot.testsupport.classpath.resources.WithResource;
7577
import org.springframework.context.ApplicationContext;
7678
import org.springframework.context.annotation.Bean;
7779
import org.springframework.context.annotation.Configuration;
@@ -288,13 +290,13 @@ void testUsingJpa() {
288290
}
289291

290292
@Test
293+
@WithPackageResources("custom-schema.sql")
291294
void testRenamePrefix() {
292295
this.contextRunner
293296
.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class,
294297
HibernateJpaAutoConfiguration.class)
295298
.withPropertyValues("spring.datasource.generate-unique-name=true",
296-
"spring.batch.jdbc.schema:classpath:batch/custom-schema.sql",
297-
"spring.batch.jdbc.tablePrefix:PREFIX_")
299+
"spring.batch.jdbc.schema:classpath:custom-schema.sql", "spring.batch.jdbc.tablePrefix:PREFIX_")
298300
.run((context) -> {
299301
assertThat(context).hasSingleBean(JobLauncher.class);
300302
assertThat(context.getBean(BatchProperties.class).getJdbc().getInitializeSchema())
@@ -412,6 +414,7 @@ void jobRepositoryBeansDependOnFlyway() {
412414
}
413415

414416
@Test
417+
@WithResource(name = "db/changelog/db.changelog-master.yaml", content = "databaseChangeLog:")
415418
void jobRepositoryBeansDependOnLiquibase() {
416419
this.contextRunner.withUserConfiguration(TestConfiguration.class, EmbeddedDataSourceConfiguration.class)
417420
.withUserConfiguration(LiquibaseAutoConfiguration.class)

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationWithoutJpaTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
3434
import org.springframework.boot.sql.init.DatabaseInitializationMode;
3535
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3636
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
37+
import org.springframework.boot.testsupport.classpath.resources.WithPackageResources;
3738
import org.springframework.jdbc.core.JdbcTemplate;
3839
import org.springframework.transaction.annotation.Isolation;
3940

@@ -70,11 +71,11 @@ void jdbcWithDefaultSettings() {
7071
}
7172

7273
@Test
74+
@WithPackageResources("custom-schema.sql")
7375
void jdbcWithCustomPrefix() {
7476
this.contextRunner.withUserConfiguration(DefaultConfiguration.class, EmbeddedDataSourceConfiguration.class)
7577
.withPropertyValues("spring.datasource.generate-unique-name=true",
76-
"spring.batch.jdbc.schema:classpath:batch/custom-schema.sql",
77-
"spring.batch.jdbc.tablePrefix:PREFIX_")
78+
"spring.batch.jdbc.schema:classpath:custom-schema.sql", "spring.batch.jdbc.tablePrefix:PREFIX_")
7879
.run((context) -> {
7980
assertThat(new JdbcTemplate(context.getBean(DataSource.class))
8081
.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();

0 commit comments

Comments
 (0)