equal
deleted
inserted
replaced
22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @library /lib/testlibrary |
26 * @library /lib/testlibrary |
27 * @modules jdk.jlink/jdk.tools.jmod |
27 * @modules jdk.compiler |
28 * jdk.compiler |
28 * jdk.jlink |
29 * @build jdk.testlibrary.FileUtils CompilerUtils |
29 * @build jdk.testlibrary.FileUtils CompilerUtils |
30 * @run testng JmodNegativeTest |
30 * @run testng JmodNegativeTest |
31 * @summary Negative tests for jmod |
31 * @summary Negative tests for jmod |
32 */ |
32 */ |
33 |
33 |
37 import java.nio.file.Paths; |
37 import java.nio.file.Paths; |
38 import java.util.Arrays; |
38 import java.util.Arrays; |
39 import java.util.List; |
39 import java.util.List; |
40 import java.util.function.Consumer; |
40 import java.util.function.Consumer; |
41 import java.util.function.Supplier; |
41 import java.util.function.Supplier; |
|
42 import java.util.spi.ToolProvider; |
42 import java.util.zip.ZipOutputStream; |
43 import java.util.zip.ZipOutputStream; |
43 import jdk.testlibrary.FileUtils; |
44 import jdk.testlibrary.FileUtils; |
44 import org.testng.annotations.BeforeTest; |
45 import org.testng.annotations.BeforeTest; |
45 import org.testng.annotations.DataProvider; |
46 import org.testng.annotations.DataProvider; |
46 import org.testng.annotations.Test; |
47 import org.testng.annotations.Test; |
48 import static java.io.File.pathSeparator; |
49 import static java.io.File.pathSeparator; |
49 import static java.nio.charset.StandardCharsets.UTF_8; |
50 import static java.nio.charset.StandardCharsets.UTF_8; |
50 import static org.testng.Assert.assertTrue; |
51 import static org.testng.Assert.assertTrue; |
51 |
52 |
52 public class JmodNegativeTest { |
53 public class JmodNegativeTest { |
|
54 |
|
55 static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod") |
|
56 .orElseThrow(() -> |
|
57 new RuntimeException("jmod tool not found") |
|
58 ); |
53 |
59 |
54 static final String TEST_SRC = System.getProperty("test.src", "."); |
60 static final String TEST_SRC = System.getProperty("test.src", "."); |
55 static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
61 static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
56 static final Path EXPLODED_DIR = Paths.get("build"); |
62 static final Path EXPLODED_DIR = Paths.get("build"); |
57 static final Path MODS_DIR = Paths.get("jmods"); |
63 static final Path MODS_DIR = Paths.get("jmods"); |
513 |
519 |
514 static JmodResult jmod(String... args) { |
520 static JmodResult jmod(String... args) { |
515 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
521 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
516 PrintStream ps = new PrintStream(baos); |
522 PrintStream ps = new PrintStream(baos); |
517 System.out.println("jmod " + Arrays.asList(args)); |
523 System.out.println("jmod " + Arrays.asList(args)); |
518 int ec = jdk.tools.jmod.Main.run(args, ps); |
524 int ec = JMOD_TOOL.run(ps, ps, args); |
519 return new JmodResult(ec, new String(baos.toByteArray(), UTF_8)); |
525 return new JmodResult(ec, new String(baos.toByteArray(), UTF_8)); |
520 } |
526 } |
521 |
527 |
522 static class JmodResult { |
528 static class JmodResult { |
523 final int exitCode; |
529 final int exitCode; |