use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class BufferPoolTest method takeInputBuffer_whenPooledInstanceWithVersionSetIsReturned.
@Test
public void takeInputBuffer_whenPooledInstanceWithVersionSetIsReturned() {
Data data = new HeapData(new byte[] {});
BufferObjectDataInput found1 = bufferPool.takeInputBuffer(data);
assertEquals(Version.UNKNOWN, found1.getVersion());
found1.setVersion(Versions.CURRENT_CLUSTER_VERSION);
bufferPool.returnInputBuffer(found1);
BufferObjectDataInput found2 = bufferPool.takeInputBuffer(data);
assertEquals(Version.UNKNOWN, found2.getVersion());
}
use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class BinaryCompatibilityTest method init.
@BeforeClass
public static void init() throws IOException {
for (byte version : versions) {
InputStream input = BinaryCompatibilityTest.class.getResourceAsStream("/" + createFileName(version));
if (input == null) {
fail("Could not locate file " + createFileName(version) + ". Follow the instructions in " + "BinaryCompatibilityFileGenerator to generate the file.");
}
DataInputStream inputStream = new DataInputStream(input);
while (input.available() != 0) {
String objectKey = inputStream.readUTF();
int length = inputStream.readInt();
if (length != NULL_OBJECT) {
byte[] bytes = new byte[length];
inputStream.read(bytes);
dataMap.put(objectKey, new HeapData(bytes));
}
}
inputStream.close();
}
}
use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class EntryEventDataCacheTest method getOrCreateEventDataIncludingValues_whenAlreadyCached.
@Test
public void getOrCreateEventDataIncludingValues_whenAlreadyCached() throws Exception {
// when: creating EntryEventData including values with same arguments
EntryEventData eed = instance.getOrCreateEventData("test", ADDRESS, new HeapData(), new Object(), new Object(), new Object(), EntryEventType.ADDED.getType(), true);
EntryEventData shouldBeCached = instance.getOrCreateEventData("test", ADDRESS, new HeapData(), new Object(), new Object(), new Object(), EntryEventType.ADDED.getType(), true);
// then: returned instances are the same
assertSame(eed, shouldBeCached);
}
use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class EntryEventDataCacheTest method eventDataIncludingValues_whenDataExcludingValuesAreCached.
@Test
public void eventDataIncludingValues_whenDataExcludingValuesAreCached() throws Exception {
// when: EntryEventData excluding values have been created
EntryEventData eed = instance.getOrCreateEventData("test", ADDRESS, new HeapData(), new Object(), new Object(), new Object(), EntryEventType.ADDED.getType(), false);
// then: eventDataIncludingValues returns null or empty collection
assertTrue(instance.eventDataIncludingValues() == null || instance.eventDataIncludingValues().isEmpty());
}
use of com.hazelcast.internal.serialization.impl.HeapData in project hazelcast by hazelcast.
the class EntryEventDataCacheTest method eventDataIncludingValues_whenValueIsCached.
@Test
public void eventDataIncludingValues_whenValueIsCached() throws Exception {
// when: EntryEventData including values have been created
EntryEventData eed = instance.getOrCreateEventData("test", ADDRESS, new HeapData(), new Object(), new Object(), new Object(), EntryEventType.ADDED.getType(), true);
// then: the cache is not empty & eventDataIncludingValues returns the cached entry
assertFalse(instance.isEmpty());
assertSame(eed, instance.eventDataIncludingValues().iterator().next());
}
Aggregations