@Test
  public void testHistory() 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");
    String[] tmp = output.split("\n");
    Assert.assertTrue(tmp[0].equals("1     : select 1;"));
    Assert.assertTrue(tmp[9].equals("10    : select 10;"));
    beeline.close();
  }
TestBeeLineHistory - executes tests of the !history command of BeeLine
beeline/src/test/org/apache/hive/beeline/TestBeeLineHistory.java