@Test
  public void testToJibContainerBuilder_setAppRootLate()
      throws URISyntaxException, IOException, InvalidImageReferenceException,
          CacheDirectoryCreationException {
    BuildContext buildContext =
        JavaContainerBuilder.from("scratch")
            .addClasses(getResource("core/application/classes"))
            .addResources(getResource("core/application/resources"))
            .addDependencies(getResource("core/application/dependencies/libraryA.jar"))
            .addToClasspath(getResource("core/fileA"))
            .setAppRoot("/different")
            .setMainClass("HelloWorld")
            .toContainerBuilder()
            .toBuildContext(Containerizer.to(RegistryImage.named("hello")));

    // Check entrypoint
    Assert.assertEquals(
        ImmutableList.of(
            "java",
            "-cp",
            "/different/classes:/different/resources:/different/libs/*:/different/classpath",
            "HelloWorld"),
        buildContext.getContainerConfiguration().getEntrypoint());

    // Check classes
    List<AbsoluteUnixPath> expectedClasses =
        ImmutableList.of(
            AbsoluteUnixPath.get("/different/classes/HelloWorld.class"),
            AbsoluteUnixPath.get("/different/classes/some.class"));
    Assert.assertEquals(expectedClasses, getExtractionPaths(buildContext, "classes"));

    // Check resources
    List<AbsoluteUnixPath> expectedResources =
        ImmutableList.of(
            AbsoluteUnixPath.get("/different/resources/resourceA"),
            AbsoluteUnixPath.get("/different/resources/resourceB"),
            AbsoluteUnixPath.get("/different/resources/world"));
    Assert.assertEquals(expectedResources, getExtractionPaths(buildContext, "resources"));

    // Check dependencies
    List<AbsoluteUnixPath> expectedDependencies =
        ImmutableList.of(AbsoluteUnixPath.get("/different/libs/libraryA.jar"));
    Assert.assertEquals(expectedDependencies, getExtractionPaths(buildContext, "dependencies"));

    Assert.assertEquals(expectedClasses, getExtractionPaths(buildContext, "classes"));

    // Check additional classpath files
    List<AbsoluteUnixPath> expectedOthers =
        ImmutableList.of(AbsoluteUnixPath.get("/different/classpath/fileA"));
    Assert.assertEquals(expectedOthers, getExtractionPaths(buildContext, "extra files"));
  }
Gets the extraction paths in the specified layer of a give {@link BuildContext}.
jib-core/src/test/java/com/google/cloud/tools/jib/api/JavaContainerBuilderTest.java