Package org.apache.hadoop.fs.shell

Examples of org.apache.hadoop.fs.shell.PathData


  public void applyEmptyFile() throws IOException {
    FileStatus fileStatus = mock(FileStatus.class);
    when(fileStatus.isDirectory()).thenReturn(false);
    when(fileStatus.getLen()).thenReturn(0l);
    fs.setFileStatus("emptyFile", fileStatus);
    PathData item = new PathData("emptyFile", fs.getConf());
   
    Empty empty = new Empty();
    empty.initialise(new FindOptions());

    assertEquals(Result.PASS, empty.apply(item));
View Full Code Here


  public void applyNotEmptyFile() throws IOException {
    FileStatus fileStatus = mock(FileStatus.class);
    when(fileStatus.isDirectory()).thenReturn(false);
    when(fileStatus.getLen()).thenReturn(1l);
    fs.setFileStatus("notEmptyFile", fileStatus);
    PathData item = new PathData("notEmptyFile", fs.getConf());
   
    Empty empty = new Empty();
    empty.initialise(new FindOptions());

    assertEquals(Result.FAIL, empty.apply(item));
View Full Code Here

  public void applyEmptyDirectory() throws IOException {
    FileStatus fileStatus = mock(FileStatus.class);
    when(fileStatus.isDirectory()).thenReturn(false);
    fs.setFileStatus("emptyDirectory", fileStatus);
    fs.setListStatus("emptyDirectory", new FileStatus[0]);
    PathData item = new PathData("emptyDirectory", fs.getConf());
   
    Empty empty = new Empty();
    empty.initialise(new FindOptions());

    assertEquals(Result.PASS, empty.apply(item));
View Full Code Here

  public void applyNotEmptyDirectory() throws IOException {
    FileStatus fileStatus = mock(FileStatus.class);
    when(fileStatus.isDirectory()).thenReturn(false);
    fs.setFileStatus("notEmptyDirectory", fileStatus);
    fs.setListStatus("notEmptyDirectory", new FileStatus[] {mock(FileStatus.class)});
    PathData item = new PathData("notEmptyDirectory", fs.getConf());
   
    Empty empty = new Empty();
    empty.initialise(new FindOptions());

    assertEquals(Result.PASS, empty.apply(item));
View Full Code Here

    FindOptions options = new FindOptions();
    options.setOut(out);
    print.initialise(options);
   
    String filename = "/one/two/test";
    PathData item = new PathData(filename, conf);
    assertEquals(Result.PASS, print.apply(item));
    verify(out).println(filename + '\0');
    verifyNoMoreInteractions(out);
  }
View Full Code Here

    FileStatus fileStatus = mock(FileStatus.class);
    when(fileStatus.getPath()).thenReturn(new Path(pathname));
   
    fs.setFileStatus("test", fileStatus);
    fs.setGlobStatus("test", new FileStatus[]{fileStatus});
    item = new PathData(pathname, fs.getConf());
   
    TestCommand.testOut = out;
    TestCommand.testErr = err;
    TestCommand.testConf = conf;
  }
View Full Code Here

    FileStatus fstat1 = mock(FileStatus.class);
    when(fstat1.getPath()).thenReturn(new Path("test1"));
    when(fstat1.toString()).thenReturn("test1");
    fs.setFileStatus("test1", fstat1);
    fs.setGlobStatus("test1", new FileStatus[]{fstat1});
    PathData item1 = new PathData("test1", fs.getConf());

    FileStatus fstat2 = mock(FileStatus.class);
    when(fstat2.getPath()).thenReturn(new Path("test2"));
    when(fstat2.toString()).thenReturn("test2");
    fs.setFileStatus("test2", fstat2);
    fs.setGlobStatus("test2", new FileStatus[]{fstat2});
    PathData item2 = new PathData("test2", fs.getConf());

    FileStatus fstat3 = mock(FileStatus.class);
    when(fstat3.getPath()).thenReturn(new Path("test3"));
    when(fstat3.toString()).thenReturn("test3");
    fs.setFileStatus("test3", fstat3);
    fs.setGlobStatus("test3", new FileStatus[]{fstat3});
    PathData item3 = new PathData("test3", fs.getConf());
   
    assertEquals(Result.PASS, ok.apply(item1));
    verifyNoMoreInteractions(out);
    verifyNoMoreInteractions(err);
   
    assertEquals(Result.PASS, ok.apply(item2));
    verify(out).println("TestCommand.processPath:"+item1.toString());
    verify(out).println("TestCommand.processPath:"+item2.toString());
    verifyNoMoreInteractions(out);
    verify(err).print("\"testCommand " + item1.toString() + " " + item2.toString() + "\"?");
    verifyNoMoreInteractions(err);
   
    assertEquals(Result.PASS, ok.apply(item3));
    verifyNoMoreInteractions(out);
    verifyNoMoreInteractions(err);

    in.reset();
    ok.finish();
    verify(out).println("TestCommand.processPath:"+item3.toString());
    verifyNoMoreInteractions(out);
    verify(err).print("\"testCommand " + item3.toString() + "\"?");
    verifyNoMoreInteractions(err);
  }
View Full Code Here

   
    FileStatus fourDaysStat = mock(FileStatus.class);
    when(fourDaysStat.getAccessTime()).thenReturn(NOW - (4l * MIN));
    when(fourDaysStat.toString()).thenReturn("fourDays");
    fs.setFileStatus("fourDays", fourDaysStat);
    fourDays = new PathData("fourDays", conf);

    FileStatus fiveDaysStat = mock(FileStatus.class);
    when(fiveDaysStat.getAccessTime()).thenReturn(NOW - (5l * MIN));
    when(fiveDaysStat.toString()).thenReturn("fiveDays");
    fs.setFileStatus("fiveDays", fiveDaysStat);
    fiveDays = new PathData("fiveDays", conf);

    FileStatus fiveDaysMinus1Stat = mock(FileStatus.class);
    when(fiveDaysMinus1Stat.getAccessTime()).thenReturn(NOW - ((5l * MIN) - 1));
    when(fiveDaysMinus1Stat.toString()).thenReturn("fiveDaysMinus");
    fs.setFileStatus("fiveDaysMinus", fiveDaysMinus1Stat);
    fiveDaysMinus = new PathData("fiveDaysMinus", conf);

    FileStatus sixDaysStat = mock(FileStatus.class);
    when(sixDaysStat.getAccessTime()).thenReturn(NOW - (6l * MIN));
    when(sixDaysStat.toString()).thenReturn("sixDays");
    fs.setFileStatus("sixDays", sixDaysStat);
    sixDays = new PathData("sixDays", conf);

    FileStatus sixDaysMinus1Stat = mock(FileStatus.class);
    when(sixDaysMinus1Stat.getAccessTime()).thenReturn(NOW - ((6l * MIN) - 1));
    when(sixDaysMinus1Stat.toString()).thenReturn("fiveDaysPlus");
    fs.setFileStatus("fiveDaysPlus", sixDaysMinus1Stat);
    fiveDaysPlus = new PathData("fiveDaysPlus", conf);

  }
View Full Code Here

  @Test
  public void applyPass() throws IOException{
    FileStatus fileStatus = mock(FileStatus.class);
    when(fileStatus.getModificationTime()).thenReturn(NOW - (4l*86400000));
    fs.setFileStatus("newer.file", fileStatus);
    PathData item = new PathData("/directory/path/newer.file", fs.getConf());
    assertEquals(Result.PASS, newer.apply(item));
  }
View Full Code Here

  @Test
  public void applyFail() throws IOException{
    FileStatus fileStatus = mock(FileStatus.class);
    when(fileStatus.getModificationTime()).thenReturn(NOW - (6l*86400000));
    fs.setFileStatus("older.file", fileStatus);
    PathData item = new PathData("/directory/path/older.file", fs.getConf());
    assertEquals(Result.FAIL, newer.apply(item));
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.fs.shell.PathData

Copyright © 2018 www.massapicom. 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.