This commit is contained in:
Yanming Zhou 2025-05-07 18:12:43 +03:00 committed by GitHub
commit 109c26f6af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 115 additions and 194 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.cassandra; package org.springframework.boot.test.autoconfigure.data.cassandra;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -26,13 +25,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class DataCassandraTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataCassandraTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataCassandraTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataCassandraTest dataCassandraTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
DataCassandraTest.class);
return (dataCassandraTest != null) ? dataCassandraTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.couchbase; package org.springframework.boot.test.autoconfigure.data.couchbase;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -26,13 +25,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Eddú Meléndez * @author Eddú Meléndez
*/ */
class DataCouchbaseTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataCouchbaseTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataCouchbaseTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataCouchbaseTest dataCouchbaseTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
DataCouchbaseTest.class);
return (dataCouchbaseTest != null) ? dataCouchbaseTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.elasticsearch; package org.springframework.boot.test.autoconfigure.data.elasticsearch;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -26,13 +25,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Eddú Meléndez * @author Eddú Meléndez
*/ */
class DataElasticsearchTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataElasticsearchTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataElasticsearchTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataElasticsearchTest dataElasticsearchTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
DataElasticsearchTest.class);
return (dataElasticsearchTest != null) ? dataElasticsearchTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.jdbc; package org.springframework.boot.test.autoconfigure.data.jdbc;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
class DataJdbcTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataJdbcTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataJdbcTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataJdbcTest dataJdbcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataJdbcTest.class);
return (dataJdbcTest != null) ? dataJdbcTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.ldap; package org.springframework.boot.test.autoconfigure.data.ldap;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class DataLdapTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataLdapTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataLdapTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataLdapTest dataLdapTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataLdapTest.class);
return (dataLdapTest != null) ? dataLdapTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.mongo; package org.springframework.boot.test.autoconfigure.data.mongo;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class DataMongoTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataMongoTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataMongoTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataMongoTest dataMongoTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataMongoTest.class);
return (dataMongoTest != null) ? dataMongoTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.neo4j; package org.springframework.boot.test.autoconfigure.data.neo4j;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class DataNeo4jTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataNeo4jTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataNeo4jTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataNeo4jTest dataNeo4jTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataNeo4jTest.class);
return (dataNeo4jTest != null) ? dataNeo4jTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.r2dbc; package org.springframework.boot.test.autoconfigure.data.r2dbc;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
class DataR2dbcTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataR2dbcTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataR2dbcTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataR2dbcTest dataR2dbcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataR2dbcTest.class);
return (dataR2dbcTest != null) ? dataR2dbcTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.data.redis; package org.springframework.boot.test.autoconfigure.data.redis;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class DataRedisTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataRedisTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataRedisTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataRedisTest dataRedisTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataRedisTest.class);
return (dataRedisTest != null) ? dataRedisTest.properties() : null;
}
} }

View File

@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.graphql; package org.springframework.boot.test.autoconfigure.graphql;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Brian Clozel * @author Brian Clozel
*/ */
class GraphQlTestContextBootstrapper extends SpringBootTestContextBootstrapper { class GraphQlTestContextBootstrapper extends TestSliceTestContextBootstrapper<GraphQlTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
GraphQlTest graphQlTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, GraphQlTest.class);
return (graphQlTest != null) ? graphQlTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,21 +16,15 @@
package org.springframework.boot.test.autoconfigure.jdbc; package org.springframework.boot.test.autoconfigure.jdbc;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
* {@link TestContextBootstrapper} for {@link JdbcTest @JdbcTest} support. * {@link TestContextBootstrapper} for {@link JdbcTest @JdbcTest} support.
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
* @author Yanming Zhou
*/ */
class JdbcTestContextBootstrapper extends SpringBootTestContextBootstrapper { class JdbcTestContextBootstrapper extends TestSliceTestContextBootstrapper<JdbcTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
JdbcTest jdbcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, JdbcTest.class);
return (jdbcTest != null) ? jdbcTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.jooq; package org.springframework.boot.test.autoconfigure.jooq;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class JooqTestContextBootstrapper extends SpringBootTestContextBootstrapper { class JooqTestContextBootstrapper extends TestSliceTestContextBootstrapper<JooqTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
JooqTest jooqTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, JooqTest.class);
return (jooqTest != null) ? jooqTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.json; package org.springframework.boot.test.autoconfigure.json;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class JsonTestContextBootstrapper extends SpringBootTestContextBootstrapper { class JsonTestContextBootstrapper extends TestSliceTestContextBootstrapper<JsonTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
JsonTest jsonTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, JsonTest.class);
return (jsonTest != null) ? jsonTest.properties() : null;
}
} }

View File

@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.orm.jpa; package org.springframework.boot.test.autoconfigure.orm.jpa;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,12 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class DataJpaTestContextBootstrapper extends SpringBootTestContextBootstrapper { class DataJpaTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataJpaTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
DataJpaTest dataJpaTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataJpaTest.class);
return (dataJpaTest != null) ? dataJpaTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.web.client; package org.springframework.boot.test.autoconfigure.web.client;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -25,13 +24,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class RestClientTestContextBootstrapper extends SpringBootTestContextBootstrapper { class RestClientTestContextBootstrapper extends TestSliceTestContextBootstrapper<RestClientTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
RestClientTest restClientTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
RestClientTest.class);
return (restClientTest != null) ? restClientTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,9 +17,8 @@
package org.springframework.boot.test.autoconfigure.web.reactive; package org.springframework.boot.test.autoconfigure.web.reactive;
import org.springframework.boot.test.context.ReactiveWebMergedContextConfiguration; import org.springframework.boot.test.context.ReactiveWebMergedContextConfiguration;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.MergedContextConfiguration; import org.springframework.test.context.MergedContextConfiguration;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -28,17 +27,11 @@ import org.springframework.test.context.TestContextBootstrapper;
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Artsiom Yudovin * @author Artsiom Yudovin
*/ */
class WebFluxTestContextBootstrapper extends SpringBootTestContextBootstrapper { class WebFluxTestContextBootstrapper extends TestSliceTestContextBootstrapper<WebFluxTest> {
@Override @Override
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) { protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
return new ReactiveWebMergedContextConfiguration(super.processMergedContextConfiguration(mergedConfig)); return new ReactiveWebMergedContextConfiguration(super.processMergedContextConfiguration(mergedConfig));
} }
@Override
protected String[] getProperties(Class<?> testClass) {
WebFluxTest webFluxTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, WebFluxTest.class);
return (webFluxTest != null) ? webFluxTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,8 @@
package org.springframework.boot.test.autoconfigure.web.servlet; package org.springframework.boot.test.autoconfigure.web.servlet;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.MergedContextConfiguration; import org.springframework.test.context.MergedContextConfiguration;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
import org.springframework.test.context.web.WebMergedContextConfiguration; import org.springframework.test.context.web.WebMergedContextConfiguration;
@ -29,7 +28,7 @@ import org.springframework.test.context.web.WebMergedContextConfiguration;
* @author Artsiom Yudovin * @author Artsiom Yudovin
* @author Lorenzo Dee * @author Lorenzo Dee
*/ */
class WebMvcTestContextBootstrapper extends SpringBootTestContextBootstrapper { class WebMvcTestContextBootstrapper extends TestSliceTestContextBootstrapper<WebMvcTest> {
@Override @Override
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) { protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
@ -37,10 +36,4 @@ class WebMvcTestContextBootstrapper extends SpringBootTestContextBootstrapper {
return new WebMergedContextConfiguration(processedMergedConfiguration, determineResourceBasePath(mergedConfig)); return new WebMergedContextConfiguration(processedMergedConfiguration, determineResourceBasePath(mergedConfig));
} }
@Override
protected String[] getProperties(Class<?> testClass) {
WebMvcTest webMvcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, WebMvcTest.class);
return (webMvcTest != null) ? webMvcTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package org.springframework.boot.test.autoconfigure.webservices.client; package org.springframework.boot.test.autoconfigure.webservices.client;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
/** /**
@ -26,13 +25,6 @@ import org.springframework.test.context.TestContextBootstrapper;
* *
* @author Dmytro Nosan * @author Dmytro Nosan
*/ */
class WebServiceClientTestContextBootstrapper extends SpringBootTestContextBootstrapper { class WebServiceClientTestContextBootstrapper extends TestSliceTestContextBootstrapper<WebServiceClientTest> {
@Override
protected String[] getProperties(Class<?> testClass) {
WebServiceClientTest webServiceClientTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
WebServiceClientTest.class);
return (webServiceClientTest != null) ? webServiceClientTest.properties() : null;
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,8 @@
package org.springframework.boot.test.autoconfigure.webservices.server; package org.springframework.boot.test.autoconfigure.webservices.server;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
import org.springframework.test.context.MergedContextConfiguration; import org.springframework.test.context.MergedContextConfiguration;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper;
import org.springframework.test.context.web.WebMergedContextConfiguration; import org.springframework.test.context.web.WebMergedContextConfiguration;
@ -28,7 +27,7 @@ import org.springframework.test.context.web.WebMergedContextConfiguration;
* *
* @author Daniil Razorenov * @author Daniil Razorenov
*/ */
class WebServiceServerTestContextBootstrapper extends SpringBootTestContextBootstrapper { class WebServiceServerTestContextBootstrapper extends TestSliceTestContextBootstrapper<WebServiceServerTest> {
@Override @Override
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) { protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig) {
@ -36,11 +35,4 @@ class WebServiceServerTestContextBootstrapper extends SpringBootTestContextBoots
return new WebMergedContextConfiguration(processedMergedConfiguration, determineResourceBasePath(mergedConfig)); return new WebMergedContextConfiguration(processedMergedConfiguration, determineResourceBasePath(mergedConfig));
} }
@Override
protected String[] getProperties(Class<?> testClass) {
WebServiceServerTest webServiceServerTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
WebServiceServerTest.class);
return (webServiceServerTest != null) ? webServiceServerTest.properties() : null;
}
} }

View File

@ -0,0 +1,59 @@
/*
* 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.test.context;
import java.lang.annotation.Annotation;
import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.MergedAnnotation;
import org.springframework.core.annotation.MergedAnnotations;
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
import org.springframework.test.context.TestContextAnnotationUtils;
import org.springframework.test.context.TestContextBootstrapper;
import org.springframework.util.Assert;
/**
* {@link TestContextBootstrapper} for test slices support.
*
* @param <T> the test slice annotation
* @author Yanming Zhou
* @since 3.5.0
*/
public class TestSliceTestContextBootstrapper<T extends Annotation> extends SpringBootTestContextBootstrapper {
private final Class<T> annotationType;
@SuppressWarnings("unchecked")
public TestSliceTestContextBootstrapper() {
this.annotationType = (Class<T>) ResolvableType.forClass(getClass())
.as(TestSliceTestContextBootstrapper.class)
.getGeneric(0)
.resolve();
Assert.notNull(this.annotationType, "'%s' doesn't contain type parameter of '%s'"
.formatted(getClass().getName(), TestSliceTestContextBootstrapper.class.getName()));
}
@Override
protected String[] getProperties(Class<?> testClass) {
MergedAnnotation<T> annotation = MergedAnnotations.search(SearchStrategy.TYPE_HIERARCHY)
.withEnclosingClasses(TestContextAnnotationUtils::searchEnclosingClass)
.from(testClass)
.get(this.annotationType);
return annotation.isPresent() ? annotation.getStringArray("properties") : null;
}
}