changeset 17049:8891407eccc4

8178323: Add negative tests for bind services Jlink feature Reviewed-by: mchung
author anazarov
date Thu, 20 Apr 2017 22:46:07 -0700
parents 83ec9920d373
children 101f35eefb01
files test/tools/jlink/bindservices/BindServices.java test/tools/jlink/bindservices/SuggestProviders.java
diffstat 2 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/jlink/bindservices/BindServices.java	Thu Apr 20 15:06:40 2017 -0700
+++ b/test/tools/jlink/bindservices/BindServices.java	Thu Apr 20 22:46:07 2017 -0700
@@ -149,6 +149,23 @@
         testImage(dir, "m1", "m2", "m3");
     }
 
+    @Test
+    public void testVerboseAndNoBindServices() throws Throwable {
+        if (!hasJmods()) return;
+
+        Path dir = Paths.get("verboseNoBind");
+
+        List<String> output =
+            JLink.run("--output", dir.toString(),
+                      "--module-path", MODULE_PATH,
+                      "--verbose",
+                      "--add-modules", "m1").output();
+
+        assertTrue(output.contains("m1 provides p1.S used by m1"));
+
+        testImage(dir, "m1");
+    }
+
     /*
      * Tests the given ${java.home} to only contain the specified modules
      */
--- a/test/tools/jlink/bindservices/SuggestProviders.java	Thu Apr 20 15:06:40 2017 -0700
+++ b/test/tools/jlink/bindservices/SuggestProviders.java	Thu Apr 20 22:46:07 2017 -0700
@@ -247,6 +247,42 @@
 
     }
 
+    @Test
+    public void suggestTypeNotRealProvider() throws Throwable {
+        if (!hasJmods()) return;
+
+        List<String> output =
+            JLink.run("--module-path", MODULE_PATH,
+                      "--add-modules", "m1",
+                      "--suggest-providers",
+                      "java.util.List").output();
+
+        System.out.println(output);
+        List<String> expected = List.of(
+            "No provider found for service specified to --suggest-providers: java.util.List"
+        );
+
+        assertTrue(output.containsAll(expected));
+    }
+
+    @Test
+    public void addNonObservableModule() throws Throwable {
+        if (!hasJmods()) return;
+
+        List<String> output =
+            JLink.run("--module-path", MODULE_PATH,
+                      "--add-modules", "nonExistentModule",
+                      "--suggest-providers",
+                      "java.nio.charset.spi.CharsetProvider").output();
+
+        System.out.println(output);
+        List<String> expected = List.of(
+            "jdk.charsets provides java.nio.charset.spi.CharsetProvider used by java.base"
+        );
+
+        assertTrue(output.containsAll(expected));
+    }
+
     static class JLink {
         static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
             .orElseThrow(() ->