Search in sources :

Example 21 with PrintStream

use of java.io.PrintStream in project hadoop by apache.

the class TestCount method processPathWithQuotaUsage.

private void processPathWithQuotaUsage(boolean rawBytes) 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>();
    if (!rawBytes) {
        options.add("-h");
    }
    options.add("-u");
    options.add("dummy");
    count.processOptions(options);
    count.processPath(pathData);
    String withStorageType = (rawBytes ? BYTES : HUMAN) + QUOTAS_AND_USAGE + pathData.toString();
    verify(out).println(withStorageType);
    verifyNoMoreInteractions(out);
}
Also used : Path(org.apache.hadoop.fs.Path) PrintStream(java.io.PrintStream) LinkedList(java.util.LinkedList)

Example 22 with PrintStream

use of java.io.PrintStream in project hadoop by apache.

the class TestCount method processOptionsHeaderWithQuotas.

// check the correct header is produced with quotas (-q -v)
@Test
public void processOptionsHeaderWithQuotas() {
    LinkedList<String> options = new LinkedList<String>();
    options.add("-q");
    options.add("-v");
    options.add("dummy");
    PrintStream out = mock(PrintStream.class);
    Count count = new Count();
    count.out = out;
    count.processOptions(options);
    String withQuotasHeader = // <----12----> <-----15------> <-----15------> <-----15------>
    "       QUOTA       REM_QUOTA     SPACE_QUOTA REM_SPACE_QUOTA " + // <----12----> <----12----> <-------18------->
    "   DIR_COUNT   FILE_COUNT       CONTENT_SIZE PATHNAME";
    verify(out).println(withQuotasHeader);
    verifyNoMoreInteractions(out);
}
Also used : PrintStream(java.io.PrintStream) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 23 with PrintStream

use of java.io.PrintStream in project hadoop by apache.

the class TestCount method processPathWithQuotasByStorageTypesHeader.

@Test
public void processPathWithQuotasByStorageTypesHeader() 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("-v");
    options.add("-t");
    options.add("all");
    options.add("dummy");
    count.processOptions(options);
    String withStorageTypeHeader = // <----13---> <-------17------> <----13-----> <------17------->
    "    SSD_QUOTA     REM_SSD_QUOTA    DISK_QUOTA    REM_DISK_QUOTA " + // <----13---> <-------17------>
    "ARCHIVE_QUOTA REM_ARCHIVE_QUOTA " + "PATHNAME";
    verify(out).println(withStorageTypeHeader);
    verifyNoMoreInteractions(out);
}
Also used : Path(org.apache.hadoop.fs.Path) PrintStream(java.io.PrintStream) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 24 with PrintStream

use of java.io.PrintStream in project hadoop by apache.

the class TestCount method processPathWithQuotasBySSDStorageTypesHeader.

@Test
public void processPathWithQuotasBySSDStorageTypesHeader() 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("-v");
    options.add("-t");
    options.add("SSD");
    options.add("dummy");
    count.processOptions(options);
    String withStorageTypeHeader = // <----13---> <-------17------>
    "    SSD_QUOTA     REM_SSD_QUOTA " + "PATHNAME";
    verify(out).println(withStorageTypeHeader);
    verifyNoMoreInteractions(out);
}
Also used : Path(org.apache.hadoop.fs.Path) PrintStream(java.io.PrintStream) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 25 with PrintStream

use of java.io.PrintStream in project hadoop by apache.

the class TestCount method processPathNoQuotas.

// check counts without quotas are reported correctly
@Test
public void processPathNoQuotas() 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("dummy");
    count.processOptions(options);
    count.processPath(pathData);
    verify(out).println(BYTES + NO_QUOTAS + path.toString());
    verifyNoMoreInteractions(out);
}
Also used : Path(org.apache.hadoop.fs.Path) PrintStream(java.io.PrintStream) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

PrintStream (java.io.PrintStream)1582 ByteArrayOutputStream (java.io.ByteArrayOutputStream)687 Test (org.junit.Test)481 File (java.io.File)276 IOException (java.io.IOException)257 FileOutputStream (java.io.FileOutputStream)177 ArrayList (java.util.ArrayList)78 FileNotFoundException (java.io.FileNotFoundException)75 OutputStream (java.io.OutputStream)72 Before (org.junit.Before)57 BufferedReader (java.io.BufferedReader)50 Date (java.util.Date)44 Map (java.util.Map)44 BufferedOutputStream (java.io.BufferedOutputStream)41 Path (org.apache.hadoop.fs.Path)41 UnsupportedEncodingException (java.io.UnsupportedEncodingException)40 Matchers.anyString (org.mockito.Matchers.anyString)37 InputStreamReader (java.io.InputStreamReader)35 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)35 HashMap (java.util.HashMap)32