@Test
  public void testNumHistories() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PrintStream ops = new PrintStream(os);
    BeeLine beeline = new BeeLine();
    beeline.getOpts().setHistoryFile(fileName);
    beeline.setOutputStream(ops);
    Method method = beeline.getClass().getDeclaredMethod("setupHistory");
    method.setAccessible(true);
    method.invoke(beeline);
    beeline.initializeConsoleReader(null);
    beeline.dispatch("!history");
    String output = os.toString("UTF-8");
    int numHistories = output.split("\n").length;
    Assert.assertEquals(10, numHistories);
    beeline.close();
  }
TestBeeLineHistory - executes tests of the !history command of BeeLine
beeline/src/test/org/apache/hive/beeline/TestBeeLineHistory.java