private void redirectOutputStream() {
    out = new ByteArrayOutputStream();
    origOut = System.out;
    System.setOut(new PrintStream(out));

    err = new ByteArrayOutputStream();
    origErr = System.err;
    System.setErr(new PrintStream(err));
  }
This method is used for verifying CMD to see whether the output contains the keywords provided.
beeline/src/test/org/apache/hive/beeline/cli/TestHiveCli.java