Package org.apache.hadoop.fs.shell.find

Examples of org.apache.hadoop.fs.shell.find.Exec.initialise()


  @Test
  public void testFsShellCommand() throws IOException {
    factory.registerCommands(FsCommand.class);
    Exec exec = new Exec();
    exec.addArguments(getArgs("-ls {} ;"));
    exec.initialise(options);
    Command cmd = exec.getCommand();
    assertEquals("org.apache.hadoop.fs.shell.Ls", cmd.getClass().getName());
  }
 
  @Test
View Full Code Here


  public void testUnknownCommand() throws IOException {
    TestCommand.testErr = System.err;
    Exec exec = new Exec();
    exec.addArguments(getArgs("-invalid arg1 arg2 ;"));
    try {
      exec.initialise(options);
      fail("Invalid command not caught");
    }
    catch(IOException e) {
      assertEquals("Unknown command: -invalid", e.getMessage());
    }
View Full Code Here

  @Test
  public void testTestCommand() throws IOException {
    Exec exec = new Exec();
    exec.addArguments(getArgs("-testCommand ;"));
    exec.initialise(options);
    Command cmd = exec.getCommand();
    assertEquals(TestCommand.class, cmd.getClass());
    verifyNoMoreInteractions(out);
    verifyNoMoreInteractions(err);
  }
View Full Code Here

 
  @Test
  public void applyOneArg() throws IOException {
    Exec exec = new Exec();
    exec.addArguments(getArgs("-testCommand {} ;"));
    exec.initialise(options);
    assertEquals(Result.PASS, exec.apply(item));
    verify(out).println("TestCommand.processPath:"+item.toString());
    verifyNoMoreInteractions(out);
    verifyNoMoreInteractions(err);
  }
View Full Code Here

 
  @Test
  public void applyOptions() throws IOException {
    Exec exec = new Exec();
    exec.addArguments(getArgs("-testCommand -option1 -option2 {} ;"));
    exec.initialise(options);
    assertEquals(Result.PASS, exec.apply(item));
    verify(out).println("TestCommand.processOptions:-option1");
    verify(out).println("TestCommand.processOptions:-option2");
    verify(out).println("TestCommand.processPath:"+item.toString());
    verifyNoMoreInteractions(out);
View Full Code Here

 
  @Test
  public void applyFail() throws IOException {
    Exec exec = new Exec();
    exec.addArguments(getArgs("-testCommand -fail {} ;"));
    exec.initialise(options);
    assertEquals(Result.FAIL, exec.apply(item));
    verify(out).println("TestCommand.processOptions:-fail");
    verify(out).println("TestCommand.processPath:"+item.toString());
    verifyNoMoreInteractions(out);
    verify(err).println("testCommand: failed");
View Full Code Here

 
  @Test
  public void applyRepeatArg() throws IOException {
    Exec exec = new Exec();
    exec.addArguments(getArgs("-testCommand {} {} ;"));
    exec.initialise(options);
    assertEquals(Result.PASS, exec.apply(item));
    verify(out, times(2)).println("TestCommand.processPath:"+item.toString());
    verifyNoMoreInteractions(out);
    verifyNoMoreInteractions(err);
  }
View Full Code Here

 
  @Test
  public void applyAdditionalArg() throws IOException {
    Exec exec = new Exec();
    exec.addArguments(getArgs("-testCommand path1 {} path2 ;"));
    exec.initialise(options);
   
    FileStatus fstat1 = mock(FileStatus.class);
    when(fstat1.getPath()).thenReturn(new Path("path1"));
    FileStatus fstat2 = mock(FileStatus.class);
    when(fstat2.getPath()).thenReturn(new Path("path2"));
View Full Code Here

 
  @Test
  public void applyBatched() throws IOException {
    Exec exec = new Exec();
    exec.addArguments(getArgs("-testCommand {} +"));
    exec.initialise(options);
    exec.setMaxArgs(2);
   
    FileStatus fstat1 = mock(FileStatus.class);
    when(fstat1.getPath()).thenReturn(new Path("test1"));
    when(fstat1.toString()).thenReturn("test1");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.