Search in sources :

Example 31 with StoredObject

use of org.apache.geode.internal.offheap.StoredObject in project geode by apache.

the class EntryEventImplTest method verifyExportNewValueWithSerializedStoredObject.

@Test
public void verifyExportNewValueWithSerializedStoredObject() {
    LocalRegion region = mock(LocalRegion.class);
    when(region.getOffHeap()).thenReturn(true);
    StoredObject newValue = mock(StoredObject.class);
    when(newValue.isSerialized()).thenReturn(true);
    Object newValueDeserialized = "newValueDeserialized";
    when(newValue.getValueAsDeserializedHeapObject()).thenReturn(newValueDeserialized);
    NewValueImporter nvImporter = mock(NewValueImporter.class);
    EntryEventImpl e = createEntryEvent(region, newValue);
    e.exportNewValue(nvImporter);
    verify(nvImporter).importNewObject(newValueDeserialized, true);
}
Also used : StoredObject(org.apache.geode.internal.offheap.StoredObject) StoredObject(org.apache.geode.internal.offheap.StoredObject) NewValueImporter(org.apache.geode.internal.cache.EntryEventImpl.NewValueImporter) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 32 with StoredObject

use of org.apache.geode.internal.offheap.StoredObject 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 33 with StoredObject

use of org.apache.geode.internal.offheap.StoredObject 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)

Example 34 with StoredObject

use of org.apache.geode.internal.offheap.StoredObject 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

StoredObject (org.apache.geode.internal.offheap.StoredObject)34 Test (org.junit.Test)11 UnitTest (org.apache.geode.test.junit.categories.UnitTest)10 Retained (org.apache.geode.internal.offheap.annotations.Retained)7 Unretained (org.apache.geode.internal.offheap.annotations.Unretained)7 Released (org.apache.geode.internal.offheap.annotations.Released)6 CachedDeserializable (org.apache.geode.internal.cache.CachedDeserializable)5 NewValueImporter (org.apache.geode.internal.cache.EntryEventImpl.NewValueImporter)4 OldValueImporter (org.apache.geode.internal.cache.EntryEventImpl.OldValueImporter)4 IOException (java.io.IOException)3 PdxInstance (org.apache.geode.pdx.PdxInstance)2 InterruptedIOException (java.io.InterruptedIOException)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 CacheException (org.apache.geode.cache.CacheException)1 CacheWriterException (org.apache.geode.cache.CacheWriterException)1 DiskAccessException (org.apache.geode.cache.DiskAccessException)1 EntryEvent (org.apache.geode.cache.EntryEvent)1 Region (org.apache.geode.cache.Region)1