Home / Class/ BackCompatibilityBinderIntegrationTests Class — spring-boot Architecture

BackCompatibilityBinderIntegrationTests Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BackCompatibilityBinderIntegrationTests.java lines 36–90

class BackCompatibilityBinderIntegrationTests {

	@Test
	void bindWhenBindingCamelCaseToEnvironmentWithExtractUnderscore() {
		// gh-10873
		MockEnvironment environment = new MockEnvironment();
		SystemEnvironmentPropertySource propertySource = new SystemEnvironmentPropertySource(
				StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
				Collections.singletonMap("FOO_ZK_NODES", "foo"));
		environment.getPropertySources().addFirst(propertySource);
		ExampleCamelCaseBean result = Binder.get(environment)
			.bind("foo", Bindable.of(ExampleCamelCaseBean.class))
			.get();
		assertThat(result.getZkNodes()).isEqualTo("foo");
	}

	@Test
	void bindWhenUsingSystemEnvironmentToOverride() {
		MockEnvironment environment = new MockEnvironment();
		SystemEnvironmentPropertySource propertySource = new SystemEnvironmentPropertySource("override",
				Collections.singletonMap("foo.password", "test"));
		environment.getPropertySources().addFirst(propertySource);
		PasswordProperties result = Binder.get(environment).bind("foo", Bindable.of(PasswordProperties.class)).get();
		assertThat(result.getPassword()).isEqualTo("test");
	}

	static class ExampleCamelCaseBean {

		private @Nullable String zkNodes;

		@Nullable String getZkNodes() {
			return this.zkNodes;
		}

		void setZkNodes(@Nullable String zkNodes) {
			this.zkNodes = zkNodes;
		}

	}

	static class PasswordProperties {

		private @Nullable String password;

		@Nullable String getPassword() {
			return this.password;
		}

		void setPassword(@Nullable String password) {
			this.password = password;
		}

	}

}

Analyze Your Own Codebase

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

Try Supermodel Free