Home / Class/ TarLayoutWriterTests Class — spring-boot Architecture

TarLayoutWriterTests Class — spring-boot Architecture

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

Entity Profile

Source Code

buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/io/TarLayoutWriterTests.java lines 36–66

class TarLayoutWriterTests {

	@Test
	void writesTarArchive() throws Exception {
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		try (TarLayoutWriter writer = new TarLayoutWriter(outputStream)) {
			writer.directory("/foo", Owner.ROOT);
			writer.file("/foo/bar.txt", Owner.of(1, 1), 0777, Content.of("test"));
		}
		try (TarArchiveInputStream tarInputStream = new TarArchiveInputStream(
				new ByteArrayInputStream(outputStream.toByteArray()))) {
			TarArchiveEntry directoryEntry = tarInputStream.getNextEntry();
			TarArchiveEntry fileEntry = tarInputStream.getNextEntry();
			byte[] fileContent = new byte[(int) fileEntry.getSize()];
			tarInputStream.read(fileContent);
			assertThat(tarInputStream.getNextEntry()).isNull();
			assertThat(directoryEntry.getName()).isEqualTo("/foo/");
			assertThat(directoryEntry.getMode()).isEqualTo(0755);
			assertThat(directoryEntry.getLongUserId()).isZero();
			assertThat(directoryEntry.getLongGroupId()).isZero();
			assertThat(directoryEntry.getModTime()).isEqualTo(new Date(TarLayoutWriter.NORMALIZED_MOD_TIME));
			assertThat(fileEntry.getName()).isEqualTo("/foo/bar.txt");
			assertThat(fileEntry.getMode()).isEqualTo(0777);
			assertThat(fileEntry.getLongUserId()).isOne();
			assertThat(fileEntry.getLongGroupId()).isOne();
			assertThat(fileEntry.getModTime()).isEqualTo(new Date(TarLayoutWriter.NORMALIZED_MOD_TIME));
			assertThat(fileContent).isEqualTo("test".getBytes(StandardCharsets.UTF_8));
		}
	}

}

Analyze Your Own Codebase

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

Try Supermodel Free