Home / Class/ ContentTests Class — spring-boot Architecture

ContentTests Class — spring-boot Architecture

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

Entity Profile

Source Code

buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/ContentTests.java lines 35–85

class ContentTests {

	@Test
	@SuppressWarnings("NullAway") // Test null check
	void ofWhenSupplierIsNullThrowsException() {
		assertThatIllegalArgumentException().isThrownBy(() -> Content.of(1, (IOSupplier<InputStream>) null))
			.withMessage("'supplier' must not be null");
	}

	@Test
	void ofWhenStreamReturnsWritable() throws Exception {
		byte[] bytes = { 1, 2, 3, 4 };
		ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
		Content writable = Content.of(4, () -> inputStream);
		assertThat(writeToAndGetBytes(writable)).isEqualTo(bytes);
	}

	@Test
	@SuppressWarnings("NullAway") // Test null check
	void ofWhenStringIsNullThrowsException() {
		assertThatIllegalArgumentException().isThrownBy(() -> Content.of((String) null))
			.withMessage("'string' must not be null");
	}

	@Test
	void ofWhenStringReturnsWritable() throws Exception {
		Content writable = Content.of("spring");
		assertThat(writeToAndGetBytes(writable)).isEqualTo("spring".getBytes(StandardCharsets.UTF_8));
	}

	@Test
	@SuppressWarnings("NullAway") // Test null check
	void ofWhenBytesIsNullThrowsException() {
		assertThatIllegalArgumentException().isThrownBy(() -> Content.of((byte[]) null))
			.withMessage("'bytes' must not be null");
	}

	@Test
	void ofWhenBytesReturnsWritable() throws Exception {
		byte[] bytes = { 1, 2, 3, 4 };
		Content writable = Content.of(bytes);
		assertThat(writeToAndGetBytes(writable)).isEqualTo(bytes);
	}

	private byte[] writeToAndGetBytes(Content writable) throws IOException {
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		writable.writeTo(outputStream);
		return outputStream.toByteArray();
	}

}

Analyze Your Own Codebase

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

Try Supermodel Free