Search in sources :

Example 1 with CommandFactory

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);
    }
}
Also used : CommandFactory(org.apache.hadoop.fs.shell.CommandFactory)

Example 2 with 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);
    }
}
Also used : CommandFactory(org.apache.hadoop.fs.shell.CommandFactory)

Example 3 with 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"));
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) Command(org.apache.hadoop.fs.shell.Command) GenericTestUtils(org.apache.hadoop.test.GenericTestUtils) CommandFactory(org.apache.hadoop.fs.shell.CommandFactory) Test(org.junit.Test)

Aggregations

CommandFactory (org.apache.hadoop.fs.shell.CommandFactory)3 Configuration (org.apache.hadoop.conf.Configuration)1 Command (org.apache.hadoop.fs.shell.Command)1 GenericTestUtils (org.apache.hadoop.test.GenericTestUtils)1 Test (org.junit.Test)1