Home / Class/ ClassPathTests Class — spring-boot Architecture

ClassPathTests Class — spring-boot Architecture

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

Entity Profile

Source Code

build-plugin/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ClassPathTests.java lines 40–105

class ClassPathTests {

	@Test
	void argsWhenNoClassPathReturnsEmptyList() {
		assertThat(ClassPath.of(Collections.emptyList()).args(false)).isEmpty();
	}

	@Test
	void argsWhenSingleUrlOnWindowsUsesPath(@TempDir Path temp) throws Exception {
		Path path = temp.resolve("test.jar");
		ClassPath classPath = ClassPath.of(onWindows(), List.of(path.toUri().toURL()));
		assertThat(classPath.args(true)).containsExactly("-cp", path.toString());
	}

	@Test
	void argsWhenSingleUrlNotOnWindowsUsesPath(@TempDir Path temp) throws Exception {
		Path path = temp.resolve("test.jar");
		ClassPath classPath = ClassPath.of(onLinux(), List.of(path.toUri().toURL()));
		assertThat(classPath.args(true)).containsExactly("-cp", path.toString());
	}

	@Test
	void argsWhenMultipleUrlsOnWindowsAndAllowedUsesArgFile(@TempDir Path temp) throws Exception {
		Path path1 = temp.resolve("test1.jar");
		Path path2 = temp.resolve("test2.jar");
		ClassPath classPath = ClassPath.of(onWindows(), List.of(path1.toUri().toURL(), path2.toUri().toURL()));
		List<String> args = classPath.args(true);
		assertThat(args.get(0)).isEqualTo("-cp");
		assertThat(args.get(1)).startsWith("@");
		assertThat(Paths.get(args.get(1).substring(1)))
			.hasContent("\"" + (path1 + File.pathSeparator + path2).replace("\\", "\\\\") + "\"");
	}

	@Test
	void argsWhenMultipleUrlsOnWindowsAndNotAllowedUsesPath(@TempDir Path temp) throws Exception {
		Path path1 = temp.resolve("test1.jar");
		Path path2 = temp.resolve("test2.jar");
		ClassPath classPath = ClassPath.of(onWindows(), List.of(path1.toUri().toURL(), path2.toUri().toURL()));
		assertThat(classPath.args(false)).containsExactly("-cp", path1 + File.pathSeparator + path2);
	}

	@Test
	void argsWhenMultipleUrlsNotOnWindowsUsesPath(@TempDir Path temp) throws Exception {
		Path path1 = temp.resolve("test1.jar");
		Path path2 = temp.resolve("test2.jar");
		ClassPath classPath = ClassPath.of(onLinux(), List.of(path1.toUri().toURL(), path2.toUri().toURL()));
		assertThat(classPath.args(true)).containsExactly("-cp", path1 + File.pathSeparator + path2);
	}

	@Test
	void toStringShouldReturnClassPath(@TempDir Path temp) throws Exception {
		Path path1 = temp.resolve("test1.jar");
		Path path2 = temp.resolve("test2.jar");
		ClassPath classPath = ClassPath.of(onLinux(), List.of(path1.toUri().toURL(), path2.toUri().toURL()));
		assertThat(classPath.toString()).isEqualTo(path1 + File.pathSeparator + path2);
	}

	private UnaryOperator<@Nullable String> onWindows() {
		return Map.of("os.name", "windows")::get;
	}

	private UnaryOperator<@Nullable String> onLinux() {
		return Map.of("os.name", "linux")::get;
	}

}

Analyze Your Own Codebase

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

Try Supermodel Free