Java Code Examples for jdk.testlibrary.FileUtils

The following examples show how to use jdk.testlibrary.FileUtils. These examples are extracted from open source projects. 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
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 2
Source Project: openjdk-jdk9   Source File: JmodTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testPackagesAttribute() throws IOException {
    Path jmod = MODS_DIR.resolve("foo.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString();

    Set<String> expectedPackages = Set.of("jdk.test.foo",
                                          "jdk.test.foo.internal",
                                          "jdk.test.foo.resources");

    jmod("create",
         "--class-path", cp,
         jmod.toString())
         .assertSuccess()
         .resultChecker(r -> {
             Set<String> pkgs = getModuleDescriptor(jmod).packages();
             assertEquals(pkgs, expectedPackages);
         });
    }
 
Example 3
@Test
public void testInvalidModuleVersion() throws IOException {
    Path jmod = MODS_DIR.resolve("testEmptyModuleVersion.jmod");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    String cp = EXPLODED_DIR.resolve("foo").resolve("classes").toString();

    for (String version : new String[] { "", "NOT_A_VALID_VERSION" }) {
        jmod("create",
             "--class-path", cp,
             "--module-version", version,
             jmod.toString())
            .assertFailure()
            .resultChecker(r ->
                assertContains(r.output, "Error: invalid module version")
            );
    }
}
 
Example 4
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 5
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 6
public static void main(String[] args) throws Exception {
    String maxLocksSet = System.getProperty(MX_LCK_SYS_PROPERTY);
    File loggerDir = createLoggerDir();
    List<FileHandler> fileHandlers = new ArrayList<>();
    try {
        // 200 raises the default limit of 100, we try 102 times
        for (int i = 0; i < 102; i++) {
            fileHandlers.add(new FileHandler(loggerDir.getPath()
                    + File.separator + "test_%u.log"));
        }
    } catch (IOException ie) {
        if (maxLocksSet.equals("200ab")
                && ie.getMessage().contains("get lock for")) {
            // Ignore: Expected exception while passing bad value- 200ab
        } else {
            throw new RuntimeException("Test Failed: " + ie.getMessage());
        }
    } finally {
        for (FileHandler fh : fileHandlers) {
            fh.close();
        }
        FileUtils.deleteFileTreeWithRetry(Paths.get(loggerDir.getPath()));
    }
}
 
Example 7
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 8
public static void main(String[] args) throws Exception {
    String maxLocksSet = System.getProperty(MX_LCK_SYS_PROPERTY);
    File loggerDir = createLoggerDir();
    List<FileHandler> fileHandlers = new ArrayList<>();
    try {
        // 200 raises the default limit of 100, we try 102 times
        for (int i = 0; i < 102; i++) {
            fileHandlers.add(new FileHandler(loggerDir.getPath()
                    + File.separator + "test_%u.log"));
        }
    } catch (IOException ie) {
        if (maxLocksSet.equals("200ab")
                && ie.getMessage().contains("get lock for")) {
            // Ignore: Expected exception while passing bad value- 200ab
        } else {
            throw new RuntimeException("Test Failed: " + ie.getMessage());
        }
    } finally {
        for (FileHandler fh : fileHandlers) {
            fh.close();
        }
        FileUtils.deleteFileTreeWithRetry(Paths.get(loggerDir.getPath()));
    }
}
 
Example 9
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 10
Source Project: openjdk-jdk9   Source File: JmodTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testTmpFileRemoved() throws IOException {
    // Implementation detail: jmod tool creates <jmod-file>.tmp
    // Ensure that it is removed in the event of a failure.
    // The failure in this case is a class in the unnamed package.

    Path jmod = MODS_DIR.resolve("testTmpFileRemoved.jmod");
    Path tmp = MODS_DIR.resolve(".testTmpFileRemoved.jmod.tmp");
    FileUtils.deleteFileIfExistsWithRetry(jmod);
    FileUtils.deleteFileIfExistsWithRetry(tmp);
    String cp = EXPLODED_DIR.resolve("foo").resolve("classes") + File.pathSeparator +
                EXPLODED_DIR.resolve("foo").resolve("classes")
                            .resolve("jdk").resolve("test").resolve("foo").toString();

    jmod("create",
         "--class-path", cp,
         jmod.toString())
        .assertFailure()
        .resultChecker(r -> {
            assertContains(r.output, "unnamed package");
            assertTrue(Files.notExists(tmp), "Unexpected tmp file:" + tmp);
        });
}
 
Example 11
public static void main(String[] args) throws Exception {
    File loggerDir = createLoggerDir();
    String configFilePath = loggerDir.getPath() + File.separator + CONFIG_FILE_NAME;
    File configFile = new File(configFilePath);
    createFile(configFile, false);
    System.setProperty("java.util.logging.config.file", configFilePath);
    List<FileHandler> fileHandlers = new ArrayList<>();
    try (FileWriter writer = new FileWriter(configFile)) {
        writer.write(MAX_LOCK_PROPERTY);
        writer.flush();
        // 200 raises the default limit of 100, we try 102 times
        for (int i = 0; i < 102; i++) {
            fileHandlers.add(new FileHandler(loggerDir.getPath() + File.separator + "test_%u.log"));
        }
    } catch (IOException ie) {
        throw new RuntimeException("Test Failed: " + ie.getMessage());
    } finally {
        for (FileHandler fh : fileHandlers) {
            fh.close();
        }
        FileUtils.deleteFileTreeWithRetry(Paths.get(loggerDir.getPath()));
    }
}
 
Example 12
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 13
@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")
        );
}
 
Example 14
Source Project: openjdk-jdk9   Source File: ImageModules.java    License: 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 15
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 Project: openjdk-jdk9   Source File: Basic.java    License: 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 17
@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 18
Source Project: openjdk-jdk9   Source File: Basic.java    License: 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 19
Source Project: openjdk-jdk9   Source File: Basic.java    License: 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 20
Source Project: openjdk-jdk9   Source File: JmodTest.java    License: 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 21
Source Project: openjdk-jdk9   Source File: Basic.java    License: 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 22
Source Project: openjdk-jdk9   Source File: Basic.java    License: 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 23
Source Project: openjdk-jdk9   Source File: JmodTest.java    License: 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 24
Source Project: openjdk-jdk9   Source File: Basic.java    License: 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 25
Source Project: openjdk-jdk9   Source File: Basic.java    License: 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 26
@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 27
@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 28
@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 29
@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 30
@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);
}