Skip to content

Commit 9751795

Browse files
committed
Introduce TestSliceTestContextBootstrapper for test slices
Signed-off-by: Yanming Zhou <[email protected]>
1 parent 83f678a commit 9751795

20 files changed

+116
-195
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,8 +16,7 @@
1616

1717
package org.springframework.boot.test.autoconfigure.data.cassandra;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
@@ -26,13 +25,6 @@
2625
*
2726
* @author Artsiom Yudovin
2827
*/
29-
class DataCassandraTestContextBootstrapper extends SpringBootTestContextBootstrapper {
30-
31-
@Override
32-
protected String[] getProperties(Class<?> testClass) {
33-
DataCassandraTest dataCassandraTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
34-
DataCassandraTest.class);
35-
return (dataCassandraTest != null) ? dataCassandraTest.properties() : null;
36-
}
28+
class DataCassandraTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataCassandraTest> {
3729

3830
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,8 +16,7 @@
1616

1717
package org.springframework.boot.test.autoconfigure.data.couchbase;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
@@ -26,13 +25,6 @@
2625
*
2726
* @author Eddú Meléndez
2827
*/
29-
class DataCouchbaseTestContextBootstrapper extends SpringBootTestContextBootstrapper {
30-
31-
@Override
32-
protected String[] getProperties(Class<?> testClass) {
33-
DataCouchbaseTest dataCouchbaseTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
34-
DataCouchbaseTest.class);
35-
return (dataCouchbaseTest != null) ? dataCouchbaseTest.properties() : null;
36-
}
28+
class DataCouchbaseTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataCouchbaseTest> {
3729

3830
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,8 +16,7 @@
1616

1717
package org.springframework.boot.test.autoconfigure.data.elasticsearch;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
@@ -26,13 +25,6 @@
2625
*
2726
* @author Eddú Meléndez
2827
*/
29-
class DataElasticsearchTestContextBootstrapper extends SpringBootTestContextBootstrapper {
30-
31-
@Override
32-
protected String[] getProperties(Class<?> testClass) {
33-
DataElasticsearchTest dataElasticsearchTest = TestContextAnnotationUtils.findMergedAnnotation(testClass,
34-
DataElasticsearchTest.class);
35-
return (dataElasticsearchTest != null) ? dataElasticsearchTest.properties() : null;
36-
}
28+
class DataElasticsearchTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataElasticsearchTest> {
3729

3830
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,21 +16,14 @@
1616

1717
package org.springframework.boot.test.autoconfigure.data.jdbc;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
2423
* {@link TestContextBootstrapper} for {@link DataJdbcTest @DataJdbcTest} support.
2524
*
2625
* @author Andy Wilkinson
2726
*/
28-
class DataJdbcTestContextBootstrapper extends SpringBootTestContextBootstrapper {
29-
30-
@Override
31-
protected String[] getProperties(Class<?> testClass) {
32-
DataJdbcTest dataJdbcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataJdbcTest.class);
33-
return (dataJdbcTest != null) ? dataJdbcTest.properties() : null;
34-
}
27+
class DataJdbcTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataJdbcTest> {
3528

3629
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,21 +16,14 @@
1616

1717
package org.springframework.boot.test.autoconfigure.data.ldap;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
2423
* {@link TestContextBootstrapper} for {@link DataLdapTest @DataLdapTest} support.
2524
*
2625
* @author Artsiom Yudovin
2726
*/
28-
class DataLdapTestContextBootstrapper extends SpringBootTestContextBootstrapper {
29-
30-
@Override
31-
protected String[] getProperties(Class<?> testClass) {
32-
DataLdapTest dataLdapTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataLdapTest.class);
33-
return (dataLdapTest != null) ? dataLdapTest.properties() : null;
34-
}
27+
class DataLdapTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataLdapTest> {
3528

3629
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,21 +16,14 @@
1616

1717
package org.springframework.boot.test.autoconfigure.data.mongo;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
2423
* {@link TestContextBootstrapper} for {@link DataMongoTest @DataMongoTest} support.
2524
*
2625
* @author Artsiom Yudovin
2726
*/
28-
class DataMongoTestContextBootstrapper extends SpringBootTestContextBootstrapper {
29-
30-
@Override
31-
protected String[] getProperties(Class<?> testClass) {
32-
DataMongoTest dataMongoTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataMongoTest.class);
33-
return (dataMongoTest != null) ? dataMongoTest.properties() : null;
34-
}
27+
class DataMongoTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataMongoTest> {
3528

3629
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,21 +16,14 @@
1616

1717
package org.springframework.boot.test.autoconfigure.data.neo4j;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
2423
* {@link TestContextBootstrapper} for {@link DataNeo4jTest @DataNeo4jTest} support.
2524
*
2625
* @author Artsiom Yudovin
2726
*/
28-
class DataNeo4jTestContextBootstrapper extends SpringBootTestContextBootstrapper {
29-
30-
@Override
31-
protected String[] getProperties(Class<?> testClass) {
32-
DataNeo4jTest dataNeo4jTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataNeo4jTest.class);
33-
return (dataNeo4jTest != null) ? dataNeo4jTest.properties() : null;
34-
}
27+
class DataNeo4jTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataNeo4jTest> {
3528

3629
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,21 +16,14 @@
1616

1717
package org.springframework.boot.test.autoconfigure.data.r2dbc;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
2423
* {@link TestContextBootstrapper} for {@link DataR2dbcTest @DataR2dbcTest} support.
2524
*
2625
* @author Mark Paluch
2726
*/
28-
class DataR2dbcTestContextBootstrapper extends SpringBootTestContextBootstrapper {
29-
30-
@Override
31-
protected String[] getProperties(Class<?> testClass) {
32-
DataR2dbcTest dataR2dbcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataR2dbcTest.class);
33-
return (dataR2dbcTest != null) ? dataR2dbcTest.properties() : null;
34-
}
27+
class DataR2dbcTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataR2dbcTest> {
3528

3629
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,21 +16,14 @@
1616

1717
package org.springframework.boot.test.autoconfigure.data.redis;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
2423
* {@link TestContextBootstrapper} for {@link DataRedisTest @DataRedisTest} support.
2524
*
2625
* @author Artsiom Yudovin
2726
*/
28-
class DataRedisTestContextBootstrapper extends SpringBootTestContextBootstrapper {
29-
30-
@Override
31-
protected String[] getProperties(Class<?> testClass) {
32-
DataRedisTest dataRedisTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataRedisTest.class);
33-
return (dataRedisTest != null) ? dataRedisTest.properties() : null;
34-
}
27+
class DataRedisTestContextBootstrapper extends TestSliceTestContextBootstrapper<DataRedisTest> {
3528

3629
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 the original author or authors.
2+
* Copyright 2020-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.
@@ -16,21 +16,14 @@
1616

1717
package org.springframework.boot.test.autoconfigure.graphql;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
2423
* {@link TestContextBootstrapper} for {@link GraphQlTest @GraphQlTest}.
2524
*
2625
* @author Brian Clozel
2726
*/
28-
class GraphQlTestContextBootstrapper extends SpringBootTestContextBootstrapper {
29-
30-
@Override
31-
protected String[] getProperties(Class<?> testClass) {
32-
GraphQlTest graphQlTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, GraphQlTest.class);
33-
return (graphQlTest != null) ? graphQlTest.properties() : null;
34-
}
27+
class GraphQlTestContextBootstrapper extends TestSliceTestContextBootstrapper<GraphQlTest> {
3528

3629
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,21 +16,15 @@
1616

1717
package org.springframework.boot.test.autoconfigure.jdbc;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
2423
* {@link TestContextBootstrapper} for {@link JdbcTest @JdbcTest} support.
2524
*
2625
* @author Artsiom Yudovin
26+
* @author Yanming Zhou
2727
*/
28-
class JdbcTestContextBootstrapper extends SpringBootTestContextBootstrapper {
29-
30-
@Override
31-
protected String[] getProperties(Class<?> testClass) {
32-
JdbcTest jdbcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, JdbcTest.class);
33-
return (jdbcTest != null) ? jdbcTest.properties() : null;
34-
}
28+
class JdbcTestContextBootstrapper extends TestSliceTestContextBootstrapper<JdbcTest> {
3529

3630
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.
@@ -16,21 +16,14 @@
1616

1717
package org.springframework.boot.test.autoconfigure.jooq;
1818

19-
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
20-
import org.springframework.test.context.TestContextAnnotationUtils;
19+
import org.springframework.boot.test.context.TestSliceTestContextBootstrapper;
2120
import org.springframework.test.context.TestContextBootstrapper;
2221

2322
/**
2423
* {@link TestContextBootstrapper} for {@link JooqTest @JooqTest} support.
2524
*
2625
* @author Artsiom Yudovin
2726
*/
28-
class JooqTestContextBootstrapper extends SpringBootTestContextBootstrapper {
29-
30-
@Override
31-
protected String[] getProperties(Class<?> testClass) {
32-
JooqTest jooqTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, JooqTest.class);
33-
return (jooqTest != null) ? jooqTest.properties() : null;
34-
}
27+
class JooqTestContextBootstrapper extends TestSliceTestContextBootstrapper<JooqTest> {
3528

3629
}

0 commit comments

Comments
 (0)