< prev index next >
test/tools/jar/modularJar/Basic.java
Print this page
@@ -37,18 +37,19 @@
import java.util.stream.Stream;
import jdk.testlibrary.FileUtils;
import jdk.testlibrary.JDKToolFinder;
import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static java.lang.String.format;
import static java.lang.System.out;
/*
* @test
- * @bug 8167328 8171830 8165640 8174248
+ * @bug 8167328 8171830 8165640 8174248 8176772
* @library /lib/testlibrary
* @modules jdk.compiler
* jdk.jartool
* @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
* @compile Basic.java
@@ -752,11 +753,11 @@
"-C", modClasses.toString(), "jdk/test/baz/Baz.class",
"-C", modClasses.toString(), "jdk/test/baz/internal/BazServiceImpl.class")
.assertSuccess();
- for (String option : new String[] {"--print-module-descriptor", "-d" }) {
+ for (String option : new String[] {"--describe-module", "-d" }) {
jar(option,
"--file=" + modularJar.toString())
.assertSuccess()
.resultChecker(r ->
@@ -799,12 +800,12 @@
"-C", modClasses.toString(), "jdk/test/foo/Foo.class")
.assertFailure();
}
@Test
- public void printModuleDescriptorFoo() throws IOException {
- Path mp = Paths.get("printModuleDescriptorFoo");
+ public void describeModuleFoo() throws IOException {
+ Path mp = Paths.get("describeModuleFoo");
createTestDir(mp);
Path modClasses = MODULE_CLASSES.resolve(FOO.moduleName);
Path modularJar = mp.resolve(FOO.moduleName + ".jar");
jar("--create",
@@ -813,11 +814,11 @@
"--module-version=" + FOO.version,
"--no-manifest",
"-C", modClasses.toString(), ".")
.assertSuccess();
- for (String option : new String[] {"--print-module-descriptor", "-d" }) {
+ for (String option : new String[] {"--describe-module", "-d" }) {
jar(option,
"--file=" + modularJar.toString())
.assertSuccess()
.resultChecker(r ->
assertTrue(r.output.contains(FOO.moduleName + "@" + FOO.version),
@@ -834,12 +835,12 @@
.assertFailure();
}
}
@Test
- public void printModuleDescriptorFooFromStdin() throws IOException {
- Path mp = Paths.get("printModuleDescriptorFooFromStdin");
+ public void describeModuleFooFromStdin() throws IOException {
+ Path mp = Paths.get("describeModuleFooFromStdin");
createTestDir(mp);
Path modClasses = MODULE_CLASSES.resolve(FOO.moduleName);
Path modularJar = mp.resolve(FOO.moduleName + ".jar");
jar("--create",
@@ -848,11 +849,11 @@
"--module-version=" + FOO.version,
"--no-manifest",
"-C", modClasses.toString(), ".")
.assertSuccess();
- for (String option : new String[] {"--print-module-descriptor", "-d" }) {
+ for (String option : new String[] {"--describe-module", "-d" }) {
jarWithStdin(modularJar.toFile(),
option)
.assertSuccess()
.resultChecker(r ->
assertTrue(r.output.contains(FOO.moduleName + "@" + FOO.version),
@@ -860,10 +861,54 @@
" in [", r.output, "]")
);
}
}
+
+ @DataProvider(name = "autoNames")
+ public Object[][] autoNames() {
+ return new Object[][] {
+ // JAR file name module-name[@version]
+ { "foo.jar", "foo" },
+ { "foo4j.jar", "foo4j", },
+ { "foo1.2.3.jar", "foo" },
+ { "foo-1.2.3.4.jar", "foo@1.2.3.4" },
+ { "foo-bar.jar", "foo.bar" },
+ { "foo-1.2-SNAPSHOT.jar", "foo@1.2-SNAPSHOT" },
+ };
+ }
+
+ @Test(dataProvider = "autoNames")
+ public void describeAutomaticModule(String jarName, String mid)
+ throws IOException
+ {
+ Path mp = Paths.get("describeAutomaticModule");
+ createTestDir(mp);
+ Path regularJar = mp.resolve(jarName);
+ Path t = Paths.get("t");
+ if (Files.notExists(t))
+ Files.createFile(t);
+
+ jar("--create",
+ "--file=" + regularJar.toString(),
+ t.toString())
+ .assertSuccess();
+
+ for (String option : new String[] {"--describe-module", "-d" }) {
+ jar(option,
+ "--file=" + regularJar.toString())
+ .assertSuccess()
+ .resultChecker(r -> {
+ assertTrue(r.output.contains("No module descriptor found"));
+ assertTrue(r.output.contains("Derived automatic module"));
+ assertTrue(r.output.contains("module " + mid),
+ "Expected [", "module " + mid,"] in [", r.output, "]");
+ }
+ );
+ }
+ }
+
// -- Infrastructure
static Result jarWithStdin(File stdinSource, String... args) {
String jar = getJDKTool("jar");
List<String> commands = new ArrayList<>();
< prev index next >