Search in sources :

Example 51 with Data

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);
}
Also used : Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 52 with Data

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());
}
Also used : Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 53 with Data

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);
}
Also used : Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 54 with Data

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;
}
Also used : Data(com.hazelcast.nio.serialization.Data)

Example 55 with Data

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);
}
Also used : Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Data (com.hazelcast.nio.serialization.Data)773 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)140 Test (org.junit.Test)121 QuickTest (com.hazelcast.test.annotation.QuickTest)118 ParallelTest (com.hazelcast.test.annotation.ParallelTest)108 ArrayList (java.util.ArrayList)81 Map (java.util.Map)64 SerializationService (com.hazelcast.spi.serialization.SerializationService)54 HashMap (java.util.HashMap)54 NodeEngine (com.hazelcast.spi.NodeEngine)50 HashSet (java.util.HashSet)39 Address (com.hazelcast.nio.Address)28 AbstractMap (java.util.AbstractMap)28 Record (com.hazelcast.map.impl.record.Record)27 HazelcastInstance (com.hazelcast.core.HazelcastInstance)26 HeapData (com.hazelcast.internal.serialization.impl.HeapData)26 List (java.util.List)20 Future (java.util.concurrent.Future)20 CacheEventData (com.hazelcast.cache.impl.CacheEventData)19 Operation (com.hazelcast.spi.Operation)18