Home / Class/ ConfigurationPropertiesAutoConfigurationTests Class — spring-boot Architecture

ConfigurationPropertiesAutoConfigurationTests Class — spring-boot Architecture

Architecture documentation for the ConfigurationPropertiesAutoConfigurationTests class in ConfigurationPropertiesAutoConfigurationTests.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

core/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfigurationTests.java lines 37–94

class ConfigurationPropertiesAutoConfigurationTests {

	private @Nullable AnnotationConfigApplicationContext context;

	@AfterEach
	void tearDown() {
		if (this.context != null) {
			this.context.close();
		}
	}

	@Test
	void processAnnotatedBean() {
		load(new Class<?>[] { AutoConfig.class, SampleBean.class }, "foo.name:test");
		assertThat(getBean().getName()).isEqualTo("test");
	}

	@Test
	void processAnnotatedBeanNoAutoConfig() {
		load(new Class<?>[] { SampleBean.class }, "foo.name:test");
		assertThat(getBean().getName()).isEqualTo("default");
	}

	private void load(Class<?>[] configs, String... environment) {
		this.context = new AnnotationConfigApplicationContext();
		this.context.register(configs);
		TestPropertyValues.of(environment).applyTo(this.context);
		this.context.refresh();
	}

	private SampleBean getBean() {
		assertThat(this.context).isNotNull();
		return this.context.getBean(SampleBean.class);
	}

	@Configuration(proxyBeanMethods = false)
	@ImportAutoConfiguration(ConfigurationPropertiesAutoConfiguration.class)
	static class AutoConfig {

	}

	@Component
	@ConfigurationProperties("foo")
	static class SampleBean {

		private String name = "default";

		String getName() {
			return this.name;
		}

		void setName(String name) {
			this.name = name;
		}

	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free