use of org.apache.hadoop.fs.shell.CommandFactory in project hadoop by apache.
the class FsShell method init.
protected void init() throws IOException {
getConf().setQuietMode(true);
if (commandFactory == null) {
commandFactory = new CommandFactory(getConf());
commandFactory.addObject(new Help(), "-help");
commandFactory.addObject(new Usage(), "-usage");
registerCommands(commandFactory);
}
}
use of org.apache.hadoop.fs.shell.CommandFactory in project SSM by Intel-bigdata.
the class SmartShell method init.
protected void init() throws IOException {
getConf().setQuietMode(true);
if (commandFactory == null) {
commandFactory = new CommandFactory(getConf());
commandFactory.addObject(new Help(), "-help");
commandFactory.addObject(new Usage(), "-usage");
registerCommands(commandFactory);
}
}
use of org.apache.hadoop.fs.shell.CommandFactory in project hadoop by apache.
the class TestFsShell method testExceptionNullMessage.
@Test
public void testExceptionNullMessage() throws Exception {
final String cmdName = "-cmdExNullMsg";
final Command cmd = Mockito.mock(Command.class);
Mockito.when(cmd.run(Mockito.anyVararg())).thenThrow(new IllegalArgumentException());
Mockito.when(cmd.getUsage()).thenReturn(cmdName);
final CommandFactory cmdFactory = Mockito.mock(CommandFactory.class);
final String[] names = { cmdName };
Mockito.when(cmdFactory.getNames()).thenReturn(names);
Mockito.when(cmdFactory.getInstance(cmdName)).thenReturn(cmd);
FsShell shell = new FsShell(new Configuration());
shell.commandFactory = cmdFactory;
try (GenericTestUtils.SystemErrCapturer capture = new GenericTestUtils.SystemErrCapturer()) {
ToolRunner.run(shell, new String[] { cmdName });
Assert.assertThat(capture.getOutput(), StringContains.containsString(cmdName + ": Null exception message"));
}
}
Aggregations