Search in sources :

Example 1 with NewValueImporter

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

the class EntryEventImplTest method verifyExportNewValueWithByteArray.

@Test
public void verifyExportNewValueWithByteArray() {
    LocalRegion region = mock(LocalRegion.class);
    byte[] newValue = new byte[] { 1, 2, 3 };
    NewValueImporter nvImporter = mock(NewValueImporter.class);
    EntryEventImpl e = createEntryEvent(region, newValue);
    e.exportNewValue(nvImporter);
    verify(nvImporter).importNewBytes(newValue, false);
}
Also used : NewValueImporter(org.apache.geode.internal.cache.EntryEventImpl.NewValueImporter) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 2 with NewValueImporter

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

the class EntryEventImplTest method verifyExportNewValueWithUnserializedStoredObject.

@Test
public void verifyExportNewValueWithUnserializedStoredObject() {
    LocalRegion region = mock(LocalRegion.class);
    when(region.getOffHeap()).thenReturn(true);
    StoredObject newValue = mock(StoredObject.class);
    byte[] newValueBytes = new byte[] { 1, 2, 3 };
    when(newValue.getValueAsHeapByteArray()).thenReturn(newValueBytes);
    NewValueImporter nvImporter = mock(NewValueImporter.class);
    EntryEventImpl e = createEntryEvent(region, newValue);
    e.exportNewValue(nvImporter);
    verify(nvImporter).importNewBytes(newValueBytes, false);
}
Also used : 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 3 with NewValueImporter

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

the class EntryEventImplTest method verifyExportNewValueWithStringIgnoresNewValueBytes.

@Test
public void verifyExportNewValueWithStringIgnoresNewValueBytes() {
    LocalRegion region = mock(LocalRegion.class);
    String newValue = "newValue";
    NewValueImporter nvImporter = mock(NewValueImporter.class);
    when(nvImporter.prefersNewSerialized()).thenReturn(true);
    EntryEventImpl e = createEntryEvent(region, newValue);
    byte[] newValueBytes = new byte[] { 1, 2 };
    e.newValueBytes = newValueBytes;
    e.exportNewValue(nvImporter);
    verify(nvImporter).importNewObject(newValue, true);
}
Also used : NewValueImporter(org.apache.geode.internal.cache.EntryEventImpl.NewValueImporter) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 4 with NewValueImporter

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

the class EntryEventImplTest method verifyExportNewValueWithSerializedStoredObjectAndImporterPrefersSerialized.

@Test
public void verifyExportNewValueWithSerializedStoredObjectAndImporterPrefersSerialized() {
    LocalRegion region = mock(LocalRegion.class);
    when(region.getOffHeap()).thenReturn(true);
    StoredObject newValue = mock(StoredObject.class);
    when(newValue.isSerialized()).thenReturn(true);
    byte[] newValueBytes = new byte[] { 1, 2, 3 };
    when(newValue.getValueAsHeapByteArray()).thenReturn(newValueBytes);
    NewValueImporter nvImporter = mock(NewValueImporter.class);
    when(nvImporter.prefersNewSerialized()).thenReturn(true);
    EntryEventImpl e = createEntryEvent(region, newValue);
    e.exportNewValue(nvImporter);
    verify(nvImporter).importNewBytes(newValueBytes, true);
}
Also used : 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 5 with NewValueImporter

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

the class EntryEventImplTest method verifyExportNewValueWithSerializedStoredObjectAndUnretainedNewReferenceOk.

@Test
public void verifyExportNewValueWithSerializedStoredObjectAndUnretainedNewReferenceOk() {
    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);
    when(nvImporter.isUnretainedNewReferenceOk()).thenReturn(true);
    EntryEventImpl e = createEntryEvent(region, newValue);
    e.exportNewValue(nvImporter);
    verify(nvImporter).importNewObject(newValue, 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)

Aggregations

NewValueImporter (org.apache.geode.internal.cache.EntryEventImpl.NewValueImporter)10 UnitTest (org.apache.geode.test.junit.categories.UnitTest)10 Test (org.junit.Test)10 StoredObject (org.apache.geode.internal.offheap.StoredObject)7