@Test
 public void getName() {
   Count count = new Count();
   String actual = count.getName();
   String expected = "count";
   assertEquals("Count.getName", expected, actual);
 }
 @Test
 public void getUsage() {
   Count count = new Count();
   String actual = count.getUsage();
   String expected = "-count [-q] [-h] [-v] [-t [<storage type>]] <path> ...";
   assertEquals("Count.getUsage", expected, actual);
 }
 @Test
 public void isDeprecated() {
   Count count = new Count();
   boolean actual = count.isDeprecated();
   boolean expected = false;
   assertEquals("Count.isDeprecated", expected, actual);
 }
 @Test
 public void getReplacementCommand() {
   Count count = new Count();
   String actual = count.getReplacementCommand();
   String expected = null;
   assertEquals("Count.getReplacementCommand", expected, actual);
 }
  @Test
  public void processPathWithQuotasByMultipleStorageTypesContent() throws Exception {
    Path path = new Path("mockfs:/test");

    when(mockFs.getFileStatus(eq(path))).thenReturn(fileStat);
    PathData pathData = new PathData(path.toString(), conf);

    PrintStream out = mock(PrintStream.class);

    Count count = new Count();
    count.out = out;

    LinkedList<String> options = new LinkedList<String>();
    options.add("-q");
    options.add("-t");
    options.add("SSD,DISK");
    options.add("dummy");
    count.processOptions(options);
    count.processPath(pathData);
    String withStorageType =
        BYTES
            + StorageType.SSD.toString()
            + " "
            + StorageType.DISK.toString()
            + " "
            + pathData.toString();
    verify(out).println(withStorageType);
    verifyNoMoreInteractions(out);
  }
  @Test
  public void processPathWithQuotasByQTVH() throws Exception {
    Path path = new Path("mockfs:/test");

    when(mockFs.getFileStatus(eq(path))).thenReturn(fileStat);

    PrintStream out = mock(PrintStream.class);

    Count count = new Count();
    count.out = out;

    LinkedList<String> options = new LinkedList<String>();
    options.add("-q");
    options.add("-t");
    options.add("-v");
    options.add("-h");
    options.add("dummy");
    count.processOptions(options);
    String withStorageTypeHeader =
        // <----13---> <-------17------>
        "    SSD_QUOTA     REM_SSD_QUOTA "
            + "   DISK_QUOTA    REM_DISK_QUOTA "
            + "ARCHIVE_QUOTA REM_ARCHIVE_QUOTA "
            + "PATHNAME";
    verify(out).println(withStorageTypeHeader);
    verifyNoMoreInteractions(out);
  }
 // check no options is handled correctly
 @Test
 public void processOptionsNoOptions() {
   LinkedList<String> options = new LinkedList<String>();
   options.add("dummy");
   Count count = new Count();
   count.processOptions(options);
   assertFalse(count.isShowQuotas());
 }
 // check missing arguments is handled correctly
 @Test
 public void processOptionsMissingArgs() {
   LinkedList<String> options = new LinkedList<String>();
   Count count = new Count();
   try {
     count.processOptions(options);
     fail("Count.processOptions - NotEnoughArgumentsException not thrown");
   } catch (NotEnoughArgumentsException e) {
   }
   assertFalse(count.isShowQuotas());
 }
  // check the correct header is produced with no quotas (-v)
  @Test
  public void processOptionsHeaderNoQuotas() {
    LinkedList<String> options = new LinkedList<String>();
    options.add("-v");
    options.add("dummy");

    PrintStream out = mock(PrintStream.class);

    Count count = new Count();
    count.out = out;

    count.processOptions(options);

    String noQuotasHeader =
        // <----12----> <----12----> <-------18------->
        "   DIR_COUNT   FILE_COUNT       CONTENT_SIZE PATHNAME";
    verify(out).println(noQuotasHeader);
    verifyNoMoreInteractions(out);
  }
Exemplo n.º 10
0
  @Test
  public void processPathNoQuotasHuman() throws Exception {
    Path path = new Path("mockfs:/test");

    when(mockFs.getFileStatus(eq(path))).thenReturn(fileStat);
    PathData pathData = new PathData(path.toString(), conf);

    PrintStream out = mock(PrintStream.class);

    Count count = new Count();
    count.out = out;

    LinkedList<String> options = new LinkedList<String>();
    options.add("-h");
    options.add("dummy");
    count.processOptions(options);

    count.processPath(pathData);
    verify(out).println(HUMAN + NO_QUOTAS + path.toString());
  }
Exemplo n.º 11
0
  // check the correct description is returned
  @Test
  public void getDescription() {
    Count count = new Count();
    String actual = count.getDescription();
    String expected =
        "Count the number of directories, files and bytes under the paths\n"
            + "that match the specified file pattern.  The output columns are:\n"
            + "DIR_COUNT FILE_COUNT CONTENT_SIZE PATHNAME\n"
            + "or, with the -q option:\n"
            + "QUOTA REM_QUOTA SPACE_QUOTA REM_SPACE_QUOTA\n"
            + "      DIR_COUNT FILE_COUNT CONTENT_SIZE PATHNAME\n"
            + "The -h option shows file sizes in human readable format.\n"
            + "The -v option displays a header line.\n"
            + "The -t option displays quota by storage types.\n"
            + "It must be used with -q option.\n"
            + "If a comma-separated list of storage types is given after the -t option, \n"
            + "it displays the quota and usage for the specified types. \n"
            + "Otherwise, it displays the quota and usage for all the storage \n"
            + "types that support quota";

    assertEquals("Count.getDescription", expected, actual);
  }
Exemplo n.º 12
0
 @Test
 public void processOptionsAll() {
   LinkedList<String> options = new LinkedList<String>();
   options.add("-q");
   options.add("-h");
   options.add("-t");
   options.add("SSD");
   options.add("dummy");
   Count count = new Count();
   count.processOptions(options);
   assertTrue(count.isShowQuotas());
   assertTrue(count.isHumanReadable());
   assertTrue(count.isShowQuotabyType());
   assertEquals(1, count.getStorageTypes().size());
   assertEquals(StorageType.SSD, count.getStorageTypes().get(0));
 }