InspectedContentTests Class — spring-boot Architecture
Architecture documentation for the InspectedContentTests class in InspectedContentTests.java from the spring-boot codebase.
Entity Profile
Source Code
buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/InspectedContentTests.java lines 37–113
class InspectedContentTests {
@Test
@SuppressWarnings("NullAway") // Test null check
void ofWhenInputStreamThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> InspectedContent.of((InputStream) null))
.withMessage("'inputStream' must not be null");
}
@Test
@SuppressWarnings("NullAway") // Test null check
void ofWhenContentIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> InspectedContent.of((Content) null))
.withMessage("'content' must not be null");
}
@Test
@SuppressWarnings("NullAway") // Test null check
void ofWhenConsumerIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> InspectedContent.of((IOConsumer<OutputStream>) null))
.withMessage("'writer' must not be null");
}
@Test
void ofFromContent() throws Exception {
InspectedContent content = InspectedContent.of(Content.of("test"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
content.writeTo(outputStream);
assertThat(outputStream.toByteArray()).containsExactly("test".getBytes(StandardCharsets.UTF_8));
}
@Test
void ofSmallContent() throws Exception {
InputStream inputStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 });
InspectedContent content = InspectedContent.of(inputStream);
assertThat(content.size()).isEqualTo(3);
assertThat(readBytes(content)).containsExactly(0, 1, 2);
}
@Test
void ofLargeContent() throws Exception {
byte[] bytes = new byte[InspectedContent.MEMORY_LIMIT + 3];
System.arraycopy(new byte[] { 0, 1, 2 }, 0, bytes, 0, 3);
InputStream inputStream = new ByteArrayInputStream(bytes);
InspectedContent content = InspectedContent.of(inputStream);
assertThat(content.size()).isEqualTo(bytes.length);
assertThat(readBytes(content)).isEqualTo(bytes);
}
@Test
void ofWithInspector() throws Exception {
InputStream inputStream = new ByteArrayInputStream("test".getBytes(StandardCharsets.UTF_8));
MessageDigest digest = MessageDigest.getInstance("SHA-256");
InspectedContent.of(inputStream, digest::update);
assertThat(digest.digest()).inHexadecimal()
.contains(0x9f, 0x86, 0xd0, 0x81, 0x88, 0x4c, 0x7d, 0x65, 0x9a, 0x2f, 0xea, 0xa0, 0xc5, 0x5a, 0xd0, 0x15,
0xa3, 0xbf, 0x4f, 0x1b, 0x2b, 0x0b, 0x82, 0x2c, 0xd1, 0x5d, 0x6c, 0x15, 0xb0, 0xf0, 0x0a, 0x08);
}
@Test
void ofWritingSingleBytesShouldWork() throws Exception {
InspectedContent content = InspectedContent.of((outputStream) -> {
outputStream.write('A');
outputStream.write('B');
outputStream.write('C');
});
assertThat(content.size()).isEqualTo(3);
assertThat(readBytes(content)).containsExactly('A', 'B', 'C');
}
private byte[] readBytes(InspectedContent content) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
content.writeTo(outputStream);
return outputStream.toByteArray();
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free