You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2016/02/22 22:43:44 UTC

[056/100] [abbrv] incubator-geode git commit: GEODE-831: unit test FreeListManager

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
deleted file mode 100644
index 81a59e3..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkJUnitTest.java
+++ /dev/null
@@ -1,921 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.gemstone.gemfire.internal.offheap;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.LogWriter;
-import com.gemstone.gemfire.compression.Compressor;
-import com.gemstone.gemfire.internal.DSCODE;
-import com.gemstone.gemfire.internal.HeapDataOutputStream;
-import com.gemstone.gemfire.internal.Version;
-import com.gemstone.gemfire.internal.cache.BytesAndBitsForCompactor;
-import com.gemstone.gemfire.internal.cache.CachePerfStats;
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
-import com.gemstone.gemfire.internal.cache.RegionEntryContext;
-import com.gemstone.gemfire.internal.offheap.MemoryBlock.State;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class GemFireChunkJUnitTest extends AbstractStoredObjectTestBase {
-
-  private MemoryAllocator ma;
-
-  static {
-    ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
-  }
-
-  @Before
-  public void setUp() {
-    OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
-    OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
-    LogWriter lw = mock(LogWriter.class);
-
-    ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, lw, 3, OffHeapStorage.MIN_SLAB_SIZE * 3, OffHeapStorage.MIN_SLAB_SIZE);
-  }
-
-  @After
-  public void tearDown() {
-    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
-  }
-
-  @Override
-  public Object getValue() {
-    return Long.valueOf(Long.MAX_VALUE);
-  }
-
-  @Override
-  public byte[] getValueAsByteArray() {
-    return convertValueToByteArray(getValue());
-  }
-
-  private byte[] convertValueToByteArray(Object value) {
-    return ByteBuffer.allocate(Long.SIZE / Byte.SIZE).putLong((Long) value).array();
-  }
-
-  @Override
-  public Object convertByteArrayToObject(byte[] valueInByteArray) {
-    return ByteBuffer.wrap(valueInByteArray).getLong();
-  }
-
-  @Override
-  public Object convertSerializedByteArrayToObject(byte[] valueInSerializedByteArray) {
-    return EntryEventImpl.deserialize(valueInSerializedByteArray);
-  }
-
-  @Override
-  public GemFireChunk createValueAsUnserializedStoredObject(Object value) {
-    byte[] valueInByteArray;
-    if (value instanceof Long) {
-      valueInByteArray = convertValueToByteArray(value);
-    } else {
-      valueInByteArray = (byte[]) value;
-    }
-
-    boolean isSerialized = false;
-    boolean isCompressed = false;
-
-    return createChunk(valueInByteArray, isSerialized, isCompressed);
-  }
-
-  @Override
-  public GemFireChunk createValueAsSerializedStoredObject(Object value) {
-    byte[] valueInSerializedByteArray = EntryEventImpl.serialize(value);
-
-    boolean isSerialized = true;
-    boolean isCompressed = false;
-
-    return createChunk(valueInSerializedByteArray, isSerialized, isCompressed);
-  }
-
-  private GemFireChunk createChunk(byte[] v, boolean isSerialized, boolean isCompressed) {
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed, GemFireChunk.TYPE);
-    return chunk;
-  }
-
-  @Test
-  public void chunkCanBeCreatedFromAnotherChunk() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-
-    GemFireChunk newChunk = new GemFireChunk(chunk);
-
-    assertNotNull(newChunk);
-    assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
-
-    chunk.release();
-  }
-
-  @Test
-  public void chunkCanBeCreatedWithOnlyMemoryAddress() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-
-    GemFireChunk newChunk = new GemFireChunk(chunk.getMemoryAddress());
-
-    assertNotNull(newChunk);
-    assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
-
-    chunk.release();
-  }
-
-  @Test
-  public void chunkSliceCanBeCreatedFromAnotherChunk() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-
-    int position = 1;
-    int end = 2;
-
-    GemFireChunk newChunk = (GemFireChunk) chunk.slice(position, end);
-
-    assertNotNull(newChunk);
-    assertThat(newChunk.getClass()).isEqualTo(GemFireChunkSlice.class);
-    assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
-
-    chunk.release();
-  }
-
-  @Test
-  public void fillSerializedValueShouldFillWrapperWithSerializedValueIfValueIsSerialized() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    // mock the things
-    BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
-
-    byte userBits = 0;
-    byte serializedUserBits = 1;
-    chunk.fillSerializedValue(wrapper, userBits);
-
-    verify(wrapper, times(1)).setChunkData(chunk, serializedUserBits);
-
-    chunk.release();
-  }
-
-  @Test
-  public void fillSerializedValueShouldFillWrapperWithDeserializedValueIfValueIsNotSerialized() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-
-    // mock the things
-    BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
-
-    byte userBits = 1;
-    chunk.fillSerializedValue(wrapper, userBits);
-
-    verify(wrapper, times(1)).setChunkData(chunk, userBits);
-
-    chunk.release();
-  }
-
-  @Test
-  public void getShortClassNameShouldReturnShortClassName() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    assertThat(chunk.getShortClassName()).isEqualTo("GemFireChunk");
-
-    chunk.release();
-  }
-
-  @Test
-  public void chunksAreEqualsOnlyByAddress() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    GemFireChunk newChunk = new GemFireChunk(chunk.getMemoryAddress());
-    assertThat(chunk.equals(newChunk)).isTrue();
-
-    GemFireChunk chunkWithSameValue = createValueAsUnserializedStoredObject(getValue());
-    assertThat(chunk.equals(chunkWithSameValue)).isFalse();
-
-    Object someObject = getValue();
-    assertThat(chunk.equals(someObject)).isFalse();
-
-    chunk.release();
-    chunkWithSameValue.release();
-  }
-
-  @Test
-  public void chunksShouldBeComparedBySize() {
-    GemFireChunk chunk1 = createValueAsSerializedStoredObject(getValue());
-
-    GemFireChunk chunk2 = chunk1;
-    assertThat(chunk1.compareTo(chunk2)).isEqualTo(0);
-
-    GemFireChunk chunkWithSameValue = createValueAsSerializedStoredObject(getValue());
-    assertThat(chunk1.compareTo(chunkWithSameValue)).isEqualTo(Long.signum(chunk1.getMemoryAddress() - chunkWithSameValue.getMemoryAddress()));
-
-    GemFireChunk chunk3 = createValueAsSerializedStoredObject(Long.MAX_VALUE);
-    GemFireChunk chunk4 = createValueAsSerializedStoredObject(Long.MAX_VALUE);
-
-    int newSizeForChunk3 = 2;
-    int newSizeForChunk4 = 3;
-
-    assertThat(chunk3.compareTo(chunk4)).isEqualTo(Integer.signum(newSizeForChunk3 - newSizeForChunk4));
-
-    chunk1.release();
-    chunk4.release();
-  }
-
-  @Test
-  public void setSerializedShouldSetTheSerializedBit() {
-    Object regionEntryValue = getValue();
-    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
-
-    boolean isSerialized = false;
-    boolean isCompressed = false;
-
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed, GemFireChunk.TYPE);
-
-    int headerBeforeSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + Chunk.REF_COUNT_OFFSET);
-
-    assertThat(chunk.isSerialized()).isFalse();
-
-    chunk.setSerialized(true); // set to true
-
-    assertThat(chunk.isSerialized()).isTrue();
-
-    int headerAfterSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + Chunk.REF_COUNT_OFFSET);
-
-    assertThat(headerAfterSerializedBitSet).isEqualTo(headerBeforeSerializedBitSet | Chunk.IS_SERIALIZED_BIT);
-
-    chunk.release();
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void setSerialziedShouldThrowExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.release();
-    chunk.setSerialized(true);
-
-    chunk.release();
-  }
-
-  @Test
-  public void setCompressedShouldSetTheCompressedBit() {
-    Object regionEntryValue = getValue();
-    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
-
-    boolean isSerialized = false;
-    boolean isCompressed = false;
-
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed, GemFireChunk.TYPE);
-
-    int headerBeforeCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + Chunk.REF_COUNT_OFFSET);
-
-    assertThat(chunk.isCompressed()).isFalse();
-
-    chunk.setCompressed(true); // set to true
-
-    assertThat(chunk.isCompressed()).isTrue();
-
-    int headerAfterCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + Chunk.REF_COUNT_OFFSET);
-
-    assertThat(headerAfterCompressedBitSet).isEqualTo(headerBeforeCompressedBitSet | Chunk.IS_COMPRESSED_BIT);
-
-    chunk.release();
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void setCompressedShouldThrowExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.release();
-    chunk.setCompressed(true);
-
-    chunk.release();
-  }
-
-  @Test
-  public void setDataSizeShouldSetTheDataSizeBits() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-
-    int beforeSize = chunk.getDataSize();
-
-    chunk.setDataSize(2);
-
-    int afterSize = chunk.getDataSize();
-
-    assertThat(afterSize).isEqualTo(2);
-    assertThat(afterSize).isNotEqualTo(beforeSize);
-
-    chunk.release();
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void setDataSizeShouldThrowExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.release();
-    chunk.setDataSize(1);
-
-    chunk.release();
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void initializeUseCountShouldThrowIllegalStateExceptionIfChunkIsAlreadyRetained() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.retain();
-    chunk.initializeUseCount();
-
-    chunk.release();
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void initializeUseCountShouldThrowIllegalStateExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.release();
-    chunk.initializeUseCount();
-
-    chunk.release();
-  }
-
-  @Test
-  public void isSerializedPdxInstanceShouldReturnTrueIfItsPDXInstance() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    byte[] serailizedValue = chunk.getSerializedValue();
-    serailizedValue[0] = DSCODE.PDX;
-    chunk.setSerializedValue(serailizedValue);
-
-    assertThat(chunk.isSerializedPdxInstance()).isTrue();
-
-    serailizedValue = chunk.getSerializedValue();
-    serailizedValue[0] = DSCODE.PDX_ENUM;
-    chunk.setSerializedValue(serailizedValue);
-
-    assertThat(chunk.isSerializedPdxInstance()).isTrue();
-
-    serailizedValue = chunk.getSerializedValue();
-    serailizedValue[0] = DSCODE.PDX_INLINE_ENUM;
-    chunk.setSerializedValue(serailizedValue);
-
-    assertThat(chunk.isSerializedPdxInstance()).isTrue();
-
-    chunk.release();
-  }
-
-  @Test
-  public void isSerializedPdxInstanceShouldReturnFalseIfItsNotPDXInstance() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-    assertThat(chunk.isSerializedPdxInstance()).isFalse();
-
-    chunk.release();
-  }
-
-  @Test
-  public void checkDataEqualsByChunk() {
-    GemFireChunk chunk1 = createValueAsSerializedStoredObject(getValue());
-    GemFireChunk sameAsChunk1 = chunk1;
-
-    assertThat(chunk1.checkDataEquals(sameAsChunk1)).isTrue();
-
-    GemFireChunk unserializedChunk = createValueAsUnserializedStoredObject(getValue());
-    assertThat(chunk1.checkDataEquals(unserializedChunk)).isFalse();
-
-    GemFireChunk chunkDifferBySize = createValueAsSerializedStoredObject(getValue());
-    chunkDifferBySize.setSize(0);
-    assertThat(chunk1.checkDataEquals(chunkDifferBySize)).isFalse();
-
-    GemFireChunk chunkDifferByValue = createValueAsSerializedStoredObject(Long.MAX_VALUE - 1);
-    assertThat(chunk1.checkDataEquals(chunkDifferByValue)).isFalse();
-
-    GemFireChunk newChunk1 = createValueAsSerializedStoredObject(getValue());
-    assertThat(chunk1.checkDataEquals(newChunk1)).isTrue();
-
-    chunk1.release();
-    unserializedChunk.release();
-    chunkDifferBySize.release();
-    chunkDifferByValue.release();
-    newChunk1.release();
-  }
-
-  @Test
-  public void checkDataEqualsBySerializedValue() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-    assertThat(chunk.checkDataEquals(new byte[1])).isFalse();
-
-    GemFireChunk chunkDifferByValue = createValueAsSerializedStoredObject(Long.MAX_VALUE - 1);
-    assertThat(chunk.checkDataEquals(chunkDifferByValue.getSerializedValue())).isFalse();
-
-    GemFireChunk newChunk = createValueAsSerializedStoredObject(getValue());
-    assertThat(chunk.checkDataEquals(newChunk.getSerializedValue())).isTrue();
-
-    chunk.release();
-    chunkDifferByValue.release();
-    newChunk.release();
-  }
-
-  @Test
-  public void getDecompressedBytesShouldReturnDecompressedBytesIfCompressed() {
-    Object regionEntryValue = getValue();
-    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
-
-    boolean isSerialized = true;
-    boolean isCompressed = true;
-
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed, GemFireChunk.TYPE);
-
-    RegionEntryContext regionContext = mock(RegionEntryContext.class);
-    CachePerfStats cacheStats = mock(CachePerfStats.class);
-    Compressor compressor = mock(Compressor.class);
-
-    long startTime = 10000L;
-
-    // mock required things
-    when(regionContext.getCompressor()).thenReturn(compressor);
-    when(compressor.decompress(regionEntryValueAsBytes)).thenReturn(regionEntryValueAsBytes);
-    when(regionContext.getCachePerfStats()).thenReturn(cacheStats);
-    when(cacheStats.startDecompression()).thenReturn(startTime);
-
-    // invoke the thing
-    byte[] bytes = chunk.getDecompressedBytes(regionContext);
-
-    // verify the thing happened
-    verify(cacheStats, atLeastOnce()).startDecompression();
-    verify(compressor, times(1)).decompress(regionEntryValueAsBytes);
-    verify(cacheStats, atLeastOnce()).endDecompression(startTime);
-
-    assertArrayEquals(regionEntryValueAsBytes, bytes);
-
-    chunk.release();
-  }
-
-  @Test
-  public void incSizeShouldIncrementSize() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    int beforeSize = chunk.getSize();
-
-    chunk.incSize(1);
-    assertThat(chunk.getSize()).isEqualTo(beforeSize + 1);
-
-    chunk.incSize(2);
-    assertThat(chunk.getSize()).isEqualTo(beforeSize + 1 + 2);
-
-    chunk.release();
-  }
-
-  @Test
-  public void readyForFreeShouldResetTheRefCount() {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    int refCountBeforeFreeing = chunk.getRefCount();
-    assertThat(refCountBeforeFreeing).isEqualTo(1);
-
-    chunk.readyForFree();
-
-    int refCountAfterFreeing = chunk.getRefCount();
-    assertThat(refCountAfterFreeing).isEqualTo(0);
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void readyForAllocationShouldThrowExceptionIfAlreadyAllocated() {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    // chunk is already allocated when we created it, so calling readyForAllocation should throw exception.
-    chunk.readyForAllocation(GemFireChunk.TYPE);
-
-    chunk.release();
-  }
-
-  @Test
-  public void checkIsAllocatedShouldReturnIfAllocated() {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
-    chunk.checkIsAllocated();
-
-    chunk.release();
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void checkIsAllocatedShouldThrowExceptionIfNotAllocated() {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
-    chunk.release();
-    chunk.checkIsAllocated();
-
-    chunk.release();
-  }
-
-  @Test
-  public void sendToShouldWriteSerializedValueToDataOutputIfValueIsSerialized() throws IOException {
-    Chunk chunk = createValueAsSerializedStoredObject(getValue());
-    Chunk spyChunk = spy(chunk);
-
-    HeapDataOutputStream dataOutput = mock(HeapDataOutputStream.class);
-    ByteBuffer directByteBuffer = ByteBuffer.allocate(1024);
-
-    doReturn(directByteBuffer).when(spyChunk).createDirectByteBuffer();
-    doNothing().when(dataOutput).write(directByteBuffer);
-
-    spyChunk.sendTo(dataOutput);
-
-    verify(dataOutput, times(1)).write(directByteBuffer);
-
-    chunk.release();
-  }
-
-  @Test
-  public void sendToShouldWriteUnserializedValueToDataOutputIfValueIsUnserialized() throws IOException {
-    byte[] regionEntryValue = getValueAsByteArray();
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
-
-    // writeByte is a final method and cannot be mocked, so creating a real one
-    HeapDataOutputStream dataOutput = new HeapDataOutputStream(Version.CURRENT);
-
-    chunk.sendTo(dataOutput);
-
-    byte[] actual = dataOutput.toByteArray();
-
-    byte[] expected = new byte[regionEntryValue.length + 2];
-    expected[0] = DSCODE.BYTE_ARRAY;
-    expected[1] = (byte) regionEntryValue.length;
-    System.arraycopy(regionEntryValue, 0, expected, 2, regionEntryValue.length);
-
-    assertNotNull(dataOutput);
-    assertThat(actual).isEqualTo(expected);
-
-    chunk.release();
-  }
-
-  @Test
-  public void sendAsByteArrayShouldWriteValueToDataOutput() throws IOException {
-    byte[] regionEntryValue = getValueAsByteArray();
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
-
-    // writeByte is a final method and cannot be mocked, so creating a real one
-    HeapDataOutputStream dataOutput = new HeapDataOutputStream(Version.CURRENT);
-
-    chunk.sendAsByteArray(dataOutput);
-
-    byte[] actual = dataOutput.toByteArray();
-
-    byte[] expected = new byte[regionEntryValue.length + 1];
-    expected[0] = (byte) regionEntryValue.length;
-    System.arraycopy(regionEntryValue, 0, expected, 1, regionEntryValue.length);
-
-    assertNotNull(dataOutput);
-    assertThat(actual).isEqualTo(expected);
-
-    chunk.release();
-  }
-
-  @Test
-  public void createDirectByteBufferShouldCreateAByteBuffer() {
-    byte[] regionEntryValue = getValueAsByteArray();
-
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
-
-    ByteBuffer buffer = chunk.createDirectByteBuffer();
-
-    byte[] actual = new byte[regionEntryValue.length];
-    buffer.get(actual);
-
-    assertArrayEquals(regionEntryValue, actual);
-
-    chunk.release();
-  }
-
-  @Test
-  public void getDirectByteBufferShouldCreateAByteBuffer() {
-    byte[] regionEntryValue = getValueAsByteArray();
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
-
-    ByteBuffer buffer = chunk.createDirectByteBuffer();
-    long bufferAddress = Chunk.getDirectByteBufferAddress(buffer);
-
-    // returned address should be starting of the value (after skipping HEADER_SIZE bytes)
-    assertEquals(chunk.getMemoryAddress() + Chunk.OFF_HEAP_HEADER_SIZE, bufferAddress);
-
-    chunk.release();
-  }
-
-  @Test(expected = AssertionError.class)
-  public void getAddressForReadingShouldFailIfItsOutsideOfChunk() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-    chunk.getAddressForReading(0, chunk.getDataSize() + 1);
-
-    chunk.release();
-  }
-
-  @Test
-  public void getAddressForReadingShouldReturnDataAddressFromGivenOffset() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    int offset = 1;
-    long requestedAddress = chunk.getAddressForReading(offset, 1);
-
-    assertThat(requestedAddress).isEqualTo(chunk.getBaseDataAddress() + offset);
-
-    chunk.release();
-  }
-
-  @Test
-  public void getSizeInBytesShouldReturnSize() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-    assertThat(chunk.getSizeInBytes()).isEqualTo(chunk.getSize());
-
-    chunk.release();
-  }
-
-  @Test(expected = AssertionError.class)
-  public void getUnsafeAddressShouldFailIfOffsetIsNegative() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-    chunk.getUnsafeAddress(-1, 1);
-
-    chunk.release();
-  }
-
-  @Test(expected = AssertionError.class)
-  public void getUnsafeAddressShouldFailIfSizeIsNegative() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-    chunk.getUnsafeAddress(1, -1);
-
-    chunk.release();
-  }
-
-  @Test(expected = AssertionError.class)
-  public void getUnsafeAddressShouldFailIfItsOutsideOfChunk() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-    chunk.getUnsafeAddress(0, chunk.getDataSize() + 1);
-
-    chunk.release();
-  }
-
-  @Test
-  public void getUnsafeAddressShouldReturnUnsafeAddress() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    int offset = 1;
-    long unsafeAddress = chunk.getUnsafeAddress(offset, 1);
-
-    assertThat(unsafeAddress).isEqualTo(chunk.getBaseDataAddress() + offset);
-
-    chunk.release();
-  }
-
-  @Test(expected = AssertionError.class)
-  public void readByteAndWriteByteShouldFailIfOffsetIsOutside() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    chunk.readByte(chunk.getDataSize() + 1);
-
-    chunk.writeByte(chunk.getDataSize() + 1, Byte.MAX_VALUE);
-
-    chunk.release();
-  }
-
-  @Test
-  public void writeByteShouldWriteAtCorrectLocation() {
-    GemFireChunk chunk = createValueAsSerializedStoredObject(getValue());
-
-    byte valueBeforeWrite = chunk.readByte(2);
-
-    Byte expected = Byte.MAX_VALUE;
-    chunk.writeByte(2, expected);
-
-    Byte actual = chunk.readByte(2);
-
-    assertThat(actual).isNotEqualTo(valueBeforeWrite);
-    assertThat(actual).isEqualTo(expected);
-
-    chunk.release();
-  }
-
-  @Test
-  public void retainShouldIncrementRefCount() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    assertThat(chunk.getRefCount()).isEqualTo(1);
-
-    chunk.retain();
-    assertThat(chunk.getRefCount()).isEqualTo(2);
-
-    chunk.retain();
-    assertThat(chunk.getRefCount()).isEqualTo(3);
-
-    chunk.release();
-    chunk.release();
-    chunk.release();
-    boolean retainAfterRelease = chunk.retain();
-
-    assertThat(retainAfterRelease).isFalse();
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void retainShouldThrowExceptionAfterMaxNumberOfTimesRetained() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-
-    // loop though and invoke retain for MAX_REF_COUNT-1 times, as create chunk above counted as one reference
-    for (int i = 0; i < Chunk.MAX_REF_COUNT - 1; i++)
-      chunk.retain();
-
-    // invoke for the one more time should throw exception
-    chunk.retain();
-  }
-
-  @Test
-  public void releaseShouldDecrementRefCount() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    assertThat(chunk.getRefCount()).isEqualTo(1);
-
-    chunk.retain();
-    chunk.retain();
-    assertThat(chunk.getRefCount()).isEqualTo(3);
-
-    chunk.release();
-    assertThat(chunk.getRefCount()).isEqualTo(2);
-
-    chunk.release();
-    assertThat(chunk.getRefCount()).isEqualTo(1);
-
-    chunk.retain();
-    chunk.release();
-    assertThat(chunk.getRefCount()).isEqualTo(1);
-
-    chunk.release();
-    assertThat(chunk.getRefCount()).isEqualTo(0);
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void releaseShouldThrowExceptionIfChunkIsAlreadyReleased() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.release();
-    chunk.release();
-  }
-
-  @Test
-  public void testToStringForOffHeapByteSource() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-
-    String expected = ":<dataSize=" + chunk.getDataSize() + " refCount=" + chunk.getRefCount() + " addr=" + Long.toHexString(chunk.getMemoryAddress()) + ">";
-    assertThat(chunk.toStringForOffHeapByteSource()).endsWith(expected);
-
-    // test toString
-    Chunk spy = spy(chunk);
-    spy.toString();
-    verify(spy, times(1)).toStringForOffHeapByteSource();
-
-    chunk.release();
-  }
-
-  @Test
-  public void getStateShouldReturnAllocatedIfRefCountIsGreaterThanZero() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    assertEquals(State.ALLOCATED, chunk.getState());
-
-    chunk.release();
-  }
-
-  @Test
-  public void getStateShouldReturnDeallocatedIfRefCountIsZero() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.release();
-    assertEquals(State.DEALLOCATED, chunk.getState());
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void getNextBlockShouldThrowUnSupportedOperationException() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.getNextBlock();
-
-    chunk.release();
-  }
-
-  @Test
-  public void getBlockSizeShouldBeSameSameGetSize() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    assertEquals(chunk.getSize(), chunk.getBlockSize());
-
-    chunk.release();
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void copyBytesShouldThrowUnSupportedOperationException() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.copyBytes(1, 2, 1);
-
-    chunk.release();
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void getSlabIdShouldThrowUnSupportedOperationException() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    chunk.getSlabId();
-
-    chunk.release();
-  }
-
-  @Test
-  public void getFreeListIdShouldReturnMinusOne() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    assertThat(chunk.getFreeListId()).isEqualTo(-1);
-
-    chunk.release();
-  }
-
-  @Test
-  public void getDataTypeShouldReturnNull() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    assertThat(chunk.getDataType()).isNull();
-
-    chunk.release();
-  }
-
-  @Test
-  public void getDataDataShouldReturnNull() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    assertThat(chunk.getDataValue()).isNull();
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void getRawBytesShouldThrowExceptionIfValueIsCompressed() {
-    Object regionEntryValue = getValue();
-    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
-
-    boolean isSerialized = true;
-    boolean isCompressed = true;
-
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed, GemFireChunk.TYPE);
-
-    chunk.getRawBytes();
-
-    chunk.release();
-  }
-
-  @Test
-  public void getSerializedValueShouldSerializeTheValue() {
-    Object regionEntryValue = getValue();
-    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
-
-    boolean isSerialized = false;
-    boolean isCompressed = false;
-
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed, GemFireChunk.TYPE);
-
-    byte[] serializedValue = chunk.getSerializedValue();
-
-    assertThat(serializedValue).isEqualTo(EntryEventImpl.serialize(regionEntryValueAsBytes));
-
-    chunk.release();
-  }
-
-  @Test
-  public void getSrcTypeOrdinalFromAddressShouldReturnOrdinal() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-
-    assertThat(Chunk.getSrcTypeOrdinal(chunk.getMemoryAddress())).isEqualTo(Chunk.SRC_TYPE_GFE >> Chunk.SRC_TYPE_SHIFT);
-
-    chunk.release();
-  }
-
-  @Test
-  public void getSrcTypeOrdinalFromRawBitsShouldReturnOrdinal() {
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-
-    int rawBits = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + Chunk.REF_COUNT_OFFSET);
-    assertThat(Chunk.getSrcTypeOrdinalFromRawBits(rawBits)).isEqualTo(Chunk.SRC_TYPE_GFE >> Chunk.SRC_TYPE_SHIFT);
-
-    chunk.release();
-  }
-
-  @Test
-  public void fillShouldFillTheChunk() {
-    boolean isSerialized = false;
-    boolean isCompressed = false;
-
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(new byte[100], isSerialized, isCompressed, GemFireChunk.TYPE);
-
-    // first fill the unused part with FILL_PATTERN
-    Chunk.fill(chunk.getMemoryAddress());
-
-    // Validate that it is filled
-    chunk.validateFill();
-
-    chunk.release();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSliceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSliceJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSliceJUnitTest.java
deleted file mode 100644
index 39ee620..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/GemFireChunkSliceJUnitTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.gemstone.gemfire.internal.offheap;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class GemFireChunkSliceJUnitTest extends GemFireChunkJUnitTest {
-
-  @Test
-  public void sliceShouldHaveAValidDataSize() {
-    int position = 1;
-    int end = 2;
-
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    GemFireChunkSlice slice = (GemFireChunkSlice) chunk.slice(position, end);
-
-    assertNotNull(slice);
-    assertEquals(GemFireChunkSlice.class, slice.getClass());
-
-    assertEquals(end - position, slice.getDataSize());
-  }
-
-  @Test
-  public void sliceShouldHaveAValidBaseDataAddress() {
-    int position = 1;
-    int end = 2;
-
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    GemFireChunkSlice slice = (GemFireChunkSlice) chunk.slice(position, end);
-
-    assertNotNull(slice);
-    assertEquals(GemFireChunkSlice.class, slice.getClass());
-
-    assertEquals(chunk.getBaseDataAddress() + position, slice.getBaseDataAddress());
-  }
-
-  @Test
-  public void sliceShouldHaveAValidBaseOffset() {
-    int position = 1;
-    int end = 2;
-
-    GemFireChunk chunk = createValueAsUnserializedStoredObject(getValue());
-    GemFireChunkSlice slice = (GemFireChunkSlice) chunk.slice(position, end);
-
-    assertNotNull(slice);
-    assertEquals(GemFireChunkSlice.class, slice.getClass());
-
-    assertEquals(chunk.getBaseDataOffset() + position, slice.getBaseDataOffset());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
index 5e54b73..97ae486 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/LifecycleListenerJUnitTest.java
@@ -63,7 +63,7 @@ public class LifecycleListenerJUnitTest {
     LifecycleListener.removeLifecycleListener(this.listener);
 
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024); // 1k
-    SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(),
+    SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(),
         new UnsafeMemoryChunk[] { slab });
 
     Assert.assertEquals(0, this.afterCreateCallbacks.size());
@@ -83,7 +83,7 @@ public class LifecycleListenerJUnitTest {
   public void testCallbacksAreCalledAfterCreate() {
     LifecycleListener.addLifecycleListener(this.listener);
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024); // 1k
-    SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(),
+    SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(),
         new UnsafeMemoryChunk[] { slab });
 
     Assert.assertEquals(1, this.afterCreateCallbacks.size());
@@ -141,7 +141,7 @@ public class LifecycleListenerJUnitTest {
 
   private SimpleMemoryAllocatorImpl createAllocator(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats ohms, UnsafeMemoryChunk[] slab) {
     try {
-       return SimpleMemoryAllocatorImpl.create(ooohml, ohms, slab);
+       return SimpleMemoryAllocatorImpl.createForUnitTest(ooohml, ohms, slab);
     } catch (IllegalStateException e) {
       return null;
     }
@@ -162,7 +162,7 @@ public class LifecycleListenerJUnitTest {
     LifecycleListener.addLifecycleListener(this.listener);
 
     UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024); // 1k
-    SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[] { slab });
+    SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[] { slab });
 
     Assert.assertEquals(1, this.afterCreateCallbacks.size());
     Assert.assertEquals(0, this.afterReuseCallbacks.size());
@@ -175,7 +175,7 @@ public class LifecycleListenerJUnitTest {
     Assert.assertEquals(1, this.beforeCloseCallbacks.size());
 
     slab = new UnsafeMemoryChunk(1024); // 1k
-    SimpleMemoryAllocatorImpl ma2 = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[] { slab });
+    SimpleMemoryAllocatorImpl ma2 = SimpleMemoryAllocatorImpl.createForUnitTest(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[] { slab });
 
     Assert.assertEquals(2, this.afterCreateCallbacks.size());
     Assert.assertEquals(0, this.afterReuseCallbacks.size());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkJUnitTest.java
new file mode 100644
index 0000000..9271b53
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkJUnitTest.java
@@ -0,0 +1,902 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gemstone.gemfire.internal.offheap;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.compression.Compressor;
+import com.gemstone.gemfire.internal.DSCODE;
+import com.gemstone.gemfire.internal.HeapDataOutputStream;
+import com.gemstone.gemfire.internal.Version;
+import com.gemstone.gemfire.internal.cache.BytesAndBitsForCompactor;
+import com.gemstone.gemfire.internal.cache.CachePerfStats;
+import com.gemstone.gemfire.internal.cache.EntryEventImpl;
+import com.gemstone.gemfire.internal.cache.RegionEntryContext;
+import com.gemstone.gemfire.internal.offheap.MemoryBlock.State;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class ObjectChunkJUnitTest extends AbstractStoredObjectTestBase {
+
+  private MemoryAllocator ma;
+
+  static {
+    ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
+  }
+
+  @Before
+  public void setUp() {
+    OutOfOffHeapMemoryListener ooohml = mock(OutOfOffHeapMemoryListener.class);
+    OffHeapMemoryStats stats = mock(OffHeapMemoryStats.class);
+    LogWriter lw = mock(LogWriter.class);
+
+    ma = SimpleMemoryAllocatorImpl.create(ooohml, stats, lw, 3, OffHeapStorage.MIN_SLAB_SIZE * 3, OffHeapStorage.MIN_SLAB_SIZE);
+  }
+
+  @After
+  public void tearDown() {
+    SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+  }
+
+  @Override
+  public Object getValue() {
+    return Long.valueOf(Long.MAX_VALUE);
+  }
+
+  @Override
+  public byte[] getValueAsByteArray() {
+    return convertValueToByteArray(getValue());
+  }
+
+  private byte[] convertValueToByteArray(Object value) {
+    return ByteBuffer.allocate(Long.SIZE / Byte.SIZE).putLong((Long) value).array();
+  }
+
+  @Override
+  public Object convertByteArrayToObject(byte[] valueInByteArray) {
+    return ByteBuffer.wrap(valueInByteArray).getLong();
+  }
+
+  @Override
+  public Object convertSerializedByteArrayToObject(byte[] valueInSerializedByteArray) {
+    return EntryEventImpl.deserialize(valueInSerializedByteArray);
+  }
+
+  @Override
+  public ObjectChunk createValueAsUnserializedStoredObject(Object value) {
+    byte[] valueInByteArray;
+    if (value instanceof Long) {
+      valueInByteArray = convertValueToByteArray(value);
+    } else {
+      valueInByteArray = (byte[]) value;
+    }
+
+    boolean isSerialized = false;
+    boolean isCompressed = false;
+
+    return createChunk(valueInByteArray, isSerialized, isCompressed);
+  }
+
+  @Override
+  public ObjectChunk createValueAsSerializedStoredObject(Object value) {
+    byte[] valueInSerializedByteArray = EntryEventImpl.serialize(value);
+
+    boolean isSerialized = true;
+    boolean isCompressed = false;
+
+    return createChunk(valueInSerializedByteArray, isSerialized, isCompressed);
+  }
+
+  private ObjectChunk createChunk(byte[] v, boolean isSerialized, boolean isCompressed) {
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
+    return chunk;
+  }
+
+  @Test
+  public void chunkCanBeCreatedFromAnotherChunk() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+
+    ObjectChunk newChunk = new ObjectChunk(chunk);
+
+    assertNotNull(newChunk);
+    assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
+
+    chunk.release();
+  }
+
+  @Test
+  public void chunkCanBeCreatedWithOnlyMemoryAddress() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+
+    ObjectChunk newChunk = new ObjectChunk(chunk.getMemoryAddress());
+
+    assertNotNull(newChunk);
+    assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
+
+    chunk.release();
+  }
+
+  @Test
+  public void chunkSliceCanBeCreatedFromAnotherChunk() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+
+    int position = 1;
+    int end = 2;
+
+    ObjectChunk newChunk = (ObjectChunk) chunk.slice(position, end);
+
+    assertNotNull(newChunk);
+    assertThat(newChunk.getClass()).isEqualTo(ObjectChunkSlice.class);
+    assertThat(newChunk.getMemoryAddress()).isEqualTo(chunk.getMemoryAddress());
+
+    chunk.release();
+  }
+
+  @Test
+  public void fillSerializedValueShouldFillWrapperWithSerializedValueIfValueIsSerialized() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    // mock the things
+    BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
+
+    byte userBits = 0;
+    byte serializedUserBits = 1;
+    chunk.fillSerializedValue(wrapper, userBits);
+
+    verify(wrapper, times(1)).setChunkData(chunk, serializedUserBits);
+
+    chunk.release();
+  }
+
+  @Test
+  public void fillSerializedValueShouldFillWrapperWithDeserializedValueIfValueIsNotSerialized() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+
+    // mock the things
+    BytesAndBitsForCompactor wrapper = mock(BytesAndBitsForCompactor.class);
+
+    byte userBits = 1;
+    chunk.fillSerializedValue(wrapper, userBits);
+
+    verify(wrapper, times(1)).setChunkData(chunk, userBits);
+
+    chunk.release();
+  }
+
+  @Test
+  public void getShortClassNameShouldReturnShortClassName() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    assertThat(chunk.getShortClassName()).isEqualTo("ObjectChunk");
+
+    chunk.release();
+  }
+
+  @Test
+  public void chunksAreEqualsOnlyByAddress() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    ObjectChunk newChunk = new ObjectChunk(chunk.getMemoryAddress());
+    assertThat(chunk.equals(newChunk)).isTrue();
+
+    ObjectChunk chunkWithSameValue = createValueAsUnserializedStoredObject(getValue());
+    assertThat(chunk.equals(chunkWithSameValue)).isFalse();
+
+    Object someObject = getValue();
+    assertThat(chunk.equals(someObject)).isFalse();
+
+    chunk.release();
+    chunkWithSameValue.release();
+  }
+
+  @Test
+  public void chunksShouldBeComparedBySize() {
+    ObjectChunk chunk1 = createValueAsSerializedStoredObject(getValue());
+
+    ObjectChunk chunk2 = chunk1;
+    assertThat(chunk1.compareTo(chunk2)).isEqualTo(0);
+
+    ObjectChunk chunkWithSameValue = createValueAsSerializedStoredObject(getValue());
+    assertThat(chunk1.compareTo(chunkWithSameValue)).isEqualTo(Long.signum(chunk1.getMemoryAddress() - chunkWithSameValue.getMemoryAddress()));
+
+    ObjectChunk chunk3 = createValueAsSerializedStoredObject(Long.MAX_VALUE);
+    ObjectChunk chunk4 = createValueAsSerializedStoredObject(Long.MAX_VALUE);
+
+    int newSizeForChunk3 = 2;
+    int newSizeForChunk4 = 3;
+
+    assertThat(chunk3.compareTo(chunk4)).isEqualTo(Integer.signum(newSizeForChunk3 - newSizeForChunk4));
+
+    chunk1.release();
+    chunk4.release();
+  }
+
+  @Test
+  public void setSerializedShouldSetTheSerializedBit() {
+    Object regionEntryValue = getValue();
+    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
+
+    boolean isSerialized = false;
+    boolean isCompressed = false;
+
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+
+    int headerBeforeSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + ObjectChunk.REF_COUNT_OFFSET);
+
+    assertThat(chunk.isSerialized()).isFalse();
+
+    chunk.setSerialized(true); // set to true
+
+    assertThat(chunk.isSerialized()).isTrue();
+
+    int headerAfterSerializedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + ObjectChunk.REF_COUNT_OFFSET);
+
+    assertThat(headerAfterSerializedBitSet).isEqualTo(headerBeforeSerializedBitSet | ObjectChunk.IS_SERIALIZED_BIT);
+
+    chunk.release();
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void setSerialziedShouldThrowExceptionIfChunkIsAlreadyReleased() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.release();
+    chunk.setSerialized(true);
+
+    chunk.release();
+  }
+
+  @Test
+  public void setCompressedShouldSetTheCompressedBit() {
+    Object regionEntryValue = getValue();
+    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
+
+    boolean isSerialized = false;
+    boolean isCompressed = false;
+
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+
+    int headerBeforeCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + ObjectChunk.REF_COUNT_OFFSET);
+
+    assertThat(chunk.isCompressed()).isFalse();
+
+    chunk.setCompressed(true); // set to true
+
+    assertThat(chunk.isCompressed()).isTrue();
+
+    int headerAfterCompressedBitSet = UnsafeMemoryChunk.readAbsoluteIntVolatile(chunk.getMemoryAddress() + ObjectChunk.REF_COUNT_OFFSET);
+
+    assertThat(headerAfterCompressedBitSet).isEqualTo(headerBeforeCompressedBitSet | ObjectChunk.IS_COMPRESSED_BIT);
+
+    chunk.release();
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void setCompressedShouldThrowExceptionIfChunkIsAlreadyReleased() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.release();
+    chunk.setCompressed(true);
+
+    chunk.release();
+  }
+
+  @Test
+  public void setDataSizeShouldSetTheDataSizeBits() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+
+    int beforeSize = chunk.getDataSize();
+
+    chunk.setDataSize(2);
+
+    int afterSize = chunk.getDataSize();
+
+    assertThat(afterSize).isEqualTo(2);
+    assertThat(afterSize).isNotEqualTo(beforeSize);
+
+    chunk.release();
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void setDataSizeShouldThrowExceptionIfChunkIsAlreadyReleased() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.release();
+    chunk.setDataSize(1);
+
+    chunk.release();
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void initializeUseCountShouldThrowIllegalStateExceptionIfChunkIsAlreadyRetained() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.retain();
+    chunk.initializeUseCount();
+
+    chunk.release();
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void initializeUseCountShouldThrowIllegalStateExceptionIfChunkIsAlreadyReleased() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.release();
+    chunk.initializeUseCount();
+
+    chunk.release();
+  }
+
+  @Test
+  public void isSerializedPdxInstanceShouldReturnTrueIfItsPDXInstance() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    byte[] serailizedValue = chunk.getSerializedValue();
+    serailizedValue[0] = DSCODE.PDX;
+    chunk.setSerializedValue(serailizedValue);
+
+    assertThat(chunk.isSerializedPdxInstance()).isTrue();
+
+    serailizedValue = chunk.getSerializedValue();
+    serailizedValue[0] = DSCODE.PDX_ENUM;
+    chunk.setSerializedValue(serailizedValue);
+
+    assertThat(chunk.isSerializedPdxInstance()).isTrue();
+
+    serailizedValue = chunk.getSerializedValue();
+    serailizedValue[0] = DSCODE.PDX_INLINE_ENUM;
+    chunk.setSerializedValue(serailizedValue);
+
+    assertThat(chunk.isSerializedPdxInstance()).isTrue();
+
+    chunk.release();
+  }
+
+  @Test
+  public void isSerializedPdxInstanceShouldReturnFalseIfItsNotPDXInstance() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    assertThat(chunk.isSerializedPdxInstance()).isFalse();
+
+    chunk.release();
+  }
+
+  @Test
+  public void checkDataEqualsByChunk() {
+    ObjectChunk chunk1 = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk sameAsChunk1 = chunk1;
+
+    assertThat(chunk1.checkDataEquals(sameAsChunk1)).isTrue();
+
+    ObjectChunk unserializedChunk = createValueAsUnserializedStoredObject(getValue());
+    assertThat(chunk1.checkDataEquals(unserializedChunk)).isFalse();
+
+    ObjectChunk chunkDifferBySize = createValueAsSerializedStoredObject(getValue());
+    chunkDifferBySize.setSize(0);
+    assertThat(chunk1.checkDataEquals(chunkDifferBySize)).isFalse();
+
+    ObjectChunk chunkDifferByValue = createValueAsSerializedStoredObject(Long.MAX_VALUE - 1);
+    assertThat(chunk1.checkDataEquals(chunkDifferByValue)).isFalse();
+
+    ObjectChunk newChunk1 = createValueAsSerializedStoredObject(getValue());
+    assertThat(chunk1.checkDataEquals(newChunk1)).isTrue();
+
+    chunk1.release();
+    unserializedChunk.release();
+    chunkDifferBySize.release();
+    chunkDifferByValue.release();
+    newChunk1.release();
+  }
+
+  @Test
+  public void checkDataEqualsBySerializedValue() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    assertThat(chunk.checkDataEquals(new byte[1])).isFalse();
+
+    ObjectChunk chunkDifferByValue = createValueAsSerializedStoredObject(Long.MAX_VALUE - 1);
+    assertThat(chunk.checkDataEquals(chunkDifferByValue.getSerializedValue())).isFalse();
+
+    ObjectChunk newChunk = createValueAsSerializedStoredObject(getValue());
+    assertThat(chunk.checkDataEquals(newChunk.getSerializedValue())).isTrue();
+
+    chunk.release();
+    chunkDifferByValue.release();
+    newChunk.release();
+  }
+
+  @Test
+  public void getDecompressedBytesShouldReturnDecompressedBytesIfCompressed() {
+    Object regionEntryValue = getValue();
+    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
+
+    boolean isSerialized = true;
+    boolean isCompressed = true;
+
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+
+    RegionEntryContext regionContext = mock(RegionEntryContext.class);
+    CachePerfStats cacheStats = mock(CachePerfStats.class);
+    Compressor compressor = mock(Compressor.class);
+
+    long startTime = 10000L;
+
+    // mock required things
+    when(regionContext.getCompressor()).thenReturn(compressor);
+    when(compressor.decompress(regionEntryValueAsBytes)).thenReturn(regionEntryValueAsBytes);
+    when(regionContext.getCachePerfStats()).thenReturn(cacheStats);
+    when(cacheStats.startDecompression()).thenReturn(startTime);
+
+    // invoke the thing
+    byte[] bytes = chunk.getDecompressedBytes(regionContext);
+
+    // verify the thing happened
+    verify(cacheStats, atLeastOnce()).startDecompression();
+    verify(compressor, times(1)).decompress(regionEntryValueAsBytes);
+    verify(cacheStats, atLeastOnce()).endDecompression(startTime);
+
+    assertArrayEquals(regionEntryValueAsBytes, bytes);
+
+    chunk.release();
+  }
+
+  @Test
+  public void incSizeShouldIncrementSize() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    int beforeSize = chunk.getSize();
+
+    chunk.incSize(1);
+    assertThat(chunk.getSize()).isEqualTo(beforeSize + 1);
+
+    chunk.incSize(2);
+    assertThat(chunk.getSize()).isEqualTo(beforeSize + 1 + 2);
+
+    chunk.release();
+  }
+
+  @Test
+  public void readyForFreeShouldResetTheRefCount() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    int refCountBeforeFreeing = chunk.getRefCount();
+    assertThat(refCountBeforeFreeing).isEqualTo(1);
+
+    chunk.readyForFree();
+
+    int refCountAfterFreeing = chunk.getRefCount();
+    assertThat(refCountAfterFreeing).isEqualTo(0);
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void readyForAllocationShouldThrowExceptionIfAlreadyAllocated() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    // chunk is already allocated when we created it, so calling readyForAllocation should throw exception.
+    chunk.readyForAllocation();
+
+    chunk.release();
+  }
+
+  @Test
+  public void checkIsAllocatedShouldReturnIfAllocated() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    chunk.checkIsAllocated();
+
+    chunk.release();
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void checkIsAllocatedShouldThrowExceptionIfNotAllocated() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    chunk.release();
+    chunk.checkIsAllocated();
+
+    chunk.release();
+  }
+
+  @Test
+  public void sendToShouldWriteSerializedValueToDataOutputIfValueIsSerialized() throws IOException {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    ObjectChunk spyChunk = spy(chunk);
+
+    HeapDataOutputStream dataOutput = mock(HeapDataOutputStream.class);
+    ByteBuffer directByteBuffer = ByteBuffer.allocate(1024);
+
+    doReturn(directByteBuffer).when(spyChunk).createDirectByteBuffer();
+    doNothing().when(dataOutput).write(directByteBuffer);
+
+    spyChunk.sendTo(dataOutput);
+
+    verify(dataOutput, times(1)).write(directByteBuffer);
+
+    chunk.release();
+  }
+
+  @Test
+  public void sendToShouldWriteUnserializedValueToDataOutputIfValueIsUnserialized() throws IOException {
+    byte[] regionEntryValue = getValueAsByteArray();
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
+
+    // writeByte is a final method and cannot be mocked, so creating a real one
+    HeapDataOutputStream dataOutput = new HeapDataOutputStream(Version.CURRENT);
+
+    chunk.sendTo(dataOutput);
+
+    byte[] actual = dataOutput.toByteArray();
+
+    byte[] expected = new byte[regionEntryValue.length + 2];
+    expected[0] = DSCODE.BYTE_ARRAY;
+    expected[1] = (byte) regionEntryValue.length;
+    System.arraycopy(regionEntryValue, 0, expected, 2, regionEntryValue.length);
+
+    assertNotNull(dataOutput);
+    assertThat(actual).isEqualTo(expected);
+
+    chunk.release();
+  }
+
+  @Test
+  public void sendAsByteArrayShouldWriteValueToDataOutput() throws IOException {
+    byte[] regionEntryValue = getValueAsByteArray();
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
+
+    // writeByte is a final method and cannot be mocked, so creating a real one
+    HeapDataOutputStream dataOutput = new HeapDataOutputStream(Version.CURRENT);
+
+    chunk.sendAsByteArray(dataOutput);
+
+    byte[] actual = dataOutput.toByteArray();
+
+    byte[] expected = new byte[regionEntryValue.length + 1];
+    expected[0] = (byte) regionEntryValue.length;
+    System.arraycopy(regionEntryValue, 0, expected, 1, regionEntryValue.length);
+
+    assertNotNull(dataOutput);
+    assertThat(actual).isEqualTo(expected);
+
+    chunk.release();
+  }
+
+  @Test
+  public void createDirectByteBufferShouldCreateAByteBuffer() {
+    byte[] regionEntryValue = getValueAsByteArray();
+
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
+
+    ByteBuffer buffer = chunk.createDirectByteBuffer();
+
+    byte[] actual = new byte[regionEntryValue.length];
+    buffer.get(actual);
+
+    assertArrayEquals(regionEntryValue, actual);
+
+    chunk.release();
+  }
+
+  @Test
+  public void getDirectByteBufferShouldCreateAByteBuffer() {
+    byte[] regionEntryValue = getValueAsByteArray();
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(regionEntryValue);
+
+    ByteBuffer buffer = chunk.createDirectByteBuffer();
+    long bufferAddress = ObjectChunk.getDirectByteBufferAddress(buffer);
+
+    // returned address should be starting of the value (after skipping HEADER_SIZE bytes)
+    assertEquals(chunk.getMemoryAddress() + ObjectChunk.OFF_HEAP_HEADER_SIZE, bufferAddress);
+
+    chunk.release();
+  }
+
+  @Test(expected = AssertionError.class)
+  public void getAddressForReadingShouldFailIfItsOutsideOfChunk() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    chunk.getAddressForReading(0, chunk.getDataSize() + 1);
+
+    chunk.release();
+  }
+
+  @Test
+  public void getAddressForReadingShouldReturnDataAddressFromGivenOffset() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    int offset = 1;
+    long requestedAddress = chunk.getAddressForReading(offset, 1);
+
+    assertThat(requestedAddress).isEqualTo(chunk.getBaseDataAddress() + offset);
+
+    chunk.release();
+  }
+
+  @Test
+  public void getSizeInBytesShouldReturnSize() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    assertThat(chunk.getSizeInBytes()).isEqualTo(chunk.getSize());
+
+    chunk.release();
+  }
+
+  @Test(expected = AssertionError.class)
+  public void getUnsafeAddressShouldFailIfOffsetIsNegative() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    chunk.getUnsafeAddress(-1, 1);
+
+    chunk.release();
+  }
+
+  @Test(expected = AssertionError.class)
+  public void getUnsafeAddressShouldFailIfSizeIsNegative() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    chunk.getUnsafeAddress(1, -1);
+
+    chunk.release();
+  }
+
+  @Test(expected = AssertionError.class)
+  public void getUnsafeAddressShouldFailIfItsOutsideOfChunk() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+    chunk.getUnsafeAddress(0, chunk.getDataSize() + 1);
+
+    chunk.release();
+  }
+
+  @Test
+  public void getUnsafeAddressShouldReturnUnsafeAddress() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    int offset = 1;
+    long unsafeAddress = chunk.getUnsafeAddress(offset, 1);
+
+    assertThat(unsafeAddress).isEqualTo(chunk.getBaseDataAddress() + offset);
+
+    chunk.release();
+  }
+
+  @Test(expected = AssertionError.class)
+  public void readByteAndWriteByteShouldFailIfOffsetIsOutside() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    chunk.readByte(chunk.getDataSize() + 1);
+
+    chunk.writeByte(chunk.getDataSize() + 1, Byte.MAX_VALUE);
+
+    chunk.release();
+  }
+
+  @Test
+  public void writeByteShouldWriteAtCorrectLocation() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    byte valueBeforeWrite = chunk.readByte(2);
+
+    Byte expected = Byte.MAX_VALUE;
+    chunk.writeByte(2, expected);
+
+    Byte actual = chunk.readByte(2);
+
+    assertThat(actual).isNotEqualTo(valueBeforeWrite);
+    assertThat(actual).isEqualTo(expected);
+
+    chunk.release();
+  }
+
+  @Test
+  public void retainShouldIncrementRefCount() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    assertThat(chunk.getRefCount()).isEqualTo(1);
+
+    chunk.retain();
+    assertThat(chunk.getRefCount()).isEqualTo(2);
+
+    chunk.retain();
+    assertThat(chunk.getRefCount()).isEqualTo(3);
+
+    chunk.release();
+    chunk.release();
+    chunk.release();
+    boolean retainAfterRelease = chunk.retain();
+
+    assertThat(retainAfterRelease).isFalse();
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void retainShouldThrowExceptionAfterMaxNumberOfTimesRetained() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+
+    // loop though and invoke retain for MAX_REF_COUNT-1 times, as create chunk above counted as one reference
+    for (int i = 0; i < ObjectChunk.MAX_REF_COUNT - 1; i++)
+      chunk.retain();
+
+    // invoke for the one more time should throw exception
+    chunk.retain();
+  }
+
+  @Test
+  public void releaseShouldDecrementRefCount() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    assertThat(chunk.getRefCount()).isEqualTo(1);
+
+    chunk.retain();
+    chunk.retain();
+    assertThat(chunk.getRefCount()).isEqualTo(3);
+
+    chunk.release();
+    assertThat(chunk.getRefCount()).isEqualTo(2);
+
+    chunk.release();
+    assertThat(chunk.getRefCount()).isEqualTo(1);
+
+    chunk.retain();
+    chunk.release();
+    assertThat(chunk.getRefCount()).isEqualTo(1);
+
+    chunk.release();
+    assertThat(chunk.getRefCount()).isEqualTo(0);
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void releaseShouldThrowExceptionIfChunkIsAlreadyReleased() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.release();
+    chunk.release();
+  }
+
+  @Test
+  public void testToStringForOffHeapByteSource() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+
+    String expected = ":<dataSize=" + chunk.getDataSize() + " refCount=" + chunk.getRefCount() + " addr=" + Long.toHexString(chunk.getMemoryAddress()) + ">";
+    assertThat(chunk.toStringForOffHeapByteSource()).endsWith(expected);
+
+    // test toString
+    ObjectChunk spy = spy(chunk);
+    spy.toString();
+    verify(spy, times(1)).toStringForOffHeapByteSource();
+
+    chunk.release();
+  }
+
+  @Test
+  public void getStateShouldReturnAllocatedIfRefCountIsGreaterThanZero() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    assertEquals(State.ALLOCATED, chunk.getState());
+
+    chunk.release();
+  }
+
+  @Test
+  public void getStateShouldReturnDeallocatedIfRefCountIsZero() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.release();
+    assertEquals(State.DEALLOCATED, chunk.getState());
+  }
+
+  @Test(expected = UnsupportedOperationException.class)
+  public void getNextBlockShouldThrowUnSupportedOperationException() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.getNextBlock();
+
+    chunk.release();
+  }
+
+  @Test
+  public void getBlockSizeShouldBeSameSameGetSize() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    assertEquals(chunk.getSize(), chunk.getBlockSize());
+
+    chunk.release();
+  }
+
+  @Test(expected = UnsupportedOperationException.class)
+  public void copyBytesShouldThrowUnSupportedOperationException() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.copyBytes(1, 2, 1);
+
+    chunk.release();
+  }
+
+  @Test(expected = UnsupportedOperationException.class)
+  public void getSlabIdShouldThrowUnSupportedOperationException() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    chunk.getSlabId();
+
+    chunk.release();
+  }
+
+  @Test
+  public void getFreeListIdShouldReturnMinusOne() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    assertThat(chunk.getFreeListId()).isEqualTo(-1);
+
+    chunk.release();
+  }
+
+  @Test
+  public void getDataTypeShouldReturnNull() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    assertThat(chunk.getDataType()).isNull();
+
+    chunk.release();
+  }
+
+  @Test
+  public void getDataDataShouldReturnNull() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    assertThat(chunk.getDataValue()).isNull();
+  }
+
+  @Test(expected = UnsupportedOperationException.class)
+  public void getRawBytesShouldThrowExceptionIfValueIsCompressed() {
+    Object regionEntryValue = getValue();
+    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
+
+    boolean isSerialized = true;
+    boolean isCompressed = true;
+
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+
+    chunk.getRawBytes();
+
+    chunk.release();
+  }
+
+  @Test
+  public void getSerializedValueShouldSerializeTheValue() {
+    Object regionEntryValue = getValue();
+    byte[] regionEntryValueAsBytes = convertValueToByteArray(regionEntryValue);
+
+    boolean isSerialized = false;
+    boolean isCompressed = false;
+
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(regionEntryValueAsBytes, isSerialized, isCompressed);
+
+    byte[] serializedValue = chunk.getSerializedValue();
+
+    assertThat(serializedValue).isEqualTo(EntryEventImpl.serialize(regionEntryValueAsBytes));
+
+    chunk.release();
+  }
+
+  @Test
+  public void fillShouldFillTheChunk() {
+    boolean isSerialized = false;
+    boolean isCompressed = false;
+
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(new byte[100], isSerialized, isCompressed);
+
+    // first fill the unused part with FILL_PATTERN
+    ObjectChunk.fill(chunk.getMemoryAddress());
+
+    // Validate that it is filled
+    chunk.validateFill();
+
+    chunk.release();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSliceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSliceJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSliceJUnitTest.java
new file mode 100644
index 0000000..fe55910
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkSliceJUnitTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gemstone.gemfire.internal.offheap;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class ObjectChunkSliceJUnitTest extends ObjectChunkJUnitTest {
+
+  @Test
+  public void sliceShouldHaveAValidDataSize() {
+    int position = 1;
+    int end = 2;
+
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunkSlice slice = (ObjectChunkSlice) chunk.slice(position, end);
+
+    assertNotNull(slice);
+    assertEquals(ObjectChunkSlice.class, slice.getClass());
+
+    assertEquals(end - position, slice.getDataSize());
+  }
+
+  @Test
+  public void sliceShouldHaveAValidBaseDataAddress() {
+    int position = 1;
+    int end = 2;
+
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunkSlice slice = (ObjectChunkSlice) chunk.slice(position, end);
+
+    assertNotNull(slice);
+    assertEquals(ObjectChunkSlice.class, slice.getClass());
+
+    assertEquals(chunk.getBaseDataAddress() + position, slice.getBaseDataAddress());
+  }
+
+  @Test
+  public void sliceShouldHaveAValidBaseOffset() {
+    int position = 1;
+    int end = 2;
+
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+    ObjectChunkSlice slice = (ObjectChunkSlice) chunk.slice(position, end);
+
+    assertNotNull(slice);
+    assertEquals(ObjectChunkSlice.class, slice.getClass());
+
+    assertEquals(chunk.getBaseDataOffset() + position, slice.getBaseDataOffset());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapFormJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapFormJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapFormJUnitTest.java
new file mode 100644
index 0000000..4486845
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapFormJUnitTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gemstone.gemfire.internal.offheap;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class ObjectChunkWithHeapFormJUnitTest extends ObjectChunkJUnitTest {
+
+  @Test
+  public void getRawBytesShouldReturnCachedHeapForm() {
+    ObjectChunk chunk = createValueAsUnserializedStoredObject(getValue());
+
+    byte[] valueInBytes = getValueAsByteArray();
+    ObjectChunkWithHeapForm heapForm = new ObjectChunkWithHeapForm(chunk, valueInBytes);
+
+    assertNotNull(heapForm);
+
+    assertSame(valueInBytes, heapForm.getRawBytes());
+  }
+
+  @Test
+  public void getChunkWithoutHeapFormShouldReturnGemFireChunk() {
+    ObjectChunk chunk = createValueAsSerializedStoredObject(getValue());
+
+    byte[] valueInBytes = getValueAsByteArray();
+    ObjectChunkWithHeapForm heapForm = new ObjectChunkWithHeapForm(chunk, valueInBytes);
+
+    ObjectChunk chunkWithOutHeapForm = heapForm.getChunkWithoutHeapForm();
+
+    assertNotNull(chunkWithOutHeapForm);
+    assertEquals(ObjectChunk.class, chunkWithOutHeapForm.getClass());
+
+    assertEquals(chunk, heapForm.getChunkWithoutHeapForm());
+
+    assertEquals(chunk.getMemoryAddress(), chunkWithOutHeapForm.getMemoryAddress());
+    assertArrayEquals(chunk.getRawBytes(), chunkWithOutHeapForm.getRawBytes());
+    assertNotSame(valueInBytes, chunkWithOutHeapForm.getRawBytes());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
index fd0eb4f..b1e3af0 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapHelperJUnitTest.java
@@ -128,8 +128,8 @@ public class OffHeapHelperJUnitTest extends AbstractStoredObjectTestBase {
     return createdObject;
   }
 
-  private GemFireChunk createChunk(byte[] v, boolean isSerialized, boolean isCompressed) {
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed, GemFireChunk.TYPE);
+  private ObjectChunk createChunk(byte[] v, boolean isSerialized, boolean isCompressed) {
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
     return chunk;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
index b515959..8de0406 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
@@ -92,7 +92,7 @@ public abstract class OffHeapRegionBase {
       assertNotNull(ma);
       final long offHeapSize = ma.getFreeMemory();
       assertEquals(0, ma.getUsedMemory());
-      MemoryChunk mc1 = ma.allocate(64, null);
+      MemoryChunk mc1 = ma.allocate(64);
       assertEquals(64+perObjectOverhead(), ma.getUsedMemory());
       assertEquals(offHeapSize-(64+perObjectOverhead()), ma.getFreeMemory());
       mc1.release();
@@ -103,7 +103,7 @@ public abstract class OffHeapRegionBase {
       // (see the todo comment on compact() in SimpleMemoryAllocator).
       // So we request 20m here since that it the total size.
       try {
-        ma.allocate(1024*1024*20, null);
+        ma.allocate(1024*1024*20);
         fail("Expected an out of heap exception");
       } catch (OutOfOffHeapMemoryException expected) {
       }
@@ -123,7 +123,7 @@ public abstract class OffHeapRegionBase {
       assertNotNull(ma);
       final long offHeapSize = ma.getFreeMemory();
       assertEquals(0, ma.getUsedMemory());
-      MemoryChunk mc1 = ma.allocate(64, null);
+      MemoryChunk mc1 = ma.allocate(64);
       assertEquals(64+perObjectOverhead(), ma.getUsedMemory());
       assertEquals(offHeapSize-(64+perObjectOverhead()), ma.getFreeMemory());
       mc1.release();
@@ -131,7 +131,7 @@ public abstract class OffHeapRegionBase {
       assertEquals(0, ma.getUsedMemory());
       // do an allocation larger than the slab size
       try {
-        ma.allocate(1024*1024*10, null);
+        ma.allocate(1024*1024*10);
         fail("Expected an out of heap exception");
       } catch (OutOfOffHeapMemoryException expected) {
         // passed
@@ -163,7 +163,7 @@ public abstract class OffHeapRegionBase {
       final long offHeapSize = ma.getFreeMemory();
       assertEquals(0, ma.getUsedMemory());
       byte[] data = new byte[] {1,2,3,4,5,6,7,8};
-      MemoryChunk mc1 = (MemoryChunk)ma.allocateAndInitialize(data, false, false, null);
+      MemoryChunk mc1 = (MemoryChunk)ma.allocateAndInitialize(data, false, false);
       assertEquals(data.length+perObjectOverhead(), ma.getUsedMemory());
       assertEquals(offHeapSize-(data.length+perObjectOverhead()), ma.getFreeMemory());
       byte[] data2 = new byte[data.length];
@@ -174,7 +174,7 @@ public abstract class OffHeapRegionBase {
       assertEquals(0, ma.getUsedMemory());
       // try some small byte[] that don't need to be stored off heap.
       data = new byte[] {1,2,3,4,5,6,7};
-      StoredObject so1 = ma.allocateAndInitialize(data, false, false, null);
+      StoredObject so1 = ma.allocateAndInitialize(data, false, false);
       assertEquals(0, ma.getUsedMemory());
       assertEquals(offHeapSize, ma.getFreeMemory());
       data2 = new byte[data.length];
@@ -540,11 +540,11 @@ public abstract class OffHeapRegionBase {
     @Released(OffHeapIdentifier.TEST_OFF_HEAP_REGION_BASE_LISTENER)
     @Override
     public void close() {
-      if (this.ohOldValue instanceof Chunk) {
-        ((Chunk)this.ohOldValue).release();
+      if (this.ohOldValue instanceof ObjectChunk) {
+        ((ObjectChunk)this.ohOldValue).release();
       }
-      if (this.ohNewValue instanceof Chunk) {
-        ((Chunk)this.ohNewValue).release();
+      if (this.ohNewValue instanceof ObjectChunk) {
+        ((ObjectChunk)this.ohNewValue).release();
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
index b800977..5d53109 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionEntryHelperJUnitTest.java
@@ -54,7 +54,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 @Category(UnitTest.class)
 @RunWith(PowerMockRunner.class)
 @PowerMockIgnore("*.UnitTest")
-@PrepareForTest({ Chunk.class, OffHeapRegionEntryHelper.class })
+@PrepareForTest({ ObjectChunk.class, OffHeapRegionEntryHelper.class })
 public class OffHeapRegionEntryHelperJUnitTest {
 
   private static final Long VALUE_IS_NOT_ENCODABLE = 0L;
@@ -75,13 +75,13 @@ public class OffHeapRegionEntryHelperJUnitTest {
     SimpleMemoryAllocatorImpl.freeOffHeapMemory();
   }
 
-  private GemFireChunk createChunk(Object value) {
+  private ObjectChunk createChunk(Object value) {
     byte[] v = EntryEventImpl.serialize(value);
 
     boolean isSerialized = true;
     boolean isCompressed = false;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed, GemFireChunk.TYPE);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(v, isSerialized, isCompressed);
 
     return chunk;
   }
@@ -294,7 +294,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
   @Test
   public void isOffHeapShouldReturnTrueIfAddressIsOnOffHeap() {
-    Chunk value = createChunk(Long.MAX_VALUE);
+    ObjectChunk value = createChunk(Long.MAX_VALUE);
     assertThat(OffHeapRegionEntryHelper.isOffHeap(value.getMemoryAddress())).isTrue();
   }
 
@@ -327,7 +327,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     long oldAddress = 1L;
 
     // testing when the newValue is a chunk
-    Chunk newValue = createChunk(Long.MAX_VALUE);
+    ObjectChunk newValue = createChunk(Long.MAX_VALUE);
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldAddress);
     when(re.setAddress(oldAddress, newValue.getMemoryAddress())).thenReturn(Boolean.TRUE);
@@ -440,13 +440,13 @@ public class OffHeapRegionEntryHelperJUnitTest {
     // mock region entry
     OffHeapRegionEntry re = mock(OffHeapRegionEntry.class);
 
-    Chunk oldValue = createChunk(Long.MAX_VALUE);
-    Chunk newValue = createChunk(Long.MAX_VALUE - 1);
+    ObjectChunk oldValue = createChunk(Long.MAX_VALUE);
+    ObjectChunk newValue = createChunk(Long.MAX_VALUE - 1);
 
     // mock Chunk static methods - in-order to verify that release is called
-    PowerMockito.spy(Chunk.class);
-    PowerMockito.doNothing().when(Chunk.class);
-    Chunk.release(oldValue.getMemoryAddress(), true);
+    PowerMockito.spy(ObjectChunk.class);
+    PowerMockito.doNothing().when(ObjectChunk.class);
+    ObjectChunk.release(oldValue.getMemoryAddress());
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldValue.getMemoryAddress());
@@ -460,7 +460,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
     // verify oldAddress is released
     PowerMockito.verifyStatic();
-    Chunk.release(oldValue.getMemoryAddress(), true);
+    ObjectChunk.release(oldValue.getMemoryAddress());
   }
 
   @Test
@@ -475,9 +475,9 @@ public class OffHeapRegionEntryHelperJUnitTest {
     DataAsAddress newAddress = new DataAsAddress(OffHeapRegionEntryHelper.encodeDataAsAddress(newData, false, false));
 
     // mock Chunk static methods - in-order to verify that release is never called
-    PowerMockito.spy(Chunk.class);
-    PowerMockito.doNothing().when(Chunk.class);
-    Chunk.release(oldAddress, true);
+    PowerMockito.spy(ObjectChunk.class);
+    PowerMockito.doNothing().when(ObjectChunk.class);
+    ObjectChunk.release(oldAddress);
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldAddress);
@@ -491,7 +491,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
     // verify that release is never called as the old address is not on offheap
     PowerMockito.verifyStatic(never());
-    Chunk.release(oldAddress, true);
+    ObjectChunk.release(oldAddress);
   }
 
   @Test
@@ -505,9 +505,9 @@ public class OffHeapRegionEntryHelperJUnitTest {
     long newAddress = OffHeapRegionEntryHelper.REMOVED_PHASE2_ADDRESS;
 
     // mock Chunk static methods - in-order to verify that release is never called
-    PowerMockito.spy(Chunk.class);
-    PowerMockito.doNothing().when(Chunk.class);
-    Chunk.release(oldAddress, true);
+    PowerMockito.spy(ObjectChunk.class);
+    PowerMockito.doNothing().when(ObjectChunk.class);
+    ObjectChunk.release(oldAddress);
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(oldAddress);
@@ -521,7 +521,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
     // verify that release is never called as the old address is not on offheap
     PowerMockito.verifyStatic(never());
-    Chunk.release(oldAddress, true);
+    ObjectChunk.release(oldAddress);
   }
 
   @Test(expected = IllegalStateException.class)
@@ -541,7 +541,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     // mock region entry
     OffHeapRegionEntry re = mock(OffHeapRegionEntry.class);
 
-    Chunk chunk = createChunk(Long.MAX_VALUE);
+    ObjectChunk chunk = createChunk(Long.MAX_VALUE);
 
     // mock region entry methods required for test
     when(re.getAddress()).thenReturn(chunk.getMemoryAddress());
@@ -627,10 +627,10 @@ public class OffHeapRegionEntryHelperJUnitTest {
 
   @Test
   public void addressToObjectShouldReturnValueFromChunk() {
-    Chunk expected = createChunk(Long.MAX_VALUE);
+    ObjectChunk expected = createChunk(Long.MAX_VALUE);
     Object actual = OffHeapRegionEntryHelper.addressToObject(expected.getMemoryAddress(), false, null);
 
-    assertThat(actual).isInstanceOf(Chunk.class);
+    assertThat(actual).isInstanceOf(ObjectChunk.class);
     assertThat(actual).isEqualTo(expected);
   }
 
@@ -640,7 +640,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     boolean isSerialized = true;
     boolean isCompressed = true;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(data, isSerialized, isCompressed, GemFireChunk.TYPE);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(data, isSerialized, isCompressed);
 
     // create the mock context
     RegionEntryContext regionContext = mock(RegionEntryContext.class);
@@ -669,7 +669,7 @@ public class OffHeapRegionEntryHelperJUnitTest {
     boolean isSerialized = false;
     boolean isCompressed = true;
 
-    GemFireChunk chunk = (GemFireChunk) ma.allocateAndInitialize(data, isSerialized, isCompressed, GemFireChunk.TYPE);
+    ObjectChunk chunk = (ObjectChunk) ma.allocateAndInitialize(data, isSerialized, isCompressed);
 
     // create the mock context
     RegionEntryContext regionContext = mock(RegionEntryContext.class);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
index f0f0461..d5db4e4 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStorageJUnitTest.java
@@ -245,14 +245,14 @@ public class OffHeapStorageJUnitTest {
 
       OutOfOffHeapMemoryException ex = null;
       try {
-        ma.allocate(1024*1024+1, null);
+        ma.allocate(1024*1024+1);
         fail("expected OutOfOffHeapMemoryException");
       } catch (OutOfOffHeapMemoryException expected) {
         ex = expected;
       }
       verify(ooohml).outOfOffHeapMemory(ex);
       try {
-        ma.allocate(1024*1024+1, null);
+        ma.allocate(1024*1024+1);
         fail("expected OutOfOffHeapMemoryException");
       } catch (OutOfOffHeapMemoryException expected) {
         ex = expected;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9899940b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
index 2d86296..630ae22 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapValidationJUnitTest.java
@@ -296,8 +296,8 @@ public class OffHeapValidationJUnitTest {
   
   private long getMemoryAddress(Region region, String key) {
     Object entry = ((LocalRegion) region).getRegionEntry(key)._getValue();
-    assertTrue(entry instanceof Chunk);
-    long memoryAddress = ((Chunk)entry).getMemoryAddress();
+    assertTrue(entry instanceof ObjectChunk);
+    long memoryAddress = ((ObjectChunk)entry).getMemoryAddress();
     assertTrue(memoryAddress > 0);
     return memoryAddress;
   }