private String connectWithPromptAndVerify(List<String> argList, String prompt,
    boolean testMaxColumnWidthOption, Integer expectedMaxColumnWidth, String hiveConfKey,
    String expectedHiveConfValue) throws Exception {
    BeeLine beeLine = null;
    InputStream inputStream = null;
    try {
      beeLine = new BeeLine();
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      PrintStream beelineOutputStream = new PrintStream(os);
      beeLine.setOutputStream(beelineOutputStream);
      beeLine.setErrorStream(beelineOutputStream);
      String[] args = argList.toArray(new String[argList.size()]);
      if (prompt != null) {
        inputStream = new ByteArrayInputStream(prompt.getBytes());
      }
      Assert.assertTrue(beeLine.begin(args, inputStream) == 0);
      if (testMaxColumnWidthOption) {
        int maxColumnWidth = beeLine.getOpts().getMaxColumnWidth();
        Assert.assertTrue(
          "Expected max columnWidth to be " + expectedMaxColumnWidth + " found " + maxColumnWidth,
          maxColumnWidth == expectedMaxColumnWidth);
      }
      if (hiveConfKey != null) {
        String hiveConfValue = beeLine.getOpts().getHiveConfVariables().get(hiveConfKey);
        Assert.assertTrue(
          "Expected " + expectedHiveConfValue + " got " + hiveConfValue + " for " + hiveConfKey,
          expectedHiveConfValue.equalsIgnoreCase(hiveConfValue));
      }
      String output = os.toString("UTF-8");
      LOG.debug(output);
      return output;
    } finally {
      if (beeLine != null) {
        beeLine.close();
      }
      if(inputStream != null) {
        inputStream.close();
      }
    }
  }
Connects to miniHS2 using beeline with the given string value for the prompt if the prompt is
null, uses beeline with null inputstream in which this method expects that the argList is
sufficient to make a successful Beeline connection with no prompt required from user

@param argList - arguments list for the beeline
@param prompt - String value to be given to beeline prompt during connection
@param beelineOptName - Name of BeelineOpt to be verified
@param beelineOptValue - Expected value of value of BeeLineOpt
@param hiveConfKey - hive conf variable name to verify
@param expectedHiveConfValue - Expected value of hive conf variable
@return output of beeline from outputstream
@throws Exception
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeelinePasswordOption.java