use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class CachedQueryEntryTest method testGetKey.
@Test
public void testGetKey() {
String keyObject = "key";
Data keyData = serializationService.toData(keyObject);
QueryableEntry entry = entry(keyData, new Object(), Extractors.empty());
Object key = entry.getKey();
assertEquals(keyObject, key);
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class QueryEntryTest method test_init.
@Test
public void test_init() throws Exception {
Data dataKey = serializationService.toData("dataKey");
Data dataValue = serializationService.toData("dataValue");
QueryableEntry queryEntry = entry(dataKey, dataValue, Extractors.empty());
Object objectValue = queryEntry.getValue();
Object objectKey = queryEntry.getKey();
init(queryEntry, serializationService, serializationService.toData(objectKey), objectValue, Extractors.empty());
// compare references of objects since they should be cloned after QueryEntry#init call.
assertTrue("Old dataKey should not be here", dataKey != queryEntry.getKeyData());
assertTrue("Old dataValue should not be here", dataValue != queryEntry.getValueData());
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class QueryEntryTest method getAttribute_whenValueInObjectFormatThenNoSerialization.
@Test
public void getAttribute_whenValueInObjectFormatThenNoSerialization() {
Data key = serializationService.toData(new SerializableObject());
SerializableObject value = new SerializableObject();
value.name = "somename";
QueryableEntry queryEntry = entry(key, value, Extractors.empty());
Object result = queryEntry.getAttributeValue("name");
assertEquals("somename", result);
assertEquals(0, value.deserializationCount);
assertEquals(0, value.serializationCount);
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class CachedQueryEntryTest method mockPortableData.
private Data mockPortableData() {
Data keyData = mock(Data.class);
when(keyData.isPortable()).thenReturn(true);
return keyData;
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class NodeEngineTest method toData_whenNull.
@Test
public void toData_whenNull() {
Data result = nodeEngine.toData(null);
assertNull(result);
}
Aggregations