private PrintStream headerPrintingTestDriver(Schema mockSchema) throws CommandProcessorException {
    CliDriver cliDriver = new CliDriver();

    // We want the driver to try to print the header...

    Configuration conf = mock(Configuration.class);
    when(conf.getBoolean(eq(ConfVars.HIVE_CLI_PRINT_HEADER.varname), anyBoolean()))
        .thenReturn(true);
    cliDriver.setConf(conf);

    IDriver proc = mock(IDriver.class);

    CommandProcessorResponse cpr = mock(CommandProcessorResponse.class);
    QueryState queryState = new QueryState.Builder().withGenerateNewQueryId(true).build();
    when(proc.run(anyString())).thenReturn(cpr);
    when(proc.getQueryState()).thenReturn(queryState);

    // and then see what happens based on the provided schema
    when(proc.getSchema()).thenReturn(mockSchema);

    CliSessionState mockSS = mock(CliSessionState.class);
    SessionStream mockOut = mock(SessionStream.class);

    mockSS.out = mockOut;

    cliDriver.processLocalCmd("use default;", proc, mockSS);
    return mockOut;
  }
Do the actual testing against a mocked CliDriver based on what type of schema

@param mockSchema
         Schema to throw against test
@return Output that would have been sent to the user
@throws CommandProcessorException
@throws CommandNeedRetryException
          won't actually be thrown
cli/src/test/org/apache/hadoop/hive/cli/TestCliDriverMethods.java