@Test
  public void testBigRanges() {
    SimpleRange ai = new SimpleRange(Bytes.toBytes("A"), Bytes.toBytes("I"));
    SimpleRange ae = new SimpleRange(Bytes.toBytes("A"), Bytes.toBytes("E"));
    SimpleRange ac = new SimpleRange(Bytes.toBytes("A"), Bytes.toBytes("C"));

    Collection<SimpleRange> bigOverlap = new ArrayList<>(8);
    bigOverlap.add(new SimpleRange(Bytes.toBytes("A"), Bytes.toBytes("E")));
    bigOverlap.add(new SimpleRange(Bytes.toBytes("A"), Bytes.toBytes("C")));
    bigOverlap.add(new SimpleRange(Bytes.toBytes("A"), Bytes.toBytes("B")));
    bigOverlap.add(new SimpleRange(Bytes.toBytes("B"), Bytes.toBytes("C")));
    bigOverlap.add(new SimpleRange(Bytes.toBytes("E"), Bytes.toBytes("H")));
    bigOverlap.add(ai);
    bigOverlap.add(ae);
    bigOverlap.add(ac);

    // Expect 1 range to be returned: ai
    List<SimpleRange> bigRanges = RegionSplitCalculator.findBigRanges(bigOverlap, 1);
    assertEquals(1, bigRanges.size());
    assertEquals(ai, bigRanges.get(0));

    // Expect 3 ranges to be returned: ai, ae and ac
    bigRanges = RegionSplitCalculator.findBigRanges(bigOverlap, 3);
    assertEquals(3, bigRanges.size());
    assertEquals(ai, bigRanges.get(0));

    SimpleRange r1 = bigRanges.get(1);
    SimpleRange r2 = bigRanges.get(2);
    assertEquals("A", Bytes.toString(r1.start));
    assertEquals("A", Bytes.toString(r2.start));
    String r1e = Bytes.toString(r1.end);
    String r2e = Bytes.toString(r2.end);
    assertTrue((r1e.equals("C") && r2e.equals("E")) || (r1e.equals("E") && r2e.equals("C")));
  }
This dumps data in a visually reasonable way for visual debugging. It has the basic iteration
structure.
hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitCalculator.java