Home / Class/ ConfigTreeConfigDataLocationResolverTests Class — spring-boot Architecture

ConfigTreeConfigDataLocationResolverTests Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigTreeConfigDataLocationResolverTests.java lines 37–84

class ConfigTreeConfigDataLocationResolverTests {

	private final ConfigTreeConfigDataLocationResolver resolver = new ConfigTreeConfigDataLocationResolver(
			new DefaultResourceLoader());

	private final ConfigDataLocationResolverContext context = mock(ConfigDataLocationResolverContext.class);

	@TempDir
	@SuppressWarnings("NullAway.Init")
	File temp;

	@Test
	void isResolvableWhenPrefixMatchesReturnsTrue() {
		assertThat(this.resolver.isResolvable(this.context, ConfigDataLocation.of("configtree:/etc/config"))).isTrue();
	}

	@Test
	void isResolvableWhenPrefixDoesNotMatchReturnsFalse() {
		assertThat(this.resolver.isResolvable(this.context, ConfigDataLocation.of("http://etc/config"))).isFalse();
		assertThat(this.resolver.isResolvable(this.context, ConfigDataLocation.of("/etc/config"))).isFalse();
	}

	@Test
	void resolveReturnsConfigVolumeMountLocation() {
		List<ConfigTreeConfigDataResource> locations = this.resolver.resolve(this.context,
				ConfigDataLocation.of("configtree:/etc/config/"));
		assertThat(locations).hasSize(1);
		assertThat(locations).extracting(Object::toString)
			.containsExactly("config tree [" + new File("/etc/config").getAbsolutePath() + "]");
	}

	@Test
	void resolveWildcardPattern() throws Exception {
		File directoryA = new File(this.temp, "a");
		File directoryB = new File(this.temp, "b");
		directoryA.mkdirs();
		directoryB.mkdirs();
		FileCopyUtils.copy("test".getBytes(), new File(directoryA, "spring"));
		FileCopyUtils.copy("test".getBytes(), new File(directoryB, "boot"));
		List<ConfigTreeConfigDataResource> locations = this.resolver.resolve(this.context,
				ConfigDataLocation.of("configtree:" + this.temp.getAbsolutePath() + "/*/"));
		assertThat(locations).hasSize(2);
		assertThat(locations).extracting(Object::toString)
			.containsExactly("config tree [" + directoryA.getAbsolutePath() + "]",
					"config tree [" + directoryB.getAbsolutePath() + "]");
	}

}

Analyze Your Own Codebase

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

Try Supermodel Free