Home / Class/ StandardConfigDataLoaderTests Class — spring-boot Architecture

StandardConfigDataLoaderTests Class — spring-boot Architecture

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

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/test/java/org/springframework/boot/context/config/StandardConfigDataLoaderTests.java lines 38–80

class StandardConfigDataLoaderTests {

	private final StandardConfigDataLoader loader = new StandardConfigDataLoader();

	private final ConfigDataLoaderContext loaderContext = mock(ConfigDataLoaderContext.class);

	@Test
	@WithResource(name = "application.yml", content = """
			foo: bar
			---
			hello: world
			""")
	void loadWhenLocationResultsInMultiplePropertySourcesAddsAllToConfigData() throws IOException {
		ClassPathResource resource = new ClassPathResource("application.yml");
		StandardConfigDataReference reference = new StandardConfigDataReference(
				ConfigDataLocation.of("classpath:application.yml"), null, "classpath:application", null, "yml",
				new YamlPropertySourceLoader(), null);
		StandardConfigDataResource location = new StandardConfigDataResource(reference, resource);
		ConfigData configData = this.loader.load(this.loaderContext, location);
		assertThat(configData.getPropertySources()).hasSize(2);
		PropertySource<?> source1 = configData.getPropertySources().get(0);
		PropertySource<?> source2 = configData.getPropertySources().get(1);
		assertThat(source1.getName()).isEqualTo("Config resource 'class path resource [application.yml]' "
				+ "via location 'classpath:application.yml' (document #0)");
		assertThat(source1.getProperty("foo")).isEqualTo("bar");
		assertThat(source2.getName()).isEqualTo("Config resource 'class path resource [application.yml]' "
				+ "via location 'classpath:application.yml' (document #1)");
		assertThat(source2.getProperty("hello")).isEqualTo("world");
	}

	@Test
	@WithResource(name = "empty.properties")
	void loadWhenPropertySourceIsEmptyAddsNothingToConfigData() throws IOException {
		ClassPathResource resource = new ClassPathResource("empty.properties");
		StandardConfigDataReference reference = new StandardConfigDataReference(
				ConfigDataLocation.of("empty.properties"), null, "empty", null, "properties",
				new PropertiesPropertySourceLoader(), null);
		StandardConfigDataResource location = new StandardConfigDataResource(reference, resource);
		ConfigData configData = this.loader.load(this.loaderContext, location);
		assertThat(configData.getPropertySources()).isEmpty();
	}

}

Domain

Analyze Your Own Codebase

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

Try Supermodel Free