< prev index next >
test/jdk/tools/jar/modularJar/Basic.java
Print this page
@@ -44,11 +44,11 @@
import static java.lang.String.format;
import static java.lang.System.out;
/*
* @test
- * @bug 8167328 8171830 8165640 8174248 8176772 8196748 8191533
+ * @bug 8167328 8171830 8165640 8174248 8176772 8196748 8191533 8210454
* @library /test/lib
* @modules jdk.compiler
* jdk.jartool
* @build jdk.test.lib.Platform
* jdk.test.lib.util.FileUtils
@@ -876,10 +876,54 @@
" in [", r.output, "]")
);
}
}
+ /**
+ * Validate that you can update a jar only specifying --module-version
+ * @throws IOException
+ */
+ @Test
+ public void updateFooModuleVersion() throws IOException {
+ Path mp = Paths.get("updateFooModuleVersion");
+ createTestDir(mp);
+ Path modClasses = MODULE_CLASSES.resolve(FOO.moduleName);
+ Path modularJar = mp.resolve(FOO.moduleName + ".jar");
+ String newFooVersion = "87.0";
+
+ jar("--create",
+ "--file=" + modularJar.toString(),
+ "--main-class=" + FOO.mainClass,
+ "--module-version=" + FOO.version,
+ "--no-manifest",
+ "-C", modClasses.toString(), ".")
+ .assertSuccess();
+
+ jarWithStdin(modularJar.toFile(), "--describe-module")
+ .assertSuccess()
+ .resultChecker(r ->
+ assertTrue(r.output.contains(FOO.moduleName + "@" + FOO.version),
+ "Expected to find ", FOO.moduleName + "@" + FOO.version,
+ " in [", r.output, "]")
+ );
+
+ jar("--update",
+ "--file=" + modularJar.toString(),
+ "--module-version=" + newFooVersion)
+ .assertSuccess();
+
+ for (String option : new String[] {"--describe-module", "-d" }) {
+ jarWithStdin(modularJar.toFile(),
+ option)
+ .assertSuccess()
+ .resultChecker(r ->
+ assertTrue(r.output.contains(FOO.moduleName + "@" + newFooVersion),
+ "Expected to find ", FOO.moduleName + "@" + newFooVersion,
+ " in [", r.output, "]")
+ );
+ }
+ }
@DataProvider(name = "autoNames")
public Object[][] autoNames() {
return new Object[][] {
// JAR file name module-name[@version]
< prev index next >