jdk.testlibrary.FileUtils Java Examples

The following examples show how to use jdk.testlibrary.FileUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JmodNegativeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testFileInModulePath() throws IOException {
    Path jmod = MODS_DIR.resolve("output.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    Path file = MODS_DIR.resolve("testFileInModulePath.txt");
    FileUtils.deleteFileIfExistsWithRetry(file);
    Files.createFile(file);

    jmod("create",
         "--hash-modules", ".*",
         "--module-path", file.toString(),
         jmod.toString())
        .assertFailure()
        .resultChecker(r ->
            assertContains(r.output, "Error: path must be a directory")
        );
}
 
Example #2
Source File: UserModuleTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@BeforeTest
public void compileAll() throws Throwable {
    if (!hasJmods()) return;

    for (String mn : modules) {
        Path msrc = SRC_DIR.resolve(mn);
        assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
            "--module-source-path", SRC_DIR.toString(),
            "--add-exports", "java.base/jdk.internal.module=" + mn,
            "--add-exports", "java.base/jdk.internal.org.objectweb.asm=" + mn));
    }

    if (Files.exists(IMAGE)) {
        FileUtils.deleteFileTreeUnchecked(IMAGE);
    }

    createImage(IMAGE, "m1", "m3");

    createJmods("m1", "m4");
}
 
Example #3
Source File: Basic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@AfterClass
public void cleanup() throws IOException {
    Files.walk(userdir, 1)
            .filter(p -> !p.equals(userdir))
            .forEach(p -> {
                try {
                    if (Files.isDirectory(p)) {
                        FileUtils.deleteFileTreeWithRetry(p);
                    } else {
                        FileUtils.deleteFileIfExistsWithRetry(p);
                    }
                } catch (IOException x) {
                    throw new UncheckedIOException(x);
                }
            });
}
 
Example #4
Source File: JmodNegativeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testEmptyFileInModulePath() throws IOException {
    Path jmod = MODS_DIR.resolve("output.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    Path empty = MODS_DIR.resolve("emptyFile.jmod");
    FileUtils.deleteFileIfExistsWithRetry(empty);
    Files.createFile(empty);
    try {
        String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString();

        jmod("create",
             "--class-path", cp,
             "--hash-modules", ".*",
             "--module-path", MODS_DIR.toString(),
             jmod.toString())
            .assertFailure();
    } finally {
        FileUtils.deleteFileWithRetry(empty);
    }
}
 
Example #5
Source File: CLICompatibility.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void extractReadFromStdin() throws IOException {
    Path path = Paths.get("extract");
    Path jarPath = path.resolve("extractReadFromStdin.jar"); // for extracting
    createJar(jarPath, RES1);

    for (String opts : new String[]{"x" ,"-x", "--extract"}) {
        if (legacyOnly && opts.startsWith("--"))
            continue;

        jarWithStdinAndWorkingDir(jarPath.toFile(), path.toFile(), opts)
            .assertSuccess()
            .resultChecker(r ->
                assertTrue(Files.exists(path.resolve(RES1)),
                           "Expected to find:" + path.resolve(RES1))
            );
        FileUtils.deleteFileIfExistsWithRetry(path.resolve(RES1));
    }
    FileUtils.deleteFileTreeWithRetry(path);
}
 
Example #6
Source File: CLICompatibility.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void listReadFromStdinWriteToStdout() throws IOException {
    Path path = Paths.get("listReadFromStdinWriteToStdout.jar");
    createJar(path, RES1);

    for (String opts : new String[]{"t", "-t", "--list"} ){
        if (legacyOnly && opts.startsWith("--"))
            continue;

        jarWithStdin(path.toFile(), opts)
            .assertSuccess()
            .resultChecker(r ->
                assertTrue(r.output.contains("META-INF/MANIFEST.MF") && r.output.contains(RES1),
                           "Failed, got [" + r.output + "]")
            );
    }
    FileUtils.deleteFileIfExistsWithRetry(path);
}
 
Example #7
Source File: CLICompatibility.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void listReadFromFileWriteToStdout() throws IOException {
    Path path = Paths.get("listReadFromFileWriteToStdout.jar");  // for listing
    createJar(path, RES1);
    String jn = path.toString();

    for (String opts : new String[]{"tf " + jn, "-tf " + jn, "--list --file " + jn}) {
        if (legacyOnly && opts.startsWith("--"))
            continue;

        jar(opts)
            .assertSuccess()
            .resultChecker(r ->
                assertTrue(r.output.contains("META-INF/MANIFEST.MF") && r.output.contains(RES1),
                           "Failed, got [" + r.output + "]")
            );
    }
    FileUtils.deleteFileIfExistsWithRetry(path);
}
 
Example #8
Source File: CLICompatibility.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void extractReadFromFile() throws IOException {
    Path path = Paths.get("extract");
    String jn = "extractReadFromFile.jar";
    Path jarPath = path.resolve(jn);
    createJar(jarPath, RES1);

    for (String opts : new String[]{"xf "+jn ,"-xf "+jn, "--extract --file "+jn}) {
        if (legacyOnly && opts.startsWith("--"))
            continue;

        jarWithStdinAndWorkingDir(null, path.toFile(), opts)
            .assertSuccess()
            .resultChecker(r ->
                assertTrue(Files.exists(path.resolve(RES1)),
                           "Expected to find:" + path.resolve(RES1))
            );
        FileUtils.deleteFileIfExistsWithRetry(path.resolve(RES1));
    }
    FileUtils.deleteFileTreeWithRetry(path);
}
 
Example #9
Source File: JmodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@BeforeTest
public void buildExplodedModules() throws IOException {
    if (Files.exists(EXPLODED_DIR))
        FileUtils.deleteFileTreeWithRetry(EXPLODED_DIR);

    for (String name : new String[] { "foo"/*, "bar", "baz"*/ } ) {
        Path dir = EXPLODED_DIR.resolve(name);
        assertTrue(compileModule(name, dir.resolve("classes")));
        copyResource(SRC_DIR.resolve("foo"),
                     dir.resolve("classes"),
                     "jdk/test/foo/resources/foo.properties");
        createCmds(dir.resolve("bin"));
        createLibs(dir.resolve("lib"));
        createConfigs(dir.resolve("conf"));
    }

    if (Files.exists(MODS_DIR))
        FileUtils.deleteFileTreeWithRetry(MODS_DIR);
    Files.createDirectories(MODS_DIR);
}
 
Example #10
Source File: JmodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testMissingPackages() throws IOException {
    Path apaDir = EXPLODED_DIR.resolve("apa");
    Path classesDir = EXPLODED_DIR.resolve("apa").resolve("classes");
    if (Files.exists(classesDir))
        FileUtils.deleteFileTreeWithRetry(classesDir);
    assertTrue(compileModule("apa", classesDir));
    FileUtils.deleteFileTreeWithRetry(classesDir.resolve("jdk"));
    Path jmod = MODS_DIR.resolve("apa.jmod");
    jmod("create",
         "--class-path", classesDir.toString(),
         jmod.toString())
        .assertFailure()
        .resultChecker(r -> {
            assertContains(r.output, "Packages that are exported or open in apa are not present: [jdk.test.apa]");
        });
    if (Files.exists(classesDir))
        FileUtils.deleteFileTreeWithRetry(classesDir);
}
 
Example #11
Source File: JmodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testMainClass() throws IOException {
    Path jmod = MODS_DIR.resolve("fooMainClass.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString();

    jmod("create",
         "--class-path", cp,
         "--main-class", "jdk.test.foo.Foo",
         jmod.toString())
        .assertSuccess()
        .resultChecker(r -> {
            Optional<String> omc = getModuleDescriptor(jmod).mainClass();
            assertTrue(omc.isPresent());
            assertEquals(omc.get(), "jdk.test.foo.Foo");
        });
}
 
Example #12
Source File: MultiThreadedReadTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    createZipFile();
    try (ZipFile zf = new ZipFile(new File(ZIPFILE_NAME))) {
        is = zf.getInputStream(zf.getEntry(ZIPENTRY_NAME));
        Thread[] threadArray = new Thread[NUM_THREADS];
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i] = new MultiThreadedReadTest();
        }
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i].start();
        }
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i].join();
        }
    } finally {
        long t = System.currentTimeMillis();
        FileUtils.deleteFileIfExistsWithRetry(Paths.get(ZIPFILE_NAME));
        System.out.println("Deleting zip file took:" +
                (System.currentTimeMillis() - t) + "ms");
    }
}
 
Example #13
Source File: JmodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testCmds() throws IOException {
    Path jmod = MODS_DIR.resolve("fooCmds.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    Path cp = EXPLODED_DIR.resolve("foo").resolve("classes");
    Path bp = EXPLODED_DIR.resolve("foo").resolve("bin");

    jmod("create",
         "--cmds", bp.toString(),
         "--class-path", cp.toString(),
         jmod.toString())
        .assertSuccess()
        .resultChecker(r -> {
            try (Stream<String> s1 = findFiles(bp).map(p -> CMDS_PREFIX + p);
                 Stream<String> s2 = findFiles(cp).map(p -> CLASSES_PREFIX + p)) {
                Set<String> expectedFilenames = Stream.concat(s1,s2)
                                                      .collect(toSet());
                assertJmodContent(jmod, expectedFilenames);
            }
        });
}
 
Example #14
Source File: JmodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testLibs() throws IOException {
    Path jmod = MODS_DIR.resolve("fooLibs.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    Path cp = EXPLODED_DIR.resolve("foo").resolve("classes");
    Path lp = EXPLODED_DIR.resolve("foo").resolve("lib");

    jmod("create",
         "--libs=", lp.toString(),
         "--class-path", cp.toString(),
         jmod.toString())
        .assertSuccess()
        .resultChecker(r -> {
            try (Stream<String> s1 = findFiles(lp).map(p -> LIBS_PREFIX + p);
                 Stream<String> s2 = findFiles(cp).map(p -> CLASSES_PREFIX + p)) {
                Set<String> expectedFilenames = Stream.concat(s1,s2)
                                                      .collect(toSet());
                assertJmodContent(jmod, expectedFilenames);
            }
        });
}
 
Example #15
Source File: MultiThreadedReadTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    createZipFile();
    try (ZipFile zf = new ZipFile(new File(ZIPFILE_NAME))) {
        is = zf.getInputStream(zf.getEntry(ZIPENTRY_NAME));
        Thread[] threadArray = new Thread[NUM_THREADS];
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i] = new MultiThreadedReadTest();
        }
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i].start();
        }
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i].join();
        }
    } finally {
        FileUtils.deleteFileIfExistsWithRetry(Paths.get(ZIPFILE_NAME));
    }
}
 
Example #16
Source File: CLICompatibility.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void updateReadStdinWriteStdout() throws IOException {
    Path path = Paths.get("updateReadStdinWriteStdout.jar");

    for (String opts : new String[]{"u", "-u", "--update"}) {
        if (legacyOnly && opts.startsWith("--"))
            continue;

        createJar(path, RES1);
        jarWithStdin(path.toFile(), opts, RES2)
            .assertSuccess()
            .resultChecker(r -> {
                ASSERT_CONTAINS_RES1.accept(r.stdoutAsStream());
                ASSERT_CONTAINS_RES2.accept(r.stdoutAsStream());
                ASSERT_CONTAINS_MAINFEST.accept(r.stdoutAsStream());
            });
    }
    FileUtils.deleteFileIfExistsWithRetry(path);
}
 
Example #17
Source File: CLICompatibility.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void updateReadFileWriteFile() throws IOException {
    Path path = Paths.get("updateReadWriteStdout.jar");  // for updating
    String jn = path.toString();

    for (String opts : new String[]{"uf " + jn, "-uf " + jn, "--update --file=" + jn}) {
        if (legacyOnly && opts.startsWith("--"))
            continue;

        createJar(path, RES1);
        jar(opts, RES2)
            .assertSuccess()
            .resultChecker(r -> {
                ASSERT_CONTAINS_RES1.accept(Files.newInputStream(path));
                ASSERT_CONTAINS_RES2.accept(Files.newInputStream(path));
                ASSERT_CONTAINS_MAINFEST.accept(Files.newInputStream(path));
            });
    }
    FileUtils.deleteFileIfExistsWithRetry(path);
}
 
Example #18
Source File: Basic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
// assure that basic nested classes are acceptable
public void test10() throws Throwable {
    String jarfile = "test.jar";

    compile("test01");  //use same data as test01

    Path classes = Paths.get("classes");

    // add a base class with a nested class
    Path source = Paths.get(src, "data", "test10", "base", "version");
    javac(classes.resolve("base"), source.resolve("Nested.java"));

    // add a versioned class with a nested class
    source = Paths.get(src, "data", "test10", "v9", "version");
    javac(classes.resolve("v9"), source.resolve("Nested.java"));

    jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
            "--release", "9", "-C", classes.resolve("v9").toString(), ".")
            .shouldHaveExitValue(SUCCESS);

    FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
    FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
}
 
Example #19
Source File: Basic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
// a class with an internal name different from the external name
public void test09() throws Throwable {
    String jarfile = "test.jar";

    compile("test01");  //use same data as test01

    Path classes = Paths.get("classes");

    Path base = classes.resolve("base").resolve("version");

    Files.copy(base.resolve("Main.class"), base.resolve("Foo.class"));

    jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
            "--release", "9", "-C", classes.resolve("v9").toString(), ".")
            .shouldNotHaveExitValue(SUCCESS)
            .shouldContain("names do not match");

    FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
    FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
}
 
Example #20
Source File: JmodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testIgnoreModuleInfoInOtherSections() throws IOException {
    Path jmod = MODS_DIR.resolve("testIgnoreModuleInfoInOtherSections.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString();

    jmod("create",
        "--class-path", cp,
        "--libs", cp,
        jmod.toString())
        .assertSuccess()
        .resultChecker(r ->
            assertContains(r.output, "Warning: ignoring entry")
        );

    FileUtils.deleteFileIfExistsWithRetry(jmod);
    jmod("create",
         "--class-path", cp,
         "--cmds", cp,
         jmod.toString())
         .assertSuccess()
         .resultChecker(r ->
             assertContains(r.output, "Warning: ignoring entry")
         );
}
 
Example #21
Source File: Basic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
// META-INF/versions/9 contains an identical class to previous version entry class
// this is okay but produces warning
public void identicalClassToPreviousVersion() throws Throwable {
    String jarfile = "test.jar";

    compile("test01");  //use same data as test01

    Path classes = Paths.get("classes");

    jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
            "--release", "9", "-C", classes.resolve("v9").toString(), ".")
            .shouldHaveExitValue(SUCCESS)
            .shouldBeEmpty();
    jar("uf", jarfile,
            "--release", "10", "-C", classes.resolve("v9").toString(), ".")
            .shouldHaveExitValue(SUCCESS)
            .shouldContain("contains a class that")
            .shouldContain("is identical");

    FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
    FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
}
 
Example #22
Source File: Basic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
// META-INF/versions/9 contains an identical class to base entry class
// this is okay but produces warning
public void test07() throws Throwable {
    String jarfile = "test.jar";

    compile("test01");  //use same data as test01

    Path classes = Paths.get("classes");

    // add the new v9 class
    Path source = Paths.get(src, "data", "test01", "base", "version");
    javac(classes.resolve("v9"), source.resolve("Version.java"));

    jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
            "--release", "9", "-C", classes.resolve("v9").toString(), ".")
            .shouldHaveExitValue(SUCCESS)
            .shouldContain("contains a class that")
            .shouldContain("is identical");

    FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
    FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
}
 
Example #23
Source File: JmodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testDuplicateEntries() throws IOException {
    Path jmod = MODS_DIR.resolve("testDuplicates.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString();
    Path lp = EXPLODED_DIR.resolve("foo").resolve("lib");

    jmod("create",
         "--class-path", cp + pathSeparator + cp,
         jmod.toString())
         .assertSuccess()
         .resultChecker(r ->
             assertContains(r.output, "Warning: ignoring duplicate entry")
         );

    FileUtils.deleteFileIfExistsWithRetry(jmod);
    jmod("create",
         "--class-path", cp,
         "--libs", lp.toString() + pathSeparator + lp.toString(),
         jmod.toString())
         .assertSuccess()
         .resultChecker(r ->
             assertContains(r.output, "Warning: ignoring duplicate entry")
         );
}
 
Example #24
Source File: Basic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
// META-INF/versions/9 contains an extra public class
public void test05() throws Throwable {
    String jarfile = "test.jar";

    compile("test01");  //use same data as test01

    Path classes = Paths.get("classes");

    // add the new v9 class
    Path source = Paths.get(src, "data", "test05", "v9", "version");
    javac(classes.resolve("v9"), source.resolve("Extra.java"));

    jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
            "--release", "9", "-C", classes.resolve("v9").toString(), ".")
            .shouldNotHaveExitValue(SUCCESS)
            .shouldContain("contains a new public class");

    FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
    FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
}
 
Example #25
Source File: Basic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
// META-INF/versions/9 class has different api than base class
public void test04() throws Throwable {
    String jarfile = "test.jar";

    compile("test01");  //use same data as test01

    Path classes = Paths.get("classes");

    // replace the v9 class
    Path source = Paths.get(src, "data", "test04", "v9", "version");
    javac(classes.resolve("v9"), source.resolve("Version.java"));

    jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
            "--release", "9", "-C", classes.resolve("v9").toString(), ".")
            .shouldNotHaveExitValue(SUCCESS)
            .shouldContain("different api from earlier");

    FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
    FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
}
 
Example #26
Source File: MultiThreadedReadTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    createZipFile();
    try (ZipFile zf = new ZipFile(new File(ZIPFILE_NAME))) {
        is = zf.getInputStream(zf.getEntry(ZIPENTRY_NAME));
        Thread[] threadArray = new Thread[NUM_THREADS];
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i] = new MultiThreadedReadTest();
        }
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i].start();
        }
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i].join();
        }
    } finally {
        long t = System.currentTimeMillis();
        FileUtils.deleteFileIfExistsWithRetry(Paths.get(ZIPFILE_NAME));
        System.out.println("Deleting zip file took:" +
                (System.currentTimeMillis() - t) + "ms");
    }
}
 
Example #27
Source File: Basic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
// create a regular, non-multi-release jar
public void test00() throws Throwable {
    String jarfile = "test.jar";

    compile("test01");  //use same data as test01

    Path classes = Paths.get("classes");
    jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".")
            .shouldHaveExitValue(SUCCESS);

    checkMultiRelease(jarfile, false);

    Map<String, String[]> names = Map.of(
            "version/Main.class",
            new String[]{"base", "version", "Main.class"},

            "version/Version.class",
            new String[]{"base", "version", "Version.class"}
    );

    compare(jarfile, names);

    FileUtils.deleteFileIfExistsWithRetry(Paths.get(jarfile));
    FileUtils.deleteFileTreeWithRetry(Paths.get(usr, "classes"));
}
 
Example #28
Source File: MultiThreadedReadTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    createZipFile();
    try (ZipFile zf = new ZipFile(new File(ZIPFILE_NAME))) {
        is = zf.getInputStream(zf.getEntry(ZIPENTRY_NAME));
        Thread[] threadArray = new Thread[NUM_THREADS];
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i] = new MultiThreadedReadTest();
        }
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i].start();
        }
        for (int i = 0; i < threadArray.length; i++) {
            threadArray[i].join();
        }
    } finally {
        FileUtils.deleteFileIfExistsWithRetry(Paths.get(ZIPFILE_NAME));
    }
}
 
Example #29
Source File: ImageModules.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void singleModularJar() throws Throwable {
    FileUtils.deleteFileTreeUnchecked(JARS_DIR);
    Files.createDirectories(JARS_DIR);
    Path converterJar = JARS_DIR.resolve("converter.jar");

    jar("--create",
        "--file", converterJar.toString(),
        "--warn-if-resolved=incubating",
        "-C", MODS_DIR.resolve("message.converter").toString() , ".")
        .assertSuccess();


    java(Paths.get(JAVA_HOME),
         "--module-path", JARS_DIR.toString(),
         "--add-modules", "message.converter",
         "-cp", CP_DIR.toString(),
         "test.ConvertToLowerCase", "HEllo WoRlD")
        .assertSuccess()
        .resultChecker(r -> {
            r.assertContains("WARNING: Using incubator modules: message.converter");
        });
}
 
Example #30
Source File: JmodNegativeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testEmptyFileInClasspath() throws IOException {
    Path jmod = MODS_DIR.resolve("testEmptyFileInClasspath.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    Path jar = MODS_DIR.resolve("NotARealJar_Empty.jar");
    FileUtils.deleteFileIfExistsWithRetry(jar);
    Files.createFile(jar);

    jmod("create",
         "--class-path", jar.toString(),
         jmod.toString())
        .assertFailure()
        .resultChecker(r ->
            assertContains(r.output, "Error: module-info.class not found")
        );
}