@Test public void testLoadClass() { String name = HoodieTable.class.getName(); CommandResult cr = getShell().executeCommand(String.format("utils loadClass --class %s", name)); assertAll("Command runs success", () -> assertTrue(cr.isSuccess()), () -> assertNotNull(cr.getResult().toString()), () -> assertTrue(cr.getResult().toString().startsWith("file:"))); }
@CliCommand(value = "utils loadClass", help = "Load a class") public String loadClass(@CliOption(key = {"class"}, help = "Check mode") final String clazz) { if (StringUtils.isNullOrEmpty(clazz)) { return "Class to be loaded can not be null!"; } try { Class klass = Class.forName(clazz); return klass.getProtectionDomain().getCodeSource().getLocation().toExternalForm(); } catch (ClassNotFoundException e) { return String.format("Class %s not found!", clazz); } }
UtilsCommand implements CommandMarker { @CliCommand(value = "utils loadClass", help = "Load a class") public String loadClass(@CliOption(key = {"class"}, help = "Check mode") final String clazz) { if (StringUtils.isNullOrEmpty(clazz)) { return "Class to be loaded can not be null!"; } try { Class klass = Class.forName(clazz); return klass.getProtectionDomain().getCodeSource().getLocation().toExternalForm(); } catch (ClassNotFoundException e) { return String.format("Class %s not found!", clazz); } } }
UtilsCommand implements CommandMarker { @CliCommand(value = "utils loadClass", help = "Load a class") public String loadClass(@CliOption(key = {"class"}, help = "Check mode") final String clazz) { if (StringUtils.isNullOrEmpty(clazz)) { return "Class to be loaded can not be null!"; } try { Class klass = Class.forName(clazz); return klass.getProtectionDomain().getCodeSource().getLocation().toExternalForm(); } catch (ClassNotFoundException e) { return String.format("Class %s not found!", clazz); } }  }
UtilsCommand implements CommandMarker { @CliCommand(value = "utils loadClass", help = "Load a class") public String loadClass(@CliOption(key = {"class"}, help = "Check mode") final String clazz) { if (StringUtils.isNullOrEmpty(clazz)) { return "Class to be loaded can not be null!"; } try { Class klass = Class.forName(clazz); return klass.getProtectionDomain().getCodeSource().getLocation().toExternalForm(); } catch (ClassNotFoundException e) { return String.format("Class %s not found!", clazz); } }  @CliCommand(value = "utils loadClass", help = "Load a class") String loadClass(@CliOption(key = {"class"}, help = "Check mode") final String clazz); }
UtilsCommand implements CommandMarker { @CliCommand(value = "utils loadClass", help = "Load a class") public String loadClass(@CliOption(key = {"class"}, help = "Check mode") final String clazz) { if (StringUtils.isNullOrEmpty(clazz)) { return "Class to be loaded can not be null!"; } try { Class klass = Class.forName(clazz); return klass.getProtectionDomain().getCodeSource().getLocation().toExternalForm(); } catch (ClassNotFoundException e) { return String.format("Class %s not found!", clazz); } }  @CliCommand(value = "utils loadClass", help = "Load a class") String loadClass(@CliOption(key = {"class"}, help = "Check mode") final String clazz);  }