private void testCommandEnclosedQuery(String enclosedQuery, String expectedPattern,
      boolean shouldMatch, List<String> argList, OutStream out) throws Throwable {

    List<String> copy = new ArrayList<String>(argList);
    copy.add("-e");
    copy.add(enclosedQuery);

    String output = testCommandLineScript(copy, null, out);
    boolean matches = output.contains(expectedPattern);
    if (shouldMatch != matches) {
      //failed
      fail("Output" + output + " should" +  (shouldMatch ? "" : " not") +
          " contain " + expectedPattern);
    }
  }
Attempt to execute the enclosed query with the -e option to BeeLine
Test for presence of an expected pattern
in the output (stdout or stderr), fail if not found
Print PASSED or FAILED
@param expectedPattern Text to look for in command output/error
@param shouldMatch true if the pattern should be found, false if it should not
@throws Exception on command execution error
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java