Home / Class/ ConditionalOnThreadingTests Class — spring-boot Architecture

ConditionalOnThreadingTests Class — spring-boot Architecture

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

Entity Profile

Relationship Graph

Source Code

core/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnThreadingTests.java lines 35–91

class ConditionalOnThreadingTests {

	private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
		.withUserConfiguration(BasicConfiguration.class);

	@Test
	@EnabledForJreRange(max = JRE.JAVA_20)
	void platformThreadsOnJdkBelow21IfVirtualThreadsPropertyIsEnabled() {
		this.contextRunner.withPropertyValues("spring.threads.virtual.enabled=true")
			.run((context) -> assertThat(context.getBean(ThreadType.class)).isEqualTo(ThreadType.PLATFORM));
	}

	@Test
	@EnabledForJreRange(max = JRE.JAVA_20)
	void platformThreadsOnJdkBelow21IfVirtualThreadsPropertyIsDisabled() {
		this.contextRunner.withPropertyValues("spring.threads.virtual.enabled=false")
			.run((context) -> assertThat(context.getBean(ThreadType.class)).isEqualTo(ThreadType.PLATFORM));
	}

	@Test
	@EnabledForJreRange(min = JRE.JAVA_21)
	void virtualThreadsOnJdk21IfVirtualThreadsPropertyIsEnabled() {
		this.contextRunner.withPropertyValues("spring.threads.virtual.enabled=true")
			.run((context) -> assertThat(context.getBean(ThreadType.class)).isEqualTo(ThreadType.VIRTUAL));
	}

	@Test
	@EnabledForJreRange(min = JRE.JAVA_21)
	void platformThreadsOnJdk21IfVirtualThreadsPropertyIsDisabled() {
		this.contextRunner.withPropertyValues("spring.threads.virtual.enabled=false")
			.run((context) -> assertThat(context.getBean(ThreadType.class)).isEqualTo(ThreadType.PLATFORM));
	}

	private enum ThreadType {

		PLATFORM, VIRTUAL

	}

	@Configuration(proxyBeanMethods = false)
	static class BasicConfiguration {

		@Bean
		@ConditionalOnThreading(Threading.VIRTUAL)
		ThreadType virtual() {
			return ThreadType.VIRTUAL;
		}

		@Bean
		@ConditionalOnThreading(Threading.PLATFORM)
		ThreadType platform() {
			return ThreadType.PLATFORM;
		}

	}

}

Domain

Analyze Your Own Codebase

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

Try Supermodel Free