@VisibleForTesting
    void addUsrLibFolderToShipFiles(Collection<File> effectiveShipFiles) {
        // Add usrlib folder to the ship files if it exists
        // Classes in the folder will be loaded by UserClassLoader if CLASSPATH_INCLUDE_USER_JAR is
        // DISABLED.
        ClusterEntrypointUtils.tryFindUserLibDirectory()
                .ifPresent(
                        usrLibDirFile -> {
                            effectiveShipFiles.add(usrLibDirFile);
                            LOG.info(
                                    "usrlib: {} will be shipped automatically.",
                                    usrLibDirFile.getAbsolutePath());
                        });
    }
@Test
    void testShipUsrLib() throws IOException {
        final Map<String, String> oldEnv = System.getenv();
        final Map<String, String> env = new HashMap<>(1);
        final File homeFolder =
                Files.createTempDirectory(temporaryFolder, UUID.randomUUID().toString()).toFile();
        final File libFolder = new File(homeFolder.getAbsolutePath(), "lib");
        assertThat(libFolder.createNewFile()).isTrue();
        final File usrLibFolder =
                new File(homeFolder.getAbsolutePath(), ConfigConstants.DEFAULT_FLINK_USR_LIB_DIR);
        assertThat(usrLibFolder.mkdirs()).isTrue();
        final File usrLibFile = new File(usrLibFolder, "usrLibFile.jar");
        assertThat(usrLibFile.createNewFile()).isTrue();
        env.put(ConfigConstants.ENV_FLINK_LIB_DIR, libFolder.getAbsolutePath());
        CommonTestUtils.setEnv(env);

        try (YarnClusterDescriptor descriptor = createYarnClusterDescriptor()) {
            final Set<File> effectiveShipFiles = new HashSet<>();
            descriptor.addUsrLibFolderToShipFiles(effectiveShipFiles);
            assertThat(effectiveShipFiles).containsExactlyInAnyOrder(usrLibFolder);
        } finally {
            CommonTestUtils.setEnv(oldEnv);
        }
    }