Search in sources :

Example 6 with OldValueImporter

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

the class EntryEventImplTest method verifyExportOldValuePrefersOldValueBytes.

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

Example 7 with OldValueImporter

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

the class EntryEventImplTest method verifyExportOldValueWithCacheDeserializableString.

@Test
public void verifyExportOldValueWithCacheDeserializableString() {
    LocalRegion region = mock(LocalRegion.class);
    CachedDeserializable oldValue = mock(CachedDeserializable.class);
    Object oldValueObj = "oldValueObj";
    when(oldValue.getValue()).thenReturn(oldValueObj);
    OldValueImporter ovImporter = mock(OldValueImporter.class);
    EntryEventImpl e = createEntryEvent(region, null);
    e.setOldValue(oldValue);
    e.exportOldValue(ovImporter);
    verify(ovImporter).importOldObject(oldValueObj, true);
}
Also used : OldValueImporter(org.apache.geode.internal.cache.EntryEventImpl.OldValueImporter) StoredObject(org.apache.geode.internal.offheap.StoredObject) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 8 with OldValueImporter

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

the class EntryEventImplTest method verifyExportOldValueWithByteArray.

@Test
public void verifyExportOldValueWithByteArray() {
    LocalRegion region = mock(LocalRegion.class);
    byte[] oldValue = new byte[] { 1, 2, 3 };
    OldValueImporter ovImporter = mock(OldValueImporter.class);
    EntryEventImpl e = createEntryEvent(region, null);
    e.setOldValue(oldValue);
    e.exportOldValue(ovImporter);
    verify(ovImporter).importOldBytes(oldValue, false);
}
Also used : OldValueImporter(org.apache.geode.internal.cache.EntryEventImpl.OldValueImporter) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 9 with OldValueImporter

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

the class EntryEventImplTest method verifyExportOldValueWithSerializedStoredObject.

@Test
public void verifyExportOldValueWithSerializedStoredObject() {
    LocalRegion region = mock(LocalRegion.class);
    when(region.getOffHeap()).thenReturn(true);
    StoredObject oldValue = mock(StoredObject.class);
    when(oldValue.isSerialized()).thenReturn(true);
    Object oldValueDeserialized = "newValueDeserialized";
    when(oldValue.getValueAsDeserializedHeapObject()).thenReturn(oldValueDeserialized);
    OldValueImporter ovImporter = mock(OldValueImporter.class);
    EntryEventImpl e = createEntryEvent(region, null);
    e.setOldValue(oldValue);
    e.exportOldValue(ovImporter);
    verify(ovImporter).importOldObject(oldValueDeserialized, true);
}
Also used : StoredObject(org.apache.geode.internal.offheap.StoredObject) OldValueImporter(org.apache.geode.internal.cache.EntryEventImpl.OldValueImporter) StoredObject(org.apache.geode.internal.offheap.StoredObject) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 10 with OldValueImporter

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

the class EntryEventImplTest method verifyExportOldValueWithUnserializedStoredObject.

@Test
public void verifyExportOldValueWithUnserializedStoredObject() {
    LocalRegion region = mock(LocalRegion.class);
    when(region.getOffHeap()).thenReturn(true);
    StoredObject oldValue = mock(StoredObject.class);
    byte[] oldValueBytes = new byte[] { 1, 2, 3 };
    when(oldValue.getValueAsHeapByteArray()).thenReturn(oldValueBytes);
    OldValueImporter ovImporter = mock(OldValueImporter.class);
    EntryEventImpl e = createEntryEvent(region, null);
    e.setOldValue(oldValue);
    e.exportOldValue(ovImporter);
    verify(ovImporter).importOldBytes(oldValueBytes, false);
}
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