use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class GIIDeltaDUnitTest method getDiskRVV.
protected RegionVersionVector getDiskRVV(VM vm) throws IOException, ClassNotFoundException {
SerializableCallable createData = new SerializableCallable("getRVV") {
public Object call() throws Exception {
Cache cache = getCache();
LocalRegion region = (LocalRegion) cache.getRegion(REGION_NAME);
RegionVersionVector rvv = region.getDiskRegion().getRegionVersionVector();
rvv = rvv.getCloneForTransmission();
HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
// Using gemfire serialization because
// RegionVersionVector is not java serializable
DataSerializer.writeObject(rvv, hdos);
return hdos.toByteArray();
}
};
byte[] result = (byte[]) vm.invoke(createData);
ByteArrayInputStream bais = new ByteArrayInputStream(result);
return DataSerializer.readObject(new DataInputStream(bais));
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class FetchEntriesMessageJUnitTest method testProcessChunk.
@Test
public void testProcessChunk() throws Exception {
cache = Fakes.cache();
PartitionedRegion pr = mock(PartitionedRegion.class);
InternalDistributedSystem system = cache.getInternalDistributedSystem();
FetchEntriesResponse response = new FetchEntriesResponse(system, pr, null, 0);
HeapDataOutputStream chunkStream = createDummyChunk();
FetchEntriesReplyMessage reply = new FetchEntriesReplyMessage(null, 0, 0, chunkStream, 0, 0, 0, false, false);
reply.chunk = chunkStream.toByteArray();
response.processChunk(reply);
assertNull(response.returnRVV);
assertEquals(2, response.returnValue.size());
assertTrue(response.returnValue.get("keyWithOutVersionTag").equals("valueWithOutVersionTag"));
assertTrue(response.returnValue.get("keyWithVersionTag").equals("valueWithVersionTag"));
assertNull(response.returnVersions.get("keyWithOutVersionTag"));
assertNotNull(response.returnVersions.get("keyWithVersionTag"));
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class BlobHelperTest method serializeNullToStreamWritesNullAsBytes.
@Test
public void serializeNullToStreamWritesNullAsBytes() throws Exception {
HeapDataOutputStream hdos = createHeapDataOutputStream();
serializeTo(null, hdos);
assertThat(hdos.toByteArray()).isNotNull().isEqualTo(this.bytesOfNull);
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class BlobHelperTest method serializeUnserializableToStreamThrowsNotSerializableException.
@Test
public void serializeUnserializableToStreamThrowsNotSerializableException() throws Exception {
HeapDataOutputStream hdos = createHeapDataOutputStream();
assertThatThrownBy(() -> serializeTo(new Object(), hdos)).isExactlyInstanceOf(NotSerializableException.class).hasMessage(Object.class.getName());
}
use of org.apache.geode.internal.HeapDataOutputStream in project geode by apache.
the class BlobHelperTest method serializeMapToStreamWritesMapAsBytes.
@Test
public void serializeMapToStreamWritesMapAsBytes() throws Exception {
HeapDataOutputStream hdos = createHeapDataOutputStream();
serializeTo(this.mapWithTwoEntries, hdos);
assertThat(hdos.toByteArray()).isNotNull().isEqualTo(bytesOfMap);
}
Aggregations