Search in sources :

Example 6 with NewValueImporter

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

the class EntryEventImplTest method verifyExportNewValueWithStringCachedDeserializablePrefersNewValueBytes.

@Test
public void verifyExportNewValueWithStringCachedDeserializablePrefersNewValueBytes() {
    LocalRegion region = mock(LocalRegion.class);
    CachedDeserializable newValue = mock(CachedDeserializable.class);
    Object newValueObj = "newValueObj";
    when(newValue.getValue()).thenReturn(newValueObj);
    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).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 7 with NewValueImporter

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

the class EntryEventImplTest method verifyExportNewValueWithStringCachedDeserializable.

@Test
public void verifyExportNewValueWithStringCachedDeserializable() {
    LocalRegion region = mock(LocalRegion.class);
    CachedDeserializable newValue = mock(CachedDeserializable.class);
    Object newValueObj = "newValueObj";
    when(newValue.getValue()).thenReturn(newValueObj);
    NewValueImporter nvImporter = mock(NewValueImporter.class);
    EntryEventImpl e = createEntryEvent(region, newValue);
    byte[] newValueBytes = new byte[] { 1, 2 };
    e.newValueBytes = newValueBytes;
    e.setCachedSerializedNewValue(newValueBytes);
    e.exportNewValue(nvImporter);
    verify(nvImporter).importNewObject(newValueObj, 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 8 with NewValueImporter

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

the class EntryEventImplTest method verifyExportNewValueWithStringCachedDeserializablePrefersCachedSerializedNewValue.

@Test
public void verifyExportNewValueWithStringCachedDeserializablePrefersCachedSerializedNewValue() {
    LocalRegion region = mock(LocalRegion.class);
    CachedDeserializable newValue = mock(CachedDeserializable.class);
    Object newValueObj = "newValueObj";
    when(newValue.getValue()).thenReturn(newValueObj);
    NewValueImporter nvImporter = mock(NewValueImporter.class);
    when(nvImporter.prefersNewSerialized()).thenReturn(true);
    EntryEventImpl e = createEntryEvent(region, newValue);
    byte[] newValueBytes = new byte[] { 1, 2 };
    e.setCachedSerializedNewValue(newValueBytes);
    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 9 with NewValueImporter

use of org.apache.geode.internal.cache.EntryEventImpl.NewValueImporter 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 10 with NewValueImporter

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

the class EntryEventImplTest method verifyExportNewValueWithByteArrayCachedDeserializable.

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