@Test public void testVersionLimits() throws Exception {
  byte[] TABLE=Bytes.toBytes("testVersionLimits");
  byte[][] FAMILIES=makeNAscii(FAMILY,3);
  int[] LIMITS={1,3,5};
  long[] STAMPS=makeStamps(10);
  byte[][] VALUES=makeNAscii(VALUE,10);
  HTable ht=TEST_UTIL.createTable(TABLE,FAMILIES,LIMITS);
  Put put=new Put(ROW);
  put.add(FAMILIES[0],QUALIFIER,STAMPS[0],VALUES[0]);
  put.add(FAMILIES[0],QUALIFIER,STAMPS[1],VALUES[1]);
  put.add(FAMILIES[1],QUALIFIER,STAMPS[0],VALUES[0]);
  put.add(FAMILIES[1],QUALIFIER,STAMPS[1],VALUES[1]);
  put.add(FAMILIES[1],QUALIFIER,STAMPS[2],VALUES[2]);
  put.add(FAMILIES[1],QUALIFIER,STAMPS[3],VALUES[3]);
  put.add(FAMILIES[2],QUALIFIER,STAMPS[0],VALUES[0]);
  put.add(FAMILIES[2],QUALIFIER,STAMPS[1],VALUES[1]);
  put.add(FAMILIES[2],QUALIFIER,STAMPS[2],VALUES[2]);
  put.add(FAMILIES[2],QUALIFIER,STAMPS[3],VALUES[3]);
  put.add(FAMILIES[2],QUALIFIER,STAMPS[4],VALUES[4]);
  put.add(FAMILIES[2],QUALIFIER,STAMPS[5],VALUES[5]);
  put.add(FAMILIES[2],QUALIFIER,STAMPS[6],VALUES[6]);
  ht.put(put);
  Get get=new Get(ROW);
  get.addColumn(FAMILIES[0],QUALIFIER);
  get.setMaxVersions(Integer.MAX_VALUE);
  Result result=ht.get(get);
  assertNResult(result,ROW,FAMILIES[0],QUALIFIER,new long[]{STAMPS[1]},new byte[][]{VALUES[1]},0,0);
  get=new Get(ROW);
  get.addFamily(FAMILIES[0]);
  get.setMaxVersions(Integer.MAX_VALUE);
  result=ht.get(get);
  assertNResult(result,ROW,FAMILIES[0],QUALIFIER,new long[]{STAMPS[1]},new byte[][]{VALUES[1]},0,0);
  Scan scan=new Scan(ROW);
  scan.addColumn(FAMILIES[0],QUALIFIER);
  scan.setMaxVersions(Integer.MAX_VALUE);
  result=getSingleScanResult(ht,scan);
  assertNResult(result,ROW,FAMILIES[0],QUALIFIER,new long[]{STAMPS[1]},new byte[][]{VALUES[1]},0,0);
  scan=new Scan(ROW);
  scan.addFamily(FAMILIES[0]);
  scan.setMaxVersions(Integer.MAX_VALUE);
  result=getSingleScanResult(ht,scan);
  assertNResult(result,ROW,FAMILIES[0],QUALIFIER,new long[]{STAMPS[1]},new byte[][]{VALUES[1]},0,0);
  get=new Get(ROW);
  get.addColumn(FAMILIES[1],QUALIFIER);
  get.setMaxVersions(Integer.MAX_VALUE);
  result=ht.get(get);
  assertNResult(result,ROW,FAMILIES[1],QUALIFIER,new long[]{STAMPS[1],STAMPS[2],STAMPS[3]},new byte[][]{VALUES[1],VALUES[2],VALUES[3]},0,2);
  get=new Get(ROW);
  get.addFamily(FAMILIES[1]);
  get.setMaxVersions(Integer.MAX_VALUE);
  result=ht.get(get);
  assertNResult(result,ROW,FAMILIES[1],QUALIFIER,new long[]{STAMPS[1],STAMPS[2],STAMPS[3]},new byte[][]{VALUES[1],VALUES[2],VALUES[3]},0,2);
  scan=new Scan(ROW);
  scan.addColumn(FAMILIES[1],QUALIFIER);
  scan.setMaxVersions(Integer.MAX_VALUE);
  result=getSingleScanResult(ht,scan);
  assertNResult(result,ROW,FAMILIES[1],QUALIFIER,new long[]{STAMPS[1],STAMPS[2],STAMPS[3]},new byte[][]{VALUES[1],VALUES[2],VALUES[3]},0,2);
  scan=new Scan(ROW);
  scan.addFamily(FAMILIES[1]);
  scan.setMaxVersions(Integer.MAX_VALUE);
  result=getSingleScanResult(ht,scan);
  assertNResult(result,ROW,FAMILIES[1],QUALIFIER,new long[]{STAMPS[1],STAMPS[2],STAMPS[3]},new byte[][]{VALUES[1],VALUES[2],VALUES[3]},0,2);
  get=new Get(ROW);
  get.addColumn(FAMILIES[2],QUALIFIER);
  get.setMaxVersions(Integer.MAX_VALUE);
  result=ht.get(get);
  assertNResult(result,ROW,FAMILIES[2],QUALIFIER,new long[]{STAMPS[2],STAMPS[3],STAMPS[4],STAMPS[5],STAMPS[6]},new byte[][]{VALUES[2],VALUES[3],VALUES[4],VALUES[5],VALUES[6]},0,4);
  get=new Get(ROW);
  get.addFamily(FAMILIES[2]);
  get.setMaxVersions(Integer.MAX_VALUE);
  result=ht.get(get);
  assertNResult(result,ROW,FAMILIES[2],QUALIFIER,new long[]{STAMPS[2],STAMPS[3],STAMPS[4],STAMPS[5],STAMPS[6]},new byte[][]{VALUES[2],VALUES[3],VALUES[4],VALUES[5],VALUES[6]},0,4);
  scan=new Scan(ROW);
  scan.addColumn(FAMILIES[2],QUALIFIER);
  scan.setMaxVersions(Integer.MAX_VALUE);
  result=getSingleScanResult(ht,scan);
  assertNResult(result,ROW,FAMILIES[2],QUALIFIER,new long[]{STAMPS[2],STAMPS[3],STAMPS[4],STAMPS[5],STAMPS[6]},new byte[][]{VALUES[2],VALUES[3],VALUES[4],VALUES[5],VALUES[6]},0,4);
  scan=new Scan(ROW);
  scan.addFamily(FAMILIES[2]);
  scan.setMaxVersions(Integer.MAX_VALUE);
  result=getSingleScanResult(ht,scan);
  assertNResult(result,ROW,FAMILIES[2],QUALIFIER,new long[]{STAMPS[2],STAMPS[3],STAMPS[4],STAMPS[5],STAMPS[6]},new byte[][]{VALUES[2],VALUES[3],VALUES[4],VALUES[5],VALUES[6]},0,4);
  get=new Get(ROW);
  get.setMaxVersions(Integer.MAX_VALUE);
  result=ht.get(get);
  assertTrue("Expected 9 keys but received " + result.size(),result.size() == 9);
  get=new Get(ROW);
  get.addFamily(FAMILIES[0]);
  get.addFamily(FAMILIES[1]);
  get.addFamily(FAMILIES[2]);
  get.setMaxVersions(Integer.MAX_VALUE);
  result=ht.get(get);
  assertTrue("Expected 9 keys but received " + result.size(),result.size() == 9);
  get=new Get(ROW);
  get.addColumn(FAMILIES[0],QUALIFIER);
  get.addColumn(FAMILIES[1],QUALIFIER);
  get.addColumn(FAMILIES[2],QUALIFIER);
  get.setMaxVersions(Integer.MAX_VALUE);
  result=ht.get(get);
  assertTrue("Expected 9 keys but received " + result.size(),result.size() == 9);
  scan=new Scan(ROW);
  scan.setMaxVersions(Integer.MAX_VALUE);
  result=getSingleScanResult(ht,scan);
  assertTrue("Expected 9 keys but received " + result.size(),result.size() == 9);
  scan=new Scan(ROW);
  scan.setMaxVersions(Integer.MAX_VALUE);
  scan.addFamily(FAMILIES[0]);
  scan.addFamily(FAMILIES[1]);
  scan.addFamily(FAMILIES[2]);
  result=getSingleScanResult(ht,scan);
  assertTrue("Expected 9 keys but received " + result.size(),result.size() == 9);
  scan=new Scan(ROW);
  scan.setMaxVersions(Integer.MAX_VALUE);
  scan.addColumn(FAMILIES[0],QUALIFIER);
  scan.addColumn(FAMILIES[1],QUALIFIER);
  scan.addColumn(FAMILIES[2],QUALIFIER);
  result=getSingleScanResult(ht,scan);
  assertTrue("Expected 9 keys but received " + result.size(),result.size() == 9);
}
