public OutputStream asOutputStream() {
    return outputStream;
  }
@Test
  public void testLexicographicalComparator() throws Exception {
    RandomAccessData streamA = new RandomAccessData();
    streamA.asOutputStream().write(TEST_DATA_A);
    RandomAccessData streamB = new RandomAccessData();
    streamB.asOutputStream().write(TEST_DATA_B);
    RandomAccessData streamC = new RandomAccessData();
    streamC.asOutputStream().write(TEST_DATA_C);
    assertTrue(RandomAccessData.UNSIGNED_LEXICOGRAPHICAL_COMPARATOR.compare(streamA, streamB) < 0);
    assertTrue(RandomAccessData.UNSIGNED_LEXICOGRAPHICAL_COMPARATOR.compare(streamB, streamA) > 0);
    assertTrue(RandomAccessData.UNSIGNED_LEXICOGRAPHICAL_COMPARATOR.compare(streamB, streamB) == 0);
    // Check common prefix length.
    assertEquals(
        2,
        RandomAccessData.UNSIGNED_LEXICOGRAPHICAL_COMPARATOR.commonPrefixLength(streamB, streamC));
    // Check that we honor the start offset.
    assertTrue(
        RandomAccessData.UNSIGNED_LEXICOGRAPHICAL_COMPARATOR.compare(streamB, streamC, 3) == 0);
    // Test positive infinity comparisons.
    assertTrue(
        RandomAccessData.UNSIGNED_LEXICOGRAPHICAL_COMPARATOR.compare(
                streamA, RandomAccessData.POSITIVE_INFINITY)
            < 0);
    assertTrue(
        RandomAccessData.UNSIGNED_LEXICOGRAPHICAL_COMPARATOR.compare(
                RandomAccessData.POSITIVE_INFINITY, RandomAccessData.POSITIVE_INFINITY)
            == 0);
    assertTrue(
        RandomAccessData.UNSIGNED_LEXICOGRAPHICAL_COMPARATOR.compare(
                RandomAccessData.POSITIVE_INFINITY, streamA)
            > 0);
  }