|
|
@ -34,6 +34,7 @@ import static org.mockito.BDDMockito.willCallRealMethod;
|
|
|
|
* Integration tests for {@link ConfigurationPropertiesScan}.
|
|
|
|
* Integration tests for {@link ConfigurationPropertiesScan}.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Madhura Bhave
|
|
|
|
* @author Madhura Bhave
|
|
|
|
|
|
|
|
* @author Johnny Lim
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ConfigurationPropertiesScanTests {
|
|
|
|
public class ConfigurationPropertiesScanTests {
|
|
|
|
|
|
|
|
|
|
|
@ -52,7 +53,7 @@ public class ConfigurationPropertiesScanTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void scanImportBeanRegistrarShouldBeEnvironmentAware() {
|
|
|
|
public void scanImportBeanRegistrarShouldBeEnvironmentAwareWithRequiredProfile() {
|
|
|
|
this.context.getEnvironment().addActiveProfile("test");
|
|
|
|
this.context.getEnvironment().addActiveProfile("test");
|
|
|
|
load(TestConfiguration.class);
|
|
|
|
load(TestConfiguration.class);
|
|
|
|
assertThat(this.context.containsBean(
|
|
|
|
assertThat(this.context.containsBean(
|
|
|
@ -61,7 +62,15 @@ public class ConfigurationPropertiesScanTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void scanImportBeanRegistrarShouldBeResourceLoaderAware() {
|
|
|
|
public void scanImportBeanRegistrarShouldBeEnvironmentAwareWithoutRequiredProfile() {
|
|
|
|
|
|
|
|
load(TestConfiguration.class);
|
|
|
|
|
|
|
|
assertThat(this.context.containsBean(
|
|
|
|
|
|
|
|
"profile-org.springframework.boot.context.properties.scan.valid.a.AScanConfiguration$MyProfileProperties"))
|
|
|
|
|
|
|
|
.isFalse();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void scanImportBeanRegistrarShouldBeResourceLoaderAwareWithRequiredResource() {
|
|
|
|
DefaultResourceLoader resourceLoader = Mockito.mock(DefaultResourceLoader.class);
|
|
|
|
DefaultResourceLoader resourceLoader = Mockito.mock(DefaultResourceLoader.class);
|
|
|
|
this.context.setResourceLoader(resourceLoader);
|
|
|
|
this.context.setResourceLoader(resourceLoader);
|
|
|
|
willCallRealMethod().given(resourceLoader).getClassLoader();
|
|
|
|
willCallRealMethod().given(resourceLoader).getClassLoader();
|
|
|
@ -73,6 +82,14 @@ public class ConfigurationPropertiesScanTests {
|
|
|
|
.isTrue();
|
|
|
|
.isTrue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void scanImportBeanRegistrarShouldBeResourceLoaderAwareWithoutRequiredResource() {
|
|
|
|
|
|
|
|
load(TestConfiguration.class);
|
|
|
|
|
|
|
|
assertThat(this.context.containsBean(
|
|
|
|
|
|
|
|
"resource-org.springframework.boot.context.properties.scan.valid.a.AScanConfiguration$MyResourceProperties"))
|
|
|
|
|
|
|
|
.isFalse();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void load(Class<?>... classes) {
|
|
|
|
private void load(Class<?>... classes) {
|
|
|
|
this.context.register(classes);
|
|
|
|
this.context.register(classes);
|
|
|
|
this.context.refresh();
|
|
|
|
this.context.refresh();
|
|
|
|