use of picocli.CommandLine.IExceptionHandler2 in project ozone by apache.
the class TestGenerateOzoneRequiredConfigurations method execute.
private void execute(String[] args, String msg) throws UnsupportedEncodingException {
List<String> arguments = new ArrayList(Arrays.asList(args));
LOG.info("Executing shell command with args {}", arguments);
CommandLine cmd = genconfTool.getCmd();
IExceptionHandler2<List<Object>> exceptionHandler = new IExceptionHandler2<List<Object>>() {
@Override
public List<Object> handleParseException(ParameterException ex, String[] args) {
throw ex;
}
@Override
public List<Object> handleExecutionException(ExecutionException ex, ParseResult parseResult) {
throw ex;
}
};
cmd.parseWithHandlers(new CommandLine.RunLast(), exceptionHandler, args);
Assert.assertTrue(out.toString(DEFAULT_ENCODING).contains(msg));
}
use of picocli.CommandLine.IExceptionHandler2 in project ozone by apache.
the class TestGenerateOzoneRequiredConfigurations method executeWithException.
private void executeWithException(String[] args, String msg) {
List<String> arguments = new ArrayList(Arrays.asList(args));
LOG.info("Executing shell command with args {}", arguments);
CommandLine cmd = genconfTool.getCmd();
IExceptionHandler2<List<Object>> exceptionHandler = new IExceptionHandler2<List<Object>>() {
@Override
public List<Object> handleParseException(ParameterException ex, String[] args) {
throw ex;
}
@Override
public List<Object> handleExecutionException(ExecutionException ex, ParseResult parseResult) {
throw ex;
}
};
try {
cmd.parseWithHandlers(new CommandLine.RunLast(), exceptionHandler, args);
} catch (Exception ex) {
Assert.assertTrue("Expected " + msg + ", but got: " + ex.getMessage(), ex.getMessage().contains(msg));
}
}
use of picocli.CommandLine.IExceptionHandler2 in project ozone by apache.
the class TestOzoneDatanodeShell method executeDatanode.
private void executeDatanode(HddsDatanodeService hdds, String[] args) {
LOG.info("Executing datanode command with args {}", Arrays.asList(args));
CommandLine cmd = hdds.getCmd();
IExceptionHandler2<List<Object>> exceptionHandler = new IExceptionHandler2<List<Object>>() {
@Override
public List<Object> handleParseException(ParameterException ex, String[] args) {
throw ex;
}
@Override
public List<Object> handleExecutionException(ExecutionException ex, ParseResult parseResult) {
throw ex;
}
};
cmd.parseWithHandlers(new RunLast(), exceptionHandler, args);
}
use of picocli.CommandLine.IExceptionHandler2 in project ozone by apache.
the class TestOzoneShellHA method execute.
private void execute(GenericCli shell, String[] args) {
LOG.info("Executing OzoneShell command with args {}", Arrays.asList(args));
CommandLine cmd = shell.getCmd();
IExceptionHandler2<List<Object>> exceptionHandler = new IExceptionHandler2<List<Object>>() {
@Override
public List<Object> handleParseException(ParameterException ex, String[] args) {
throw ex;
}
@Override
public List<Object> handleExecutionException(ExecutionException ex, ParseResult parseRes) {
throw ex;
}
};
// Since there is no elegant way to pass Ozone config to the shell,
// the idea is to use 'set' to place those OM HA configs.
String[] argsWithHAConf = getHASetConfStrings(args);
cmd.parseWithHandlers(new RunLast(), exceptionHandler, argsWithHAConf);
}
use of picocli.CommandLine.IExceptionHandler2 in project ozone by apache.
the class TestAuditParser method execute.
private static void execute(String[] args, String msg) {
List<String> arguments = new ArrayList(Arrays.asList(args));
LOG.info("Executing shell command with args {}", arguments);
CommandLine cmd = parserTool.getCmd();
IExceptionHandler2<List<Object>> exceptionHandler = new IExceptionHandler2<List<Object>>() {
@Override
public List<Object> handleParseException(ParameterException ex, String[] args) {
throw ex;
}
@Override
public List<Object> handleExecutionException(ExecutionException ex, ParseResult parseResult) {
throw ex;
}
};
cmd.parseWithHandlers(new CommandLine.RunLast(), exceptionHandler, args);
try {
Assert.assertTrue(OUT.toString(DEFAULT_CODING).contains(msg));
} catch (UnsupportedEncodingException ignored) {
}
}
Aggregations