|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2020 the original author or authors. |
| 2 | + * Copyright 2012-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
31 | 31 | import org.springframework.beans.factory.annotation.Value;
|
32 | 32 | import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
33 | 33 | import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
| 34 | +import org.springframework.boot.autoconfigure.condition.scan.ScanBean; |
34 | 35 | import org.springframework.boot.autoconfigure.condition.scan.ScannedFactoryBeanConfiguration;
|
35 | 36 | import org.springframework.boot.autoconfigure.condition.scan.ScannedFactoryBeanWithBeanMethodArgumentsConfiguration;
|
36 | 37 | import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
|
60 | 61 | * @author Andy Wilkinson
|
61 | 62 | */
|
62 | 63 | @SuppressWarnings("resource")
|
63 |
| -public class ConditionalOnMissingBeanTests { |
| 64 | +class ConditionalOnMissingBeanTests { |
64 | 65 |
|
65 | 66 | private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
|
66 | 67 |
|
@@ -161,15 +162,15 @@ void testOnMissingBeanConditionWithComponentScannedFactoryBean() {
|
161 | 162 | this.contextRunner
|
162 | 163 | .withUserConfiguration(ComponentScannedFactoryBeanBeanMethodConfiguration.class,
|
163 | 164 | ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class)
|
164 |
| - .run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); |
| 165 | + .run((context) -> assertThat(context.getBean(ScanBean.class).toString()).isEqualTo("fromFactory")); |
165 | 166 | }
|
166 | 167 |
|
167 | 168 | @Test
|
168 | 169 | void testOnMissingBeanConditionWithComponentScannedFactoryBeanWithBeanMethodArguments() {
|
169 | 170 | this.contextRunner
|
170 | 171 | .withUserConfiguration(ComponentScannedFactoryBeanBeanMethodWithArgumentsConfiguration.class,
|
171 | 172 | ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class)
|
172 |
| - .run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); |
| 173 | + .run((context) -> assertThat(context.getBean(ScanBean.class).toString()).isEqualTo("fromFactory")); |
173 | 174 | }
|
174 | 175 |
|
175 | 176 | @Test
|
@@ -617,9 +618,9 @@ ExampleBean exampleBean2() {
|
617 | 618 |
|
618 | 619 | }
|
619 | 620 |
|
620 |
| - public static class ExampleFactoryBean implements FactoryBean<ExampleBean> { |
| 621 | + static class ExampleFactoryBean implements FactoryBean<ExampleBean> { |
621 | 622 |
|
622 |
| - public ExampleFactoryBean(String value) { |
| 623 | + ExampleFactoryBean(String value) { |
623 | 624 | Assert.state(!value.contains("$"), "value should not contain '$'");
|
624 | 625 | }
|
625 | 626 |
|
@@ -738,11 +739,11 @@ TestParameterizedContainer<CustomExampleBean> conditionalCustomExampleBean() {
|
738 | 739 | }
|
739 | 740 |
|
740 | 741 | @TestAnnotation
|
741 |
| - public static class ExampleBean { |
| 742 | + static class ExampleBean { |
742 | 743 |
|
743 | 744 | private String value;
|
744 | 745 |
|
745 |
| - public ExampleBean(String value) { |
| 746 | + ExampleBean(String value) { |
746 | 747 | this.value = value;
|
747 | 748 | }
|
748 | 749 |
|
|
0 commit comments