< prev index next >

test/tools/jlink/bindservices/SuggestProviders.java

Print this page

        

*** 58,68 **** private static final String MODULE_PATH = Paths.get(JAVA_HOME, "jmods").toString() + File.pathSeparator + MODS_DIR.toString(); // the names of the modules in this test ! private static String[] modules = new String[] {"m1", "m2", "m3"}; private static boolean hasJmods() { if (!Files.exists(Paths.get(JAVA_HOME, "jmods"))) { System.err.println("Test skipped. NO jmods directory"); --- 58,68 ---- private static final String MODULE_PATH = Paths.get(JAVA_HOME, "jmods").toString() + File.pathSeparator + MODS_DIR.toString(); // the names of the modules in this test ! private static String[] modules = new String[] {"m1", "m2", "m3", "m4"}; private static boolean hasJmods() { if (!Files.exists(Paths.get(JAVA_HOME, "jmods"))) { System.err.println("Test skipped. NO jmods directory");
*** 169,187 **** String expected = "--bind-services option is specified. No additional providers suggested."; assertTrue(output.contains(expected)); } static class JLink { static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink") .orElseThrow(() -> new RuntimeException("jlink tool not found") ); static JLink run(String... options) { JLink jlink = new JLink(); ! assertTrue(jlink.execute(options) == 0); return jlink; } final List<String> output = new ArrayList<>(); private int execute(String... options) { --- 169,253 ---- String expected = "--bind-services option is specified. No additional providers suggested."; assertTrue(output.contains(expected)); } + @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( + "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<String> output = + JLink.run("--module-path", MODULE_PATH, + "--add-modules", "m4", + "--suggest-providers", + "p4.Impl").output(); + + System.out.println(output); + List<String> 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<String> output = + JLink.run(false, + "--module-path", MODULE_PATH, + "--add-modules", "nonExistentModule", + "--suggest-providers", + "java.nio.charset.spi.CharsetProvider").output(); + + System.out.println(output); + List<String> expected = List.of( + "Error: Module nonExistentModule not found" + ); + + assertTrue(output.containsAll(expected)); + } + static class JLink { static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink") .orElseThrow(() -> new RuntimeException("jlink tool not found") ); static JLink run(String... options) { + return run(true, options); + } + + static JLink run(boolean expectSuccess, String... options) { JLink jlink = new JLink(); ! if (expectSuccess){ ! assertEquals(jlink.execute(options), 0 , ! "Jlink failed."); ! } ! else { ! assertNotEquals(jlink.execute(options), 0, ! "Jlink succeeded. Expect to fail."); ! } return jlink; } final List<String> output = new ArrayList<>(); private int execute(String... options) {
< prev index next >