Search in sources :

Example 1 with FileUtils

use of org.apache.flink.util.FileUtils in project flink by apache.

the class AbstractUserClassPathJobGraphRetrieverTest method testGetUserClassPath.

@Test
public void testGetUserClassPath() throws IOException {
    final File testJobDir = temporaryFolder.newFolder("_test_job");
    final Collection<Path> testFiles = FileUtilsTest.prepareTestFiles(testJobDir.toPath());
    final Path currentWorkingDirectory = FileUtils.getCurrentWorkingDirectory();
    final TestJobGraphRetriever testJobGraphRetriever = new TestJobGraphRetriever(testJobDir);
    assertThat(testJobGraphRetriever.getUserClassPaths(), containsInAnyOrder(testFiles.stream().map(file -> FileUtils.relativizePath(currentWorkingDirectory, file)).map(FunctionUtils.uncheckedFunction(FileUtils::toURL)).toArray()));
}
Also used : Path(java.nio.file.Path) FileUtils(org.apache.flink.util.FileUtils) File(java.io.File) Test(org.junit.Test) FileUtilsTest(org.apache.flink.util.FileUtilsTest)

Example 2 with FileUtils

use of org.apache.flink.util.FileUtils in project flink by apache.

the class DefaultPackagedProgramRetriever method getClasspathsFromUserLibDir.

private static List<URL> getClasspathsFromUserLibDir(@Nullable File userLibDir) throws IOException {
    if (userLibDir == null) {
        return Collections.emptyList();
    }
    final Path workingDirectory = FileUtils.getCurrentWorkingDirectory();
    final List<URL> relativeJarURLs = FileUtils.listFilesInDirectory(userLibDir.toPath(), FileUtils::isJarFile).stream().map(path -> FileUtils.relativizePath(workingDirectory, path)).map(FunctionUtils.uncheckedFunction(FileUtils::toURL)).collect(Collectors.toList());
    return Collections.unmodifiableList(relativeJarURLs);
}
Also used : Path(java.nio.file.Path) FileUtils(org.apache.flink.util.FileUtils) URL(java.net.URL)

Aggregations

Path (java.nio.file.Path)2 FileUtils (org.apache.flink.util.FileUtils)2 File (java.io.File)1 URL (java.net.URL)1 FileUtilsTest (org.apache.flink.util.FileUtilsTest)1 Test (org.junit.Test)1