private void verifyTarArchive(TarArchiveInputStream tarArchiveInputStream) throws IOException {
    // Verifies fileA was archived correctly.
    TarArchiveEntry headerFileA = tarArchiveInputStream.getNextTarEntry();
    Assert.assertEquals("some/path/to/resourceFileA", headerFileA.getName());
    byte[] fileAString = ByteStreams.toByteArray(tarArchiveInputStream);
    Assert.assertArrayEquals(fileAContents, fileAString);

    // Verifies fileB was archived correctly.
    TarArchiveEntry headerFileB = tarArchiveInputStream.getNextTarEntry();
    Assert.assertEquals("crepecake", headerFileB.getName());
    byte[] fileBString = ByteStreams.toByteArray(tarArchiveInputStream);
    Assert.assertArrayEquals(fileBContents, fileBString);

    // Verifies directoryA was archived correctly.
    TarArchiveEntry headerDirectoryA = tarArchiveInputStream.getNextTarEntry();
    Assert.assertEquals("some/path/to/", headerDirectoryA.getName());

    // Verifies the long file was archived correctly.
    TarArchiveEntry headerFileALong = tarArchiveInputStream.getNextTarEntry();
    Assert.assertEquals(
        "some/really/long/path/that/exceeds/100/characters/abcdefghijklmnopqrstuvwxyz0123456789012345678901234567890",
        headerFileALong.getName());
    byte[] fileALongString = ByteStreams.toByteArray(tarArchiveInputStream);
    Assert.assertArrayEquals(fileAContents, fileALongString);

    Assert.assertNull(tarArchiveInputStream.getNextTarEntry());
  }
Helper method to verify that the files were archived correctly by reading {@code
tarArchiveInputStream}.
jib-core/src/test/java/com/google/cloud/tools/jib/tar/TarStreamBuilderTest.java