--- old/test/tools/jlink/bindservices/SuggestProviders.java 2017-04-10 22:27:00.000000000 +0300 +++ new/test/tools/jlink/bindservices/SuggestProviders.java 2017-04-10 22:27:00.000000000 +0300 @@ -60,7 +60,7 @@ File.pathSeparator + MODS_DIR.toString(); // the names of the modules in this test - private static String[] modules = new String[] {"m1", "m2", "m3"}; + private static String[] modules = new String[] {"m1", "m2", "m3", "m4"}; private static boolean hasJmods() { @@ -171,6 +171,61 @@ } + @Test + public void suggestTypeNotRealProvider() throws Throwable { + if (!hasJmods()) return; + + List output = + JLink.run("--module-path", MODULE_PATH, + "--add-modules", "m1", + "--suggest-providers", + "java.util.List").output(); + + System.out.println(output); + List expected = List.of( + "Services specified in --suggest-providers not used: java.util.List" + ); + + assertTrue(output.containsAll(expected)); + } + +// @Test @ignore JDK-8178405 + public void noOneUsesProvider() throws Throwable { + if (!hasJmods()) return; + + List output = + JLink.run("--module-path", MODULE_PATH, + "--add-modules", "m4", + "--suggest-providers", + "p4.Impl").output(); + + System.out.println(output); + List expected = List.of( + "Services specified in --suggest-providers not used: p4.Impl" + ); + + assertTrue(output.containsAll(expected)); + } + +// @Test @ignore JDK-8178404 + public void nonObservableModule() throws Throwable { + if (!hasJmods()) return; + + List output = + JLink.run(false, + "--module-path", MODULE_PATH, + "--add-modules", "nonExistentModule", + "--suggest-providers", + "java.nio.charset.spi.CharsetProvider").output(); + + System.out.println(output); + List expected = List.of( + "Error: Module nonExistentModule not found" + ); + + assertTrue(output.containsAll(expected)); + } + static class JLink { static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink") .orElseThrow(() -> @@ -178,8 +233,19 @@ ); static JLink run(String... options) { + return run(true, options); + } + + static JLink run(boolean expectSuccess, String... options) { JLink jlink = new JLink(); - assertTrue(jlink.execute(options) == 0); + if (expectSuccess){ + assertEquals(jlink.execute(options), 0 , + "Jlink failed."); + } + else { + assertNotEquals(jlink.execute(options), 0, + "Jlink succeeded. Expect to fail."); + } return jlink; }