@Test
  public void testFillPatternAfterDefragmentation() {
    /*
     * Stores our allocated memory.
     */
    OffHeapStoredObject[] allocatedChunks = new OffHeapStoredObject[DEFRAGMENTATION_CHUNKS];

    /*
     * Use up most of our memory Our memory looks like [ ][ ][ ]
     */
    for (int i = 0; i < allocatedChunks.length; ++i) {
      allocatedChunks[i] =
          (OffHeapStoredObject) allocator.allocate(DEFRAGMENTATION_CHUNK_SIZE);
      allocatedChunks[i].validateFill();
    }

    /*
     * Release some of our allocated chunks.
     */
    for (int i = 0; i < 2; ++i) {
      allocatedChunks[i].release();
      allocatedChunks[i].validateFill();
    }

    /*
     * Now, allocate another chunk that is slightly larger than one of our initial chunks. This
     * should force a defragmentation causing our memory to look like [ ][ ].
     */
    OffHeapStoredObject slightlyLargerChunk =
        (OffHeapStoredObject) allocator.allocate(FORCE_DEFRAGMENTATION_CHUNK_SIZE);

    /*
     * Make sure the defragmented memory has the fill validation.
     */
    slightlyLargerChunk.validateFill();
  }
This tests that fill validation is working properly on newly created fragments after a
defragmentation.
geode-core/src/test/java/org/apache/geode/internal/offheap/MemoryAllocatorFillPatternJUnitTest.java