@Override public int run(String[] args) throws Exception { int exitCode = 0; try { exitCode = init(args); if (exitCode != 0) { return exitCode; } if (command.validate()) { command.execute(); } else { exitCode = 1; } } catch (Exception e) { e.printStackTrace(err); return 1; } return exitCode; }
@Override public int run(String[] args) throws Exception { int exitCode = 0; try { exitCode = init(args); if (exitCode != 0) { return exitCode; } if (command.validate()) { command.execute(); } else { exitCode = 1; } } catch (Exception e) { e.printStackTrace(err); return 1; } return exitCode; }
@Override public int run(String[] args) throws Exception { int exitCode = 0; try { exitCode = init(args); if (exitCode != 0) { return exitCode; } if (command.validate()) { command.execute(); } else { exitCode = 1; } } catch (Exception e) { e.printStackTrace(err); return 1; } return exitCode; }
@Override public int run(String[] args) throws Exception { int exitCode = 0; try { exitCode = init(args); if (exitCode != 0) { return exitCode; } if (!isHelp) { if (command.validate()) { command.execute(); } else { exitCode = 1; } } } catch (Exception e) { e.printStackTrace(err); return 1; } return exitCode; }
@Test public void testEmptyArgForCommands() throws Exception { CredentialShell shell = new CredentialShell(); String[] command = { "list", "-provider" }; assertEquals("Expected empty argument on " + command + " to return 1", 1, shell.init(command)); for (String cmd : Arrays.asList("create", "delete")) { shell.setConf(new Configuration()); assertEquals("Expected empty argument on " + cmd + " to return 1", 1, shell.init(new String[] { cmd })); } } }
@Test public void testEmptyArgForCommands() throws Exception { CredentialShell shell = new CredentialShell(); String[] command = { "list", "-provider" }; assertEquals("Expected empty argument on " + command + " to return 1", 1, shell.init(command)); for (String cmd : Arrays.asList("create", "delete")) { shell.setConf(new Configuration()); assertEquals("Expected empty argument on " + cmd + " to return 1", 1, shell.init(new String[] { cmd })); } } }
@Test public void testCommandHelpExitsNormally() throws Exception { for (String cmd : Arrays.asList("create", "list", "delete")) { CredentialShell shell = new CredentialShell(); shell.setConf(new Configuration()); assertEquals("Expected help argument on " + cmd + " to return 0", 0, shell.init(new String[] {cmd, "-help"})); } }
@Test public void testCommandHelpExitsNormally() throws Exception { for (String cmd : Arrays.asList("create", "list", "delete")) { CredentialShell shell = new CredentialShell(); shell.setConf(new Configuration()); assertEquals("Expected help argument on " + cmd + " to return 0", 0, shell.init(new String[] {cmd, "-help"})); } }
@Test public void testEmptyArgList() throws Exception { CredentialShell shell = new CredentialShell(); shell.setConf(new Configuration()); assertEquals(1, shell.init(new String[0])); }
@Test public void testEmptyArgList() throws Exception { CredentialShell shell = new CredentialShell(); shell.setConf(new Configuration()); assertEquals(1, shell.init(new String[0])); }