Commit 506f7ac 1 parent d9084ea commit 506f7ac Copy full SHA for 506f7ac
File tree 8 files changed +19
-37
lines changed
spring-boot-test/src/main/java/org/springframework/boot/test
spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure
8 files changed +19
-37
lines changed Original file line number Diff line number Diff line change 26
26
import org .springframework .test .context .ContextCustomizerFactory ;
27
27
import org .springframework .test .context .MergedContextConfiguration ;
28
28
import org .springframework .test .context .TestContextAnnotationUtils ;
29
- import org .springframework .test .context .TestContextAnnotationUtils .AnnotationDescriptor ;
30
29
31
30
/**
32
31
* {@link ContextCustomizerFactory} to support
@@ -39,9 +38,9 @@ class OverrideAutoConfigurationContextCustomizerFactory implements ContextCustom
39
38
@ Override
40
39
public ContextCustomizer createContextCustomizer (Class <?> testClass ,
41
40
List <ContextConfigurationAttributes > configurationAttributes ) {
42
- AnnotationDescriptor < OverrideAutoConfiguration > descriptor = TestContextAnnotationUtils
43
- . findAnnotationDescriptor ( testClass , OverrideAutoConfiguration .class );
44
- boolean enabled = (descriptor != null ) ? descriptor . getAnnotation () .enabled () : true ;
41
+ OverrideAutoConfiguration overrideAutoConfiguration = TestContextAnnotationUtils . findMergedAnnotation ( testClass ,
42
+ OverrideAutoConfiguration .class );
43
+ boolean enabled = (overrideAutoConfiguration != null ) ? overrideAutoConfiguration .enabled () : true ;
45
44
return !enabled ? new DisableAutoConfigurationContextCustomizer () : null ;
46
45
}
47
46
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class MetricsExportContextCustomizerFactory implements ContextCustomizerFactory
37
37
@ Override
38
38
public ContextCustomizer createContextCustomizer (Class <?> testClass ,
39
39
List <ContextConfigurationAttributes > configAttributes ) {
40
- boolean disableMetricsExport = TestContextAnnotationUtils .findAnnotationDescriptor (testClass ,
40
+ boolean disableMetricsExport = TestContextAnnotationUtils .findMergedAnnotation (testClass ,
41
41
AutoConfigureMetrics .class ) == null ;
42
42
return disableMetricsExport ? new DisableMetricExportContextCustomizer () : null ;
43
43
}
Original file line number Diff line number Diff line change 47
47
import org .springframework .test .context .MergedContextConfiguration ;
48
48
import org .springframework .test .context .TestContext ;
49
49
import org .springframework .test .context .TestContextAnnotationUtils ;
50
- import org .springframework .test .context .TestContextAnnotationUtils .AnnotationDescriptor ;
51
50
import org .springframework .test .context .TestContextBootstrapper ;
52
51
import org .springframework .test .context .TestExecutionListener ;
53
52
import org .springframework .test .context .support .DefaultTestContextBootstrapper ;
@@ -320,12 +319,7 @@ protected String[] getProperties(Class<?> testClass) {
320
319
}
321
320
322
321
protected SpringBootTest getAnnotation (Class <?> testClass ) {
323
- AnnotationDescriptor <SpringBootTest > descriptor = TestContextAnnotationUtils .findAnnotationDescriptor (testClass ,
324
- SpringBootTest .class );
325
- if (descriptor != null ) {
326
- return descriptor .getAnnotation ();
327
- }
328
- return null ;
322
+ return TestContextAnnotationUtils .findMergedAnnotation (testClass , SpringBootTest .class );
329
323
}
330
324
331
325
protected void verifyConfiguration (Class <?> testClass ) {
Original file line number Diff line number Diff line change 21
21
import org .springframework .test .context .ContextCustomizer ;
22
22
import org .springframework .test .context .MergedContextConfiguration ;
23
23
import org .springframework .test .context .TestContextAnnotationUtils ;
24
- import org .springframework .test .context .TestContextAnnotationUtils .AnnotationDescriptor ;
25
24
26
25
/**
27
26
* {@link ContextCustomizer} to track the web environment that is used in a
@@ -36,9 +35,9 @@ class SpringBootTestWebEnvironment implements ContextCustomizer {
36
35
private final WebEnvironment webEnvironment ;
37
36
38
37
SpringBootTestWebEnvironment (Class <?> testClass ) {
39
- AnnotationDescriptor < SpringBootTest > descriptor = TestContextAnnotationUtils .findAnnotationDescriptor (testClass ,
38
+ SpringBootTest sprintBootTest = TestContextAnnotationUtils .findMergedAnnotation (testClass ,
40
39
SpringBootTest .class );
41
- this .webEnvironment = (descriptor != null ) ? descriptor . getAnnotation () .webEnvironment () : null ;
40
+ this .webEnvironment = (sprintBootTest != null ) ? sprintBootTest .webEnvironment () : null ;
42
41
}
43
42
44
43
@ Override
Original file line number Diff line number Diff line change 40
40
import org .springframework .test .context .ContextCustomizer ;
41
41
import org .springframework .test .context .MergedContextConfiguration ;
42
42
import org .springframework .test .context .TestContextAnnotationUtils ;
43
- import org .springframework .test .context .TestContextAnnotationUtils .AnnotationDescriptor ;
44
43
45
44
/**
46
45
* {@link ContextCustomizer} for {@link TestRestTemplate}.
@@ -53,9 +52,9 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer {
53
52
@ Override
54
53
public void customizeContext (ConfigurableApplicationContext context ,
55
54
MergedContextConfiguration mergedContextConfiguration ) {
56
- AnnotationDescriptor < SpringBootTest > springBootTest = TestContextAnnotationUtils
57
- .findAnnotationDescriptor (mergedContextConfiguration .getTestClass (), SpringBootTest .class );
58
- if (springBootTest .getAnnotation (). webEnvironment ().isEmbedded ()) {
55
+ SpringBootTest springBootTest = TestContextAnnotationUtils
56
+ .findMergedAnnotation (mergedContextConfiguration .getTestClass (), SpringBootTest .class );
57
+ if (springBootTest .webEnvironment ().isEmbedded ()) {
59
58
registerTestRestTemplate (context );
60
59
}
61
60
}
Original file line number Diff line number Diff line change 23
23
import org .springframework .test .context .ContextCustomizer ;
24
24
import org .springframework .test .context .ContextCustomizerFactory ;
25
25
import org .springframework .test .context .TestContextAnnotationUtils ;
26
- import org .springframework .test .context .TestContextAnnotationUtils .AnnotationDescriptor ;
27
26
28
27
/**
29
28
* {@link ContextCustomizerFactory} for {@link TestRestTemplate}.
@@ -36,12 +35,9 @@ class TestRestTemplateContextCustomizerFactory implements ContextCustomizerFacto
36
35
@ Override
37
36
public ContextCustomizer createContextCustomizer (Class <?> testClass ,
38
37
List <ContextConfigurationAttributes > configAttributes ) {
39
- AnnotationDescriptor <SpringBootTest > springBootTest = TestContextAnnotationUtils
40
- .findAnnotationDescriptor (testClass , SpringBootTest .class );
41
- if (springBootTest != null ) {
42
- return new TestRestTemplateContextCustomizer ();
43
- }
44
- return null ;
38
+ SpringBootTest springBootTest = TestContextAnnotationUtils .findMergedAnnotation (testClass ,
39
+ SpringBootTest .class );
40
+ return (springBootTest != null ) ? new TestRestTemplateContextCustomizer () : null ;
45
41
}
46
42
47
43
}
Original file line number Diff line number Diff line change 41
41
import org .springframework .test .context .ContextCustomizer ;
42
42
import org .springframework .test .context .MergedContextConfiguration ;
43
43
import org .springframework .test .context .TestContextAnnotationUtils ;
44
- import org .springframework .test .context .TestContextAnnotationUtils .AnnotationDescriptor ;
45
44
import org .springframework .test .web .reactive .server .WebTestClient ;
46
45
import org .springframework .util .CollectionUtils ;
47
46
import org .springframework .web .reactive .function .client .ExchangeStrategies ;
@@ -55,9 +54,9 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
55
54
56
55
@ Override
57
56
public void customizeContext (ConfigurableApplicationContext context , MergedContextConfiguration mergedConfig ) {
58
- AnnotationDescriptor < SpringBootTest > springBootTest = TestContextAnnotationUtils
59
- . findAnnotationDescriptor ( mergedConfig . getTestClass (), SpringBootTest .class );
60
- if (springBootTest .getAnnotation (). webEnvironment ().isEmbedded ()) {
57
+ SpringBootTest springBootTest = TestContextAnnotationUtils . findMergedAnnotation ( mergedConfig . getTestClass (),
58
+ SpringBootTest .class );
59
+ if (springBootTest .webEnvironment ().isEmbedded ()) {
61
60
registerWebTestClient (context );
62
61
}
63
62
}
Original file line number Diff line number Diff line change 23
23
import org .springframework .test .context .ContextCustomizer ;
24
24
import org .springframework .test .context .ContextCustomizerFactory ;
25
25
import org .springframework .test .context .TestContextAnnotationUtils ;
26
- import org .springframework .test .context .TestContextAnnotationUtils .AnnotationDescriptor ;
27
26
import org .springframework .util .ClassUtils ;
28
27
29
28
/**
@@ -38,12 +37,9 @@ class WebTestClientContextCustomizerFactory implements ContextCustomizerFactory
38
37
@ Override
39
38
public ContextCustomizer createContextCustomizer (Class <?> testClass ,
40
39
List <ContextConfigurationAttributes > configAttributes ) {
41
- AnnotationDescriptor <SpringBootTest > springBootTest = TestContextAnnotationUtils
42
- .findAnnotationDescriptor (testClass , SpringBootTest .class );
43
- if (springBootTest != null ) {
44
- return new WebTestClientContextCustomizer ();
45
- }
46
- return null ;
40
+ SpringBootTest springBootTest = TestContextAnnotationUtils .findMergedAnnotation (testClass ,
41
+ SpringBootTest .class );
42
+ return (springBootTest != null ) ? new WebTestClientContextCustomizer () : null ;
47
43
}
48
44
49
45
private boolean isWebClientPresent () {
You can’t perform that action at this time.
0 commit comments