|
16 | 16 |
|
17 | 17 | package org.springframework.boot.test.context;
|
18 | 18 |
|
19 |
| -import org.assertj.core.api.Assertions; |
20 | 19 | import org.junit.jupiter.api.Test;
|
21 | 20 |
|
22 |
| -import org.springframework.boot.test.context.runner.ApplicationContextRunner; |
| 21 | +import org.springframework.context.annotation.Configuration; |
| 22 | +import org.springframework.core.annotation.AnnotatedElementUtils; |
| 23 | +import org.springframework.core.annotation.AnnotationAttributes; |
| 24 | + |
| 25 | +import static org.assertj.core.api.Assertions.assertThat; |
23 | 26 |
|
24 | 27 | /**
|
25 |
| - * Tests for {@link TestConfiguration}. |
| 28 | + * Tests for {@link TestConfiguration @TestConfiguration}. |
26 | 29 | *
|
27 |
| - * @author Dmytro Nosan |
| 30 | + * @author Stephane Nicoll |
28 | 31 | */
|
29 | 32 | class TestConfigurationTests {
|
30 | 33 |
|
31 |
| - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner(); |
32 |
| - |
33 | 34 | @Test
|
34 |
| - void shouldProxyBeanMethods() { |
35 |
| - this.contextRunner.withUserConfiguration(ProxyBeanMethodsConfiguration.class) |
36 |
| - .run((context) -> Assertions.assertThat(context).hasFailed()); |
| 35 | + void proxyBeanMethodsIsEnabledByDefault() { |
| 36 | + AnnotationAttributes attributes = AnnotatedElementUtils |
| 37 | + .getMergedAnnotationAttributes(DefaultTestConfiguration.class, Configuration.class); |
| 38 | + assertThat(attributes.get("proxyBeanMethods")).isEqualTo(true); |
37 | 39 | }
|
38 | 40 |
|
39 | 41 | @Test
|
40 |
| - void shouldNotProxyBeanMethods() { |
41 |
| - this.contextRunner.withUserConfiguration(ProxyBeanMethodsDisableConfiguration.class) |
42 |
| - .run((context) -> Assertions.assertThat(context).hasNotFailed()); |
| 42 | + void proxyBeanMethodsCanBeDisabled() { |
| 43 | + AnnotationAttributes attributes = AnnotatedElementUtils |
| 44 | + .getMergedAnnotationAttributes(NoBeanMethodProxyingTestConfiguration.class, Configuration.class); |
| 45 | + assertThat(attributes.get("proxyBeanMethods")).isEqualTo(false); |
43 | 46 | }
|
44 | 47 |
|
45 | 48 | @TestConfiguration
|
46 |
| - final static class ProxyBeanMethodsConfiguration { |
| 49 | + static class DefaultTestConfiguration { |
47 | 50 |
|
48 | 51 | }
|
49 | 52 |
|
50 | 53 | @TestConfiguration(proxyBeanMethods = false)
|
51 |
| - final static class ProxyBeanMethodsDisableConfiguration { |
| 54 | + static class NoBeanMethodProxyingTestConfiguration { |
52 | 55 |
|
53 | 56 | }
|
54 | 57 |
|
|
0 commit comments