Search in sources :

Example 11 with OldValueImporter

use of org.apache.geode.internal.cache.EntryEventImpl.OldValueImporter in project geode by apache.

the class EntryEventImplTest method verifyExportOldValueWithSerializedStoredObjectAndImporterPrefersSerialized.

@Test
public void verifyExportOldValueWithSerializedStoredObjectAndImporterPrefersSerialized() {
    LocalRegion region = mock(LocalRegion.class);
    when(region.getOffHeap()).thenReturn(true);
    StoredObject oldValue = mock(StoredObject.class);
    when(oldValue.isSerialized()).thenReturn(true);
    byte[] oldValueBytes = new byte[] { 1, 2, 3 };
    when(oldValue.getValueAsHeapByteArray()).thenReturn(oldValueBytes);
    OldValueImporter ovImporter = mock(OldValueImporter.class);
    when(ovImporter.prefersOldSerialized()).thenReturn(true);
    EntryEventImpl e = createEntryEvent(region, null);
    e.setOldValue(oldValue);
    e.exportOldValue(ovImporter);
    verify(ovImporter).importOldBytes(oldValueBytes, true);
}
Also used : StoredObject(org.apache.geode.internal.offheap.StoredObject) OldValueImporter(org.apache.geode.internal.cache.EntryEventImpl.OldValueImporter) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Aggregations

OldValueImporter (org.apache.geode.internal.cache.EntryEventImpl.OldValueImporter)11 Test (org.junit.Test)11 UnitTest (org.apache.geode.test.junit.categories.UnitTest)10 StoredObject (org.apache.geode.internal.offheap.StoredObject)6 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)1 MemoryAllocatorImpl (org.apache.geode.internal.offheap.MemoryAllocatorImpl)1 NullOffHeapMemoryStats (org.apache.geode.internal.offheap.NullOffHeapMemoryStats)1 NullOutOfOffHeapMemoryListener (org.apache.geode.internal.offheap.NullOutOfOffHeapMemoryListener)1 OffHeapStoredObject (org.apache.geode.internal.offheap.OffHeapStoredObject)1 SlabImpl (org.apache.geode.internal.offheap.SlabImpl)1 TinyStoredObject (org.apache.geode.internal.offheap.TinyStoredObject)1