Search in sources :

Example 16 with Portable

use of com.hazelcast.nio.serialization.Portable in project hazelcast by hazelcast.

the class QueryAdvancedTest method testUnknownPortableField_notCausesQueryException_withIndex.

@Test
public // see: https://github.com/hazelcast/hazelcast/issues/3927
void testUnknownPortableField_notCausesQueryException_withIndex() {
    String mapName = "default";
    Config config = getConfig();
    config.getSerializationConfig().addPortableFactory(666, new PortableFactory() {

        public Portable create(int classId) {
            return new PortableEmployee();
        }
    });
    config.getMapConfig(mapName).addMapIndexConfig(new MapIndexConfig("notExist", false)).addMapIndexConfig(new MapIndexConfig("n", false));
    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    IMap<Integer, PortableEmployee> map = hazelcastInstance.getMap(mapName);
    for (int i = 0; i < 5; i++) {
        map.put(i, new PortableEmployee(i, "name_" + i));
    }
    Collection values = map.values(new SqlPredicate("n = name_2 OR notExist = name_0"));
    assertEquals(1, values.size());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Portable(com.hazelcast.nio.serialization.Portable) MapIndexConfig(com.hazelcast.config.MapIndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) PortableEmployee(com.hazelcast.query.SampleObjects.PortableEmployee) Collection(java.util.Collection) SqlPredicate(com.hazelcast.query.SqlPredicate) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 17 with Portable

use of com.hazelcast.nio.serialization.Portable in project hazelcast by hazelcast.

the class DefaultPortableReaderSpecTest method fromPortableArrayToPortableArrayAnyScenarios.

// ----------------------------------------------------------------------------------------------------------
// from PORTABLE_ARRAY to PORTABLE_ARRAY access + further
// ----------------------------------------------------------------------------------------------------------
private static void fromPortableArrayToPortableArrayAnyScenarios(List<Object[]> result) {
    String p = "fromPortableArrayToPortableArrayAnyScenarios";
    NestedGroupPortable anyGroup = nested(new Portable[] { group(prim(1, FULL), prim(10, NONE), prim(50, NULL)), group(prim(2, FULL), prim(20, NONE), prim(80, NULL)) });
    result.addAll(asList(scenario(anyGroup, ((GroupPortable) (anyGroup.portables[0])).portables, PortableArray, "portables[0].portables[any]", p), scenario(anyGroup, new Portable[] { prim(1, FULL), prim(2, FULL) }, PortableArray, "portables[any].portables[0]", p), scenario(anyGroup, new Portable[] { prim(10, FULL), prim(20, FULL) }, PortableArray, "portables[any].portables[1]", p), scenario(anyGroup, new Portable[] { prim(50, FULL), prim(80, FULL) }, PortableArray, "portables[any].portables[2]", p), scenario(anyGroup, new Portable[] { prim(1, FULL), prim(10, FULL), prim(50, FULL), prim(2, FULL), prim(20, FULL), prim(80, FULL) }, PortableArray, "portables[any].portables[any]", p)));
    result.addAll(asList(scenario(anyGroup, ((GroupPortable) (anyGroup.portables[0])).portables, Generic, "portables[0].portables[any]", p), scenario(anyGroup, new Portable[] { prim(1, FULL), prim(2, FULL) }, Generic, "portables[any].portables[0]", p), scenario(anyGroup, new Portable[] { prim(10, FULL), prim(20, FULL) }, Generic, "portables[any].portables[1]", p), scenario(anyGroup, new Portable[] { prim(50, FULL), prim(80, FULL) }, Generic, "portables[any].portables[2]", p), scenario(anyGroup, new Portable[] { prim(1, FULL), prim(10, FULL), prim(50, FULL), prim(2, FULL), prim(20, FULL), prim(80, FULL) }, Generic, "portables[any].portables[any]", p)));
    NestedGroupPortable nestedEmptyArrayGroup = nested(new Portable[] { new GroupPortable(new Portable[0]), group(prim(1, FULL), prim(10, NONE), prim(50, NULL)) });
    result.addAll(asList(scenario(nestedEmptyArrayGroup, null, PortableArray, "portables[0].portables[any]", p), scenario(nestedEmptyArrayGroup, new Portable[] { null, prim(1, FULL) }, PortableArray, "portables[any].portables[0]", p), scenario(nestedEmptyArrayGroup, new Portable[] { null, prim(10, FULL) }, PortableArray, "portables[any].portables[1]", p), scenario(nestedEmptyArrayGroup, new Portable[] { null, prim(50, FULL) }, PortableArray, "portables[any].portables[2]", p), scenario(nestedEmptyArrayGroup, new Portable[] { null, prim(1, FULL), prim(10, FULL), prim(50, FULL) }, PortableArray, "portables[any].portables[any]", p)));
    result.addAll(asList(scenario(nestedEmptyArrayGroup, null, Generic, "portables[0].portables[any]", p), scenario(nestedEmptyArrayGroup, new Portable[] { null, prim(1, FULL) }, Generic, "portables[any].portables[0]", p), scenario(nestedEmptyArrayGroup, new Portable[] { null, prim(10, FULL) }, Generic, "portables[any].portables[1]", p), scenario(nestedEmptyArrayGroup, new Portable[] { null, prim(50, FULL) }, Generic, "portables[any].portables[2]", p), scenario(nestedEmptyArrayGroup, new Portable[] { null, prim(1, FULL), prim(10, FULL), prim(50, FULL) }, Generic, "portables[any].portables[any]", p)));
    NestedGroupPortable nestedNullArrayGroup = nested(new Portable[] { new GroupPortable((Portable[]) null), group(prim(1, FULL), prim(10, NONE), prim(50, NULL)) });
    result.addAll(asList(scenario(nestedNullArrayGroup, null, PortableArray, "portables[0].portables[any]", p), scenario(nestedNullArrayGroup, new Portable[] { null, prim(1, FULL) }, PortableArray, "portables[any].portables[0]", p), scenario(nestedNullArrayGroup, new Portable[] { null, prim(10, FULL) }, PortableArray, "portables[any].portables[1]", p), scenario(nestedNullArrayGroup, new Portable[] { null, prim(50, FULL) }, PortableArray, "portables[any].portables[2]", p), scenario(nestedNullArrayGroup, new Portable[] { null, prim(1, FULL), prim(10, FULL), prim(50, FULL) }, PortableArray, "portables[any].portables[any]", p)));
    result.addAll(asList(scenario(nestedNullArrayGroup, null, PortableArray, "portables[0].portables[any]", p), scenario(nestedNullArrayGroup, new Portable[] { null, prim(1, FULL) }, Generic, "portables[any].portables[0]", p), scenario(nestedNullArrayGroup, new Portable[] { null, prim(10, FULL) }, Generic, "portables[any].portables[1]", p), scenario(nestedNullArrayGroup, new Portable[] { null, prim(50, FULL) }, Generic, "portables[any].portables[2]", p), scenario(nestedNullArrayGroup, new Portable[] { null, prim(1, FULL), prim(10, FULL), prim(50, FULL) }, Generic, "portables[any].portables[any]", p)));
}
Also used : GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) Portable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.Method.Portable) Portable(com.hazelcast.nio.serialization.Portable) PrimitivePortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable) GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable)

Example 18 with Portable

use of com.hazelcast.nio.serialization.Portable in project hazelcast by hazelcast.

the class DefaultPortableReaderSpecTest method fromPortableArrayToPrimitiveScenarios.

// ----------------------------------------------------------------------------------------------------------
// from PORTABLE-ARRAY to primitive and primitive-array access
// ----------------------------------------------------------------------------------------------------------
private static void fromPortableArrayToPrimitiveScenarios(List<Object[]> result) {
    String p = "fromPortableArrayToPrimitiveScenarios";
    // FULLy initialised primitive objects accessed from portable stored in array
    GroupPortable fullGroupVarious = group(prim(1, FULL), prim(10, FULL), prim(100, FULL));
    result.addAll(expandPortableArrayPrimitiveScenario(fullGroupVarious, fullGroupVarious, "portableArray.primitiveUTF_", p));
    GroupPortable fullEmptyNullGroup = group(prim(1, FULL), prim(10, NONE), prim(100, NULL));
    result.addAll(expandPortableArrayPrimitiveScenario(fullEmptyNullGroup, fullEmptyNullGroup, "portableArray.primitiveUTF_", p));
    // empty or null portable array de-referenced further
    GroupPortable nullArrayGroup = new GroupPortable((Portable[]) null);
    result.addAll(expandPortableArrayPrimitiveScenario(nullArrayGroup, nullArrayGroup, "portableArray.primitiveUTF_", p));
    GroupPortable emptyArrayGroup = new GroupPortable(new Portable[0]);
    result.addAll(expandPortableArrayPrimitiveScenario(emptyArrayGroup, emptyArrayGroup, "portableArray.primitiveUTF_", p));
    // FULLy initialised primitive arrays accessed from portable stored in array
    GroupPortable fullGroup = group(prim(FULL), prim(FULL), prim(FULL));
    result.addAll(expandPrimitiveArrayScenario(fullGroup, prim(FULL), "portables[0].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(fullGroup, prim(FULL), "portables[1].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(fullGroup, prim(FULL), "portables[2].primitiveArray", p));
    // EMPTY primitive arrays accessed from portable stored in array
    GroupPortable noneGroup = group(prim(NONE), prim(NONE), prim(NONE));
    result.addAll(expandPrimitiveArrayScenario(noneGroup, prim(NONE), "portables[0].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(noneGroup, prim(NONE), "portables[1].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(noneGroup, prim(NONE), "portables[2].primitiveArray", p));
    // NULL primitive arrays accessed from portable stored in array
    GroupPortable nullGroup = group(prim(NULL), prim(NULL), prim(NULL));
    result.addAll(expandPrimitiveArrayScenario(nullGroup, prim(NULL), "portables[0].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(nullGroup, prim(NULL), "portables[1].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(nullGroup, prim(NULL), "portables[2].primitiveArray", p));
    // EMPTY portable array -> de-referenced further for primitive access
    result.addAll(expandPrimitiveScenario(emptyArrayGroup, IllegalArgumentException.class, "portables[0].primitive_", p));
    result.addAll(expandPrimitiveScenario(emptyArrayGroup, IllegalArgumentException.class, "portables[1].primitive_", p));
    result.addAll(expandPrimitiveScenario(emptyArrayGroup, IllegalArgumentException.class, "portables[2].primitive_", p));
    result.add(scenario(emptyArrayGroup, null, UTF, "portables[0].string_", p));
    result.add(scenario(emptyArrayGroup, null, UTF, "portables[1].string_", p));
    result.add(scenario(emptyArrayGroup, null, Generic, "portables[0].string_", p));
    result.add(scenario(emptyArrayGroup, null, Generic, "portables[1].string_", p));
    // EMPTY portable array -> de-referenced further for array access
    result.addAll(expandPrimitiveArrayScenario(emptyArrayGroup, null, "portables[0].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(emptyArrayGroup, null, "portables[1].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(emptyArrayGroup, null, "portables[2].primitiveArray", p));
    // NULL portable array -> de-referenced further for primitive access
    result.addAll(expandPrimitiveScenario(nullArrayGroup, IllegalArgumentException.class, "portables[0].primitive_", p));
    result.addAll(expandPrimitiveScenario(nullArrayGroup, IllegalArgumentException.class, "portables[1].primitive_", p));
    result.addAll(expandPrimitiveScenario(nullArrayGroup, IllegalArgumentException.class, "portables[2].primitive_", p));
    result.add(scenario(nullArrayGroup, null, UTF, "portables[0].string_", p));
    result.add(scenario(nullArrayGroup, null, UTF, "portables[1].string_", p));
    result.add(scenario(nullArrayGroup, null, Generic, "portables[0].string_", p));
    result.add(scenario(nullArrayGroup, null, Generic, "portables[1].string_", p));
    // EMPTY portable array -> de-referenced further for array access
    result.addAll(expandPrimitiveArrayScenario(nullArrayGroup, null, "portables[0].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(nullArrayGroup, null, "portables[1].primitiveArray", p));
    result.addAll(expandPrimitiveArrayScenario(nullArrayGroup, null, "portables[2].primitiveArray", p));
}
Also used : GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) Portable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.Method.Portable) Portable(com.hazelcast.nio.serialization.Portable) PrimitivePortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable) GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable)

Example 19 with Portable

use of com.hazelcast.nio.serialization.Portable in project hazelcast by hazelcast.

the class DefaultPortableReaderSpecTest method fromPortableArrayToPortableArrayToPrimitiveScenarios.

// ----------------------------------------------------------------------------------------------------------
// from PORTABLE_ARRAY to PORTABLE_ARRAY access + further
// ----------------------------------------------------------------------------------------------------------
private static void fromPortableArrayToPortableArrayToPrimitiveScenarios(List<Object[]> result) {
    String p = "fromPortableArrayToPortableArrayToPrimitiveScenarios";
    // FULLy initialised primitive objects accessed from portable stored in array
    NestedGroupPortable nestedFullGroup = nested(group(prim(1, FULL), prim(10, FULL), prim(100, FULL)));
    result.addAll(asList(scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables, PortableArray, "portables[0].portables", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables, PortableArray, "portables[0].portables[any]", p), scenario(nestedFullGroup, new Portable[] { prim(1, FULL) }, PortableArray, "portables[any].portables[0]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables, PortableArray, "portables[any].portables[any]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables[0], Portable, "portables[0].portables[0]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables[1], Portable, "portables[0].portables[1]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables[2], Portable, "portables[0].portables[2]", p), scenario(nestedFullGroup, null, Portable, "portables[0].portables[12]", p)));
    result.addAll(asList(scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables, Generic, "portables[0].portables", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables, Generic, "portables[0].portables[any]", p), scenario(nestedFullGroup, new Portable[] { prim(1, FULL) }, Generic, "portables[any].portables[0]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables, Generic, "portables[any].portables[any]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables[0], Generic, "portables[0].portables[0]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables[1], Generic, "portables[0].portables[1]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portables[0])).portables[2], Generic, "portables[0].portables[2]", p), scenario(nestedFullGroup, null, Generic, "portables[0].portables[12]", p)));
    result.addAll(expandPortableArrayPrimitiveScenario(nestedFullGroup, (GroupPortable) nestedFullGroup.portable, "portables[0].portableArray.primitiveUTF_", p));
    NestedGroupPortable anyGroup = nested(new Portable[] { group(prim(1, FULL), prim(10, NONE), prim(50, NULL)), group(prim(2, FULL), prim(20, NONE), prim(80, NULL)) });
    result.addAll(expandPortableArrayPrimitiveScenario(anyGroup, (GroupPortable) anyGroup.portables[0], "portables[0].portableArray.primitiveUTF_", p));
    // empty or null portable array de-referenced further
    NestedGroupPortable nestedNullArrayGroup = nested(new GroupPortable((Portable[]) null));
    result.addAll(asList(scenario(nestedNullArrayGroup, null, PortableArray, "portables[0].portables", p), scenario(nestedNullArrayGroup, null, PortableArray, "portables[0].portables[any]", p), scenario(nestedNullArrayGroup, null, PortableArray, "portables[any].portables[0]", p), scenario(nestedNullArrayGroup, null, PortableArray, "portables[any].portables[any]", p), scenario(nestedNullArrayGroup, null, Portable, "portables[0].portables[0]", p), scenario(nestedNullArrayGroup, null, Portable, "portables[0].portables[1]", p), scenario(nestedNullArrayGroup, null, Portable, "portables[0].portables[2]", p)));
    result.addAll(asList(scenario(nestedNullArrayGroup, null, Generic, "portables[0].portables", p), scenario(nestedNullArrayGroup, null, Generic, "portables[0].portables[any]", p), scenario(nestedNullArrayGroup, null, Generic, "portables[any].portables[0]", p), scenario(nestedNullArrayGroup, null, Generic, "portables[any].portables[any]", p), scenario(nestedNullArrayGroup, null, Generic, "portables[0].portables[0]", p), scenario(nestedNullArrayGroup, null, Generic, "portables[0].portables[1]", p), scenario(nestedNullArrayGroup, null, Generic, "portables[0].portables[2]", p)));
    result.addAll(expandPortableArrayPrimitiveScenario(nestedNullArrayGroup, (GroupPortable) nestedNullArrayGroup.portable, "portables[0].portableArray.primitiveUTF_", p));
    NestedGroupPortable nestedEmptyArrayGroup = nested(new GroupPortable(new Portable[0]));
    result.addAll(asList(scenario(nestedEmptyArrayGroup, new Portable[0], PortableArray, "portables[0].portables", p), scenario(nestedEmptyArrayGroup, null, PortableArray, "portables[0].portables[any]", p), scenario(nestedEmptyArrayGroup, null, PortableArray, "portables[any].portables[0]", p), scenario(nestedEmptyArrayGroup, null, PortableArray, "portables[any].portables[any]", p), scenario(nestedEmptyArrayGroup, null, Portable, "portables[0].portables[0]", p), scenario(nestedEmptyArrayGroup, null, Portable, "portables[0].portables[1]", p), scenario(nestedEmptyArrayGroup, null, Portable, "portables[0].portables[2]", p)));
    result.addAll(asList(scenario(nestedEmptyArrayGroup, new Portable[0], Generic, "portables[0].portables", p), scenario(nestedEmptyArrayGroup, null, Generic, "portables[0].portables[any]", p), scenario(nestedEmptyArrayGroup, null, Generic, "portables[any].portables[0]", p), scenario(nestedEmptyArrayGroup, null, Generic, "portables[any].portables[any]", p), scenario(nestedEmptyArrayGroup, null, Generic, "portables[0].portables[0]", p), scenario(nestedEmptyArrayGroup, null, Generic, "portables[0].portables[1]", p), scenario(nestedEmptyArrayGroup, null, Generic, "portables[0].portables[2]", p)));
    result.addAll(expandPortableArrayPrimitiveScenario(nestedEmptyArrayGroup, (GroupPortable) nestedEmptyArrayGroup.portable, "portables[0].portableArray.primitiveUTF_", p));
    NestedGroupPortable nestedEmpty = nested(new GroupPortable[0]);
    result.addAll(asList(scenario(nestedEmpty, null, PortableArray, "portables[0].portables", p), scenario(nestedEmpty, null, PortableArray, "portables[0].portables[any]", p), scenario(nestedEmpty, null, PortableArray, "portables[any].portables[0]", p), scenario(nestedEmpty, null, PortableArray, "portables[any].portables[any]", p), scenario(nestedEmpty, null, Portable, "portables[0].portables[0]", p), scenario(nestedEmpty, null, Portable, "portables[0].portables[1]", p), scenario(nestedEmpty, null, Portable, "portables[0].portables[2]", p)));
    result.addAll(asList(scenario(nestedEmpty, null, Generic, "portables[0].portables", p), scenario(nestedEmpty, null, Generic, "portables[0].portables[any]", p), scenario(nestedEmpty, null, Generic, "portables[any].portables[0]", p), scenario(nestedEmpty, null, Generic, "portables[any].portables[any]", p), scenario(nestedEmpty, null, Generic, "portables[0].portables[0]", p), scenario(nestedEmpty, null, Generic, "portables[0].portables[1]", p), scenario(nestedEmpty, null, Generic, "portables[0].portables[2]", p)));
    result.addAll(expandPortableArrayPrimitiveScenario(nestedEmpty, (GroupPortable) nestedEmpty.portable, "portables[0].portableArray.primitiveUTF_", p));
    NestedGroupPortable nestedNull = nested((GroupPortable[]) null);
    result.addAll(asList(scenario(nestedNull, null, PortableArray, "portables[0].portables", p), scenario(nestedNull, null, PortableArray, "portables[0].portables[any]", p), scenario(nestedNull, null, PortableArray, "portables[any].portables[0]", p), scenario(nestedNull, null, PortableArray, "portables[any].portables[any]", p), scenario(nestedNull, null, Portable, "portables[0].portables[0]", p), scenario(nestedNull, null, Portable, "portables[0].portables[1]", p), scenario(nestedNull, null, Portable, "portables[0].portables[2]", p)));
    result.addAll(asList(scenario(nestedNull, null, Generic, "portables[0].portables", p), scenario(nestedNull, null, Generic, "portables[0].portables[any]", p), scenario(nestedNull, null, Generic, "portables[any].portables[0]", p), scenario(nestedNull, null, Generic, "portables[any].portables[any]", p), scenario(nestedNull, null, Generic, "portables[0].portables[0]", p), scenario(nestedNull, null, Generic, "portables[0].portables[1]", p), scenario(nestedNull, null, Generic, "portables[0].portables[2]", p)));
    result.addAll(expandPortableArrayPrimitiveScenario(nestedNull, (GroupPortable) nestedNull.portable, "portables[0].portableArray.primitiveUTF_", p));
}
Also used : GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) Portable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.Method.Portable) Portable(com.hazelcast.nio.serialization.Portable) PrimitivePortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable) GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable)

Example 20 with Portable

use of com.hazelcast.nio.serialization.Portable in project hazelcast by hazelcast.

the class DefaultPortableReaderSpecTest method fromPortableArrayToPortableArrayToPrimitiveArrayAnyScenarios.

// ----------------------------------------------------------------------------------------------------------
// from PORTABLE_ARRAY[any] via PORTABLE_ARRAY[any] to further PRIMITIVE_ARRAY[any] access
// ----------------------------------------------------------------------------------------------------------
private static void fromPortableArrayToPortableArrayToPrimitiveArrayAnyScenarios(List<Object[]> result) {
    String method = "fromPortableArrayToPortableArrayToPrimitiveArrayAnyScenarios";
    String p = method + " mixed";
    // =============================================
    // INPUT mixed
    // =============================================
    NestedGroupPortable input = nested(new Portable[] { new GroupPortable(new Portable[0]), group(prim(1, NONE), prim(10, FULL), prim(50, NULL)), new GroupPortable((Portable[]) null), group(prim(20, FULL), prim(70, NULL)) });
    PrimitivePortable p10 = prim(10, FULL);
    PrimitivePortable p20 = prim(20, FULL);
    Class failure = IllegalArgumentException.class;
    result.addAll(asList(scenario(input, failure, ByteArray, "portables[any].portables[any].bytes[any]", p), scenario(input, failure, ShortArray, "portables[any].portables[any].shorts[any]", p), scenario(input, failure, IntArray, "portables[any].portables[any].ints[any]", p), scenario(input, failure, LongArray, "portables[any].portables[any].longs[any]", p), scenario(input, failure, CharArray, "portables[any].portables[any].chars[any]", p), scenario(input, failure, FloatArray, "portables[any].portables[any].floats[any]", p), scenario(input, failure, DoubleArray, "portables[any].portables[any].doubles[any]", p), scenario(input, failure, BooleanArray, "portables[any].portables[any].booleans[any]", p)));
    List expectedUtfArray = list(null, null, p10.strings, null, null, p20.strings, null);
    result.add(scenario(input, expectedUtfArray, UTFArray, "portables[any].portables[any].strings[any]", p));
    result.addAll(asList(scenario(input, list(null, null, p10.bytes, null, null, p20.bytes, null), Generic, "portables[any].portables[any].bytes[any]", p), scenario(input, list(null, null, p10.shorts, null, null, p20.shorts, null), Generic, "portables[any].portables[any].shorts[any]", p), scenario(input, list(null, null, p10.ints, null, null, p20.ints, null), Generic, "portables[any].portables[any].ints[any]", p), scenario(input, list(null, null, p10.longs, null, null, p20.longs, null), Generic, "portables[any].portables[any].longs[any]", p), scenario(input, list(null, null, p10.chars, null, null, p20.chars, null), Generic, "portables[any].portables[any].chars[any]", p), scenario(input, list(null, null, p10.floats, null, null, p20.floats, null), Generic, "portables[any].portables[any].floats[any]", p), scenario(input, list(null, null, p10.doubles, null, null, p20.doubles, null), Generic, "portables[any].portables[any].doubles[any]", p), scenario(input, list(null, null, p10.booleans, null, null, p20.booleans, null), Generic, "portables[any].portables[any].booleans[any]", p), scenario(input, list(null, null, p10.strings, null, null, p20.strings, null), Generic, "portables[any].portables[any].strings[any]", p)));
    // =============================================
    // INPUT empty
    // =============================================
    p = method + " empty";
    NestedGroupPortable inputEmpty = nested(new Portable[0]);
    result.addAll(asList(scenario(inputEmpty, null, ByteArray, "portables[any].portables[any].bytes[any]", p), scenario(inputEmpty, null, ShortArray, "portables[any].portables[any].shorts[any]", p), scenario(inputEmpty, null, IntArray, "portables[any].portables[any].ints[any]", p), scenario(inputEmpty, null, LongArray, "portables[any].portables[any].longs[any]", p), scenario(inputEmpty, null, CharArray, "portables[any].portables[any].chars[any]", p), scenario(inputEmpty, null, FloatArray, "portables[any].portables[any].floats[any]", p), scenario(inputEmpty, null, DoubleArray, "portables[any].portables[any].doubles[any]", p), scenario(inputEmpty, null, BooleanArray, "portables[any].portables[any].booleans[any]", p), scenario(inputEmpty, null, UTFArray, "portables[any].portables[any].strings[any]", p)));
    result.addAll(asList(scenario(inputEmpty, null, Generic, "portables[any].portables[any].bytes[any]", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].shorts[any]", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].ints[any]", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].longs[any]", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].chars[any]", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].floats[any]", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].doubles[any]", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].booleans[any]", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].strings[any]", p)));
    // =============================================
    // INPUT null
    // =============================================
    p = method + " null";
    NestedGroupPortable inputNull = nested((Portable[]) null);
    result.addAll(asList(scenario(inputNull, null, ByteArray, "portables[any].portables[any].bytes[any]", p), scenario(inputNull, null, ShortArray, "portables[any].portables[any].shorts[any]", p), scenario(inputNull, null, IntArray, "portables[any].portables[any].ints[any]", p), scenario(inputNull, null, LongArray, "portables[any].portables[any].longs[any]", p), scenario(inputNull, null, CharArray, "portables[any].portables[any].chars[any]", p), scenario(inputNull, null, FloatArray, "portables[any].portables[any].floats[any]", p), scenario(inputNull, null, DoubleArray, "portables[any].portables[any].doubles[any]", p), scenario(inputNull, null, BooleanArray, "portables[any].portables[any].booleans[any]", p), scenario(inputNull, null, UTFArray, "portables[any].portables[any].strings[any]", p)));
    result.addAll(asList(scenario(inputNull, null, Generic, "portables[any].portables[any].bytes[any]", p), scenario(inputNull, null, Generic, "portables[any].portables[any].shorts[any]", p), scenario(inputNull, null, Generic, "portables[any].portables[any].ints[any]", p), scenario(inputNull, null, Generic, "portables[any].portables[any].longs[any]", p), scenario(inputNull, null, Generic, "portables[any].portables[any].chars[any]", p), scenario(inputNull, null, Generic, "portables[any].portables[any].floats[any]", p), scenario(inputNull, null, Generic, "portables[any].portables[any].doubles[any]", p), scenario(inputNull, null, Generic, "portables[any].portables[any].booleans[any]", p), scenario(inputNull, null, Generic, "portables[any].portables[any].strings[any]", p)));
}
Also used : GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) Portable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.Method.Portable) Portable(com.hazelcast.nio.serialization.Portable) PrimitivePortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable) PrimitivePortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable)

Aggregations

Portable (com.hazelcast.nio.serialization.Portable)26 QuickTest (com.hazelcast.test.annotation.QuickTest)10 Test (org.junit.Test)10 PortableFactory (com.hazelcast.nio.serialization.PortableFactory)9 ParallelTest (com.hazelcast.test.annotation.ParallelTest)7 GroupPortable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable)6 Portable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.Method.Portable)6 NestedGroupPortable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable)6 PrimitivePortable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 ClientConfig (com.hazelcast.client.config.ClientConfig)4 Config (com.hazelcast.config.Config)4 MapStoreConfig (com.hazelcast.config.MapStoreConfig)4 SqlPredicate (com.hazelcast.query.SqlPredicate)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 MapIndexConfig (com.hazelcast.config.MapIndexConfig)2 SerializationConfig (com.hazelcast.config.SerializationConfig)2 ClassDefinition (com.hazelcast.nio.serialization.ClassDefinition)2 ClassDefinitionBuilder (com.hazelcast.nio.serialization.ClassDefinitionBuilder)2 HazelcastSerializationException (com.hazelcast.nio.serialization.HazelcastSerializationException)2