@Test
  public void viewAndRefCountTest() throws IOException, StoreException {
    LogSegmentName segmentName = LogSegmentName.generateFirstSegmentName(false);
    LogSegment segment = getSegment(segmentName, STANDARD_SEGMENT_SIZE, true);
    try {
      long startOffset = segment.getStartOffset();
      int readSize = 100;
      int viewCount = 5;
      byte[] data = appendRandomData(segment, readSize * viewCount);

      for (int i = 0; i < viewCount; i++) {
        getAndVerifyView(segment, startOffset, i * readSize, data, i + 1);
      }

      for (int i = 0; i < viewCount; i++) {
        segment.closeView();
        assertEquals("Ref count is not as expected", viewCount - i - 1, segment.refCount());
      }
    } finally {
      closeSegmentAndDeleteFile(segment);
    }
  }
Verifies getting and closing views and makes sure that data and ref counts are consistent.
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/LogSegmentTest.java