Home / Function/ commandLinePropertySourceEnhancesEnvironment() — spring-boot Function Reference

commandLinePropertySourceEnhancesEnvironment() — spring-boot Function Reference

Architecture documentation for the commandLinePropertySourceEnhancesEnvironment() function in SpringApplicationTests.java from the spring-boot codebase.

Entity Profile

Dependency Diagram

graph TD
  6cab1961_31ea_6f51_7ced_1b916c5a5a2b["commandLinePropertySourceEnhancesEnvironment()"]
  6e69498f_9e4b_668b_1683_67bcc2555f34["matchingPropertySource()"]
  6cab1961_31ea_6f51_7ced_1b916c5a5a2b -->|calls| 6e69498f_9e4b_668b_1683_67bcc2555f34
  26640d57_69c1_a220_7428_6c3de4cab3f3["matches()"]
  6cab1961_31ea_6f51_7ced_1b916c5a5a2b -->|calls| 26640d57_69c1_a220_7428_6c3de4cab3f3
  3613e214_49bf_015b_c43f_7f8a1274fb0b["run()"]
  6cab1961_31ea_6f51_7ced_1b916c5a5a2b -->|calls| 3613e214_49bf_015b_c43f_7f8a1274fb0b
  style 6cab1961_31ea_6f51_7ced_1b916c5a5a2b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

core/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java lines 486–508

	@Test
	void commandLinePropertySourceEnhancesEnvironment() {
		SpringApplication application = new SpringApplication(ExampleConfig.class);
		application.setWebApplicationType(WebApplicationType.NONE);
		ConfigurableEnvironment environment = new StandardEnvironment();
		environment.getPropertySources()
			.addFirst(new MapPropertySource("commandLineArgs", Collections.singletonMap("foo", "original")));
		application.setEnvironment(environment);
		this.context = application.run("--foo=bar", "--bar=foo");
		assertThat(environment).has(matchingPropertySource(CompositePropertySource.class, "commandLineArgs"));
		assertThat(environment.getProperty("bar")).isEqualTo("foo");
		// New command line properties take precedence
		assertThat(environment.getProperty("foo")).isEqualTo("bar");
		CompositePropertySource composite = (CompositePropertySource) environment.getPropertySources()
			.get("commandLineArgs");
		assertThat(composite).isNotNull();
		assertThat(composite.getPropertySources()).hasSize(2);
		assertThat(composite.getPropertySources()).first()
			.matches((source) -> source.getName().equals("springApplicationCommandLineArgs"),
					"is named springApplicationCommandLineArgs");
		assertThat(composite.getPropertySources()).element(1)
			.matches((source) -> source.getName().equals("commandLineArgs"), "is named commandLineArgs");
	}

Domain

Subdomains

Frequently Asked Questions

What does commandLinePropertySourceEnhancesEnvironment() do?
commandLinePropertySourceEnhancesEnvironment() is a function in the spring-boot codebase.
What does commandLinePropertySourceEnhancesEnvironment() call?
commandLinePropertySourceEnhancesEnvironment() calls 3 function(s): matches, matchingPropertySource, run.

Analyze Your Own Codebase

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

Try Supermodel Free