@Test
  public void testSteps_forBuildToDockerRegistry_skipExistingDigest()
      throws IOException, InterruptedException, ExecutionException, RegistryException,
          CacheDirectoryCreationException, InvalidImageReferenceException {
    System.setProperty(JibSystemProperties.SKIP_EXISTING_IMAGES, "true");

    JibContainer image1 =
        buildImage(
            ImageReference.scratch(),
            Containerizer.to(RegistryImage.named(dockerHost + ":5000/testimagerepo:testtag")),
            Collections.singletonList("testtag2"));

    // Test that the initial image with the original tag has been pushed.
    localRegistry.pull(dockerHost + ":5000/testimagerepo:testtag");
    // Test that any additional tags have also been pushed with the original image.
    localRegistry.pull(dockerHost + ":5000/testimagerepo:testtag2");

    // Push the same image with a different tag, with SKIP_EXISTING_IMAGES enabled.
    JibContainer image2 =
        buildImage(
            ImageReference.scratch(),
            Containerizer.to(RegistryImage.named(dockerHost + ":5000/testimagerepo:new_testtag")),
            Collections.emptyList());

    // Test that the pull request throws an exception, indicating that the new tag was not pushed.
    try {
      localRegistry.pull(dockerHost + ":5000/testimagerepo:new_testtag");
      Assert.fail(
          "jib.skipExistingImages was enabled and digest was already pushed, "
              + "hence new_testtag shouldn't have been pushed.");
    } catch (RuntimeException ex) {
      MatcherAssert.assertThat(
          ex.getMessage(),
          CoreMatchers.containsString(
              "manifest for " + dockerHost + ":5000/testimagerepo:new_testtag not found"));
    }

    // Test that both images have the same properties.
    Assert.assertEquals(image1.getDigest(), image2.getDigest());
    Assert.assertEquals(image1.getImageId(), image2.getImageId());

    // Test that the first image was pushed while the second one was skipped
    Assert.assertTrue(image1.isImagePushed());
    Assert.assertFalse(image2.isImagePushed());
  }
Lists the files in the {@code resourcePath} resources directory and builds a {@link
FileEntriesLayer} from those files.
jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ContainerizerIntegrationTest.java