use of com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable in project hazelcast by hazelcast.
the class DefaultPortableReaderSpecTest method fromPortableArrayAnyToPortableArrayAnyToPrimitiveScenarios.
// ----------------------------------------------------------------------------------------------------------
// from PORTABLE_ARRAY[any] via PORTABLE_ARRAY[any] to further PRIMITIVE access
// ----------------------------------------------------------------------------------------------------------
private static void fromPortableArrayAnyToPortableArrayAnyToPrimitiveScenarios(List<Object[]> result) {
String p = "fromPortableArrayAnyToPortableArrayAnyToPrimitiveScenarios";
// =============================================
// INPUT mixed
// =============================================
PrimitivePortable p1 = prim(1, NONE);
PrimitivePortable p10 = prim(10, FULL);
PrimitivePortable p20 = prim(20, FULL);
NestedGroupPortable input = nested(new Portable[] { new GroupPortable(new Portable[0]), group(p1, p10), new GroupPortable((Portable[]) null), group(new PrimitivePortable[] { p20 }) });
Class failure = IllegalArgumentException.class;
result.addAll(asList(scenario(input, failure, ByteArray, "portables[any].portables[any].byte_", p), scenario(input, failure, ShortArray, "portables[any].portables[any].short_", p), scenario(input, failure, IntArray, "portables[any].portables[any].int_", p), scenario(input, failure, LongArray, "portables[any].portables[any].long_", p), scenario(input, failure, CharArray, "portables[any].portables[any].char_", p), scenario(input, failure, FloatArray, "portables[any].portables[any].float_", p), scenario(input, failure, DoubleArray, "portables[any].portables[any].double_", p), scenario(input, failure, BooleanArray, "portables[any].portables[any].boolean_", p)));
List expectedUtfArray = list(null, p1.string_, p10.string_, null, p20.string_);
result.add(scenario(input, expectedUtfArray, UTFArray, "portables[any].portables[any].string_", p));
result.addAll(asList(scenario(input, list(null, p1.byte_, p10.byte_, null, p20.byte_), Generic, "portables[any].portables[any].byte_", p), scenario(input, list(null, p1.short_, p10.short_, null, p20.short_), Generic, "portables[any].portables[any].short_", p), scenario(input, list(null, p1.int_, p10.int_, null, p20.int_), Generic, "portables[any].portables[any].int_", p), scenario(input, list(null, p1.long_, p10.long_, null, p20.long_), Generic, "portables[any].portables[any].long_", p), scenario(input, list(null, p1.char_, p10.char_, null, p20.char_), Generic, "portables[any].portables[any].char_", p), scenario(input, list(null, p1.float_, p10.float_, null, p20.float_), Generic, "portables[any].portables[any].float_", p), scenario(input, list(null, p1.double_, p10.double_, null, p20.double_), Generic, "portables[any].portables[any].double_", p), scenario(input, list(null, p1.boolean_, p10.boolean_, null, p20.boolean_), Generic, "portables[any].portables[any].boolean_", p), scenario(input, list(null, p1.string_, p10.string_, null, p20.string_), Generic, "portables[any].portables[any].string_", p)));
// =============================================
// INPUT empty
// =============================================
NestedGroupPortable inputEmpty = nested(new Portable[0]);
result.addAll(asList(scenario(inputEmpty, null, ByteArray, "portables[any].portables[any].byte_", p), scenario(inputEmpty, null, ShortArray, "portables[any].portables[any].short_", p), scenario(inputEmpty, null, IntArray, "portables[any].portables[any].int_", p), scenario(inputEmpty, null, LongArray, "portables[any].portables[any].long_", p), scenario(inputEmpty, null, CharArray, "portables[any].portables[any].char_", p), scenario(inputEmpty, null, FloatArray, "portables[any].portables[any].float_", p), scenario(inputEmpty, null, DoubleArray, "portables[any].portables[any].double_", p), scenario(inputEmpty, null, BooleanArray, "portables[any].portables[any].boolean_", p), scenario(inputEmpty, null, UTFArray, "portables[any].portables[any].string_", p)));
result.addAll(asList(scenario(inputEmpty, null, Generic, "portables[any].portables[any].byte_", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].short_", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].int_", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].long_", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].char_", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].float_", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].double_", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].boolean_", p), scenario(inputEmpty, null, Generic, "portables[any].portables[any].string_", p)));
// =============================================
// INPUT null
// =============================================
NestedGroupPortable inputNull = nested((Portable[]) null);
result.addAll(asList(scenario(inputNull, null, ByteArray, "portables[any].portables[any].byte_", p), scenario(inputNull, null, ShortArray, "portables[any].portables[any].short_", p), scenario(inputNull, null, IntArray, "portables[any].portables[any].int_", p), scenario(inputNull, null, LongArray, "portables[any].portables[any].long_", p), scenario(inputNull, null, CharArray, "portables[any].portables[any].char_", p), scenario(inputNull, null, FloatArray, "portables[any].portables[any].float_", p), scenario(inputNull, null, DoubleArray, "portables[any].portables[any].double_", p), scenario(inputNull, null, BooleanArray, "portables[any].portables[any].boolean_", p), scenario(inputNull, null, UTFArray, "portables[any].portables[any].string_", p)));
result.addAll(asList(scenario(inputNull, null, Generic, "portables[any].portables[any].byte_", p), scenario(inputNull, null, Generic, "portables[any].portables[any].short_", p), scenario(inputNull, null, Generic, "portables[any].portables[any].int_", p), scenario(inputNull, null, Generic, "portables[any].portables[any].long_", p), scenario(inputNull, null, Generic, "portables[any].portables[any].char_", p), scenario(inputNull, null, Generic, "portables[any].portables[any].float_", p), scenario(inputNull, null, Generic, "portables[any].portables[any].double_", p), scenario(inputNull, null, Generic, "portables[any].portables[any].boolean_", p), scenario(inputNull, null, Generic, "portables[any].portables[any].string_", p)));
}
use of com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable in project hazelcast by hazelcast.
the class DefaultPortableReaderSpecTest method reader.
//
// Hazelcast init Utilities
//
public PortableReader reader(Portable portable) throws IOException {
Config config = new Config();
config.getSerializationConfig().addPortableFactory(TestPortableFactory.ID, new TestPortableFactory());
HazelcastInstanceProxy hz = (HazelcastInstanceProxy) createHazelcastInstance(config);
IMap<String, Object> map = hz.getMap("stealingMap");
// avoid the case where there's no class definition
if (portable instanceof PrimitivePortable) {
map.put(P_NON_EMPTY.toString(), P_NON_EMPTY);
}
if (portable instanceof GroupPortable) {
map.put(G_NON_EMPTY.toString(), G_NON_EMPTY);
}
if (portable instanceof NestedGroupPortable) {
map.put(N_NON_EMPTY.toString(), N_NON_EMPTY);
}
map.put(portable.toString(), portable);
EntryStealingProcessor processor = new EntryStealingProcessor(portable.toString());
map.executeOnEntries(processor);
SerializationServiceV1 ss = (SerializationServiceV1) hz.getSerializationService();
return ss.createPortableReader(processor.stolenEntryData);
}
use of com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable in project hazelcast by hazelcast.
the class DefaultPortableReaderSpecTest method fromPortableToPortableToPrimitiveScenarios.
// ----------------------------------------------------------------------------------------------------------
// from PORTABLE via PORTABLE to further access
// ----------------------------------------------------------------------------------------------------------
private static void fromPortableToPortableToPrimitiveScenarios(List<Object[]> result) {
String p = "fromPortableToPortableToPrimitiveScenarios";
// 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, (nestedFullGroup.portable), Portable, "portable", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portable, Portable, "portable.portable", p)));
result.addAll(asList(scenario(nestedFullGroup, (nestedFullGroup.portable), Generic, "portable", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portable, Generic, "portable.portable", p)));
result.addAll(expandPrimitiveScenario(nestedFullGroup, ((GroupPortable) nestedFullGroup.portable).portable, "portable.portable.primitiveUTF_", p));
result.addAll(expandPrimitiveArrayScenario(nestedFullGroup, (PrimitivePortable) ((GroupPortable) nestedFullGroup.portable).portable, "portable.portable.primitiveArray", p));
NestedGroupPortable nestedFullEmptyNullGroup = nested(group(prim(1, FULL), prim(10, NONE), prim(100, NULL)));
result.addAll(expandPrimitiveScenario(nestedFullEmptyNullGroup, ((GroupPortable) nestedFullEmptyNullGroup.portable).portable, "portable.portable.primitiveUTF_", p));
result.addAll(expandPrimitiveArrayScenario(nestedFullEmptyNullGroup, (PrimitivePortable) ((GroupPortable) nestedFullEmptyNullGroup.portable).portable, "portable.portable.primitiveArray", p));
// empty or null portable array de-referenced further
NestedGroupPortable nestedNullArrayGroup = nested(new GroupPortable((Portable[]) null));
result.addAll(asList(scenario(nestedNullArrayGroup, (nestedNullArrayGroup.portable), Portable, "portable", p), scenario(nestedNullArrayGroup, null, Portable, "portable.portable", p)));
result.addAll(asList(scenario(nestedNullArrayGroup, (nestedNullArrayGroup.portable), Generic, "portable", p), scenario(nestedNullArrayGroup, null, Generic, "portable.portable", p)));
result.addAll(expandPrimitiveScenario(nestedNullArrayGroup, null, "portable.portable.primitiveUTF_", p));
result.addAll(expandPrimitiveArrayScenario(nestedNullArrayGroup, null, "portable.portable.primitiveArray", p));
NestedGroupPortable nestedNull = nested(new Portable[0]);
result.addAll(asList(scenario(nestedNull, null, Portable, "portable", p), scenario(nestedNull, null, Portable, "portable.portable", p)));
result.addAll(asList(scenario(nestedNull, null, Generic, "portable", p), scenario(nestedNull, null, Generic, "portable.portable", p)));
result.addAll(expandPrimitiveScenario(nestedNull, null, "portable.portable.primitiveUTF_", p));
result.addAll(expandPrimitiveArrayScenario(nestedNull, null, "portable.portable.primitiveArray", p));
}
use of com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable in project hazelcast by hazelcast.
the class DefaultPortableReaderSpecTest method fromPortableToPortableArrayToPrimitiveScenarios.
// ----------------------------------------------------------------------------------------------------------
// from PORTABLE via PORTABLE_ARRAY to further access
// ----------------------------------------------------------------------------------------------------------
private static void fromPortableToPortableArrayToPrimitiveScenarios(List<Object[]> result) {
// FULLy initialised primitive objects accessed from portable stored in array
String p = "fromPortableToPortableToPrimitiveScenarios";
NestedGroupPortable nestedFullGroup = nested(group(prim(1, FULL), prim(10, FULL), prim(100, FULL)));
result.addAll(asList(scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables, PortableArray, "portable.portables", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables, PortableArray, "portable.portables[any]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables[0], Portable, "portable.portables[0]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables[1], Portable, "portable.portables[1]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables[2], Portable, "portable.portables[2]", p), scenario(nestedFullGroup, null, Portable, "portable.portables[12]", p)));
result.addAll(asList(scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables, Generic, "portable.portables", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables, Generic, "portable.portables[any]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables[0], Generic, "portable.portables[0]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables[1], Generic, "portable.portables[1]", p), scenario(nestedFullGroup, ((GroupPortable) (nestedFullGroup.portable)).portables[2], Generic, "portable.portables[2]", p), scenario(nestedFullGroup, null, Generic, "portable.portables[12]", p)));
result.addAll(expandPortableArrayPrimitiveScenario(nestedFullGroup, (GroupPortable) nestedFullGroup.portable, "portable.portableArray.primitiveUTF_", p));
NestedGroupPortable nestedFullEmptyNullGroup = nested(group(prim(1, FULL), prim(10, NONE), prim(100, NULL)));
result.addAll(expandPortableArrayPrimitiveScenario(nestedFullEmptyNullGroup, (GroupPortable) nestedFullEmptyNullGroup.portable, "portable.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, "portable.portables", p), scenario(nestedNullArrayGroup, null, PortableArray, "portable.portables[any]", p), scenario(nestedNullArrayGroup, null, Portable, "portable.portables[0]", p), scenario(nestedNullArrayGroup, null, Portable, "portable.portables[1]", p), scenario(nestedNullArrayGroup, null, Portable, "portable.portables[2]", p)));
result.addAll(asList(scenario(nestedNullArrayGroup, null, Generic, "portable.portables", p), scenario(nestedNullArrayGroup, null, Generic, "portable.portables[any]", p), scenario(nestedNullArrayGroup, null, Generic, "portable.portables[0]", p), scenario(nestedNullArrayGroup, null, Generic, "portable.portables[1]", p), scenario(nestedNullArrayGroup, null, Generic, "portable.portables[2]", p)));
result.addAll(expandPortableArrayPrimitiveScenario(nestedNullArrayGroup, (GroupPortable) nestedNullArrayGroup.portable, "portable.portableArray.primitiveUTF_", p));
NestedGroupPortable nestedEmptyArrayGroup = nested(new GroupPortable(new Portable[0]));
result.addAll(asList(scenario(nestedEmptyArrayGroup, new Portable[0], PortableArray, "portable.portables", p), scenario(nestedEmptyArrayGroup, null, PortableArray, "portable.portables[any]", p), scenario(nestedEmptyArrayGroup, null, Portable, "portable.portables[0]", p), scenario(nestedEmptyArrayGroup, null, Portable, "portable.portables[1]", p), scenario(nestedEmptyArrayGroup, null, Portable, "portable.portables[2]", p)));
result.addAll(asList(scenario(nestedEmptyArrayGroup, new Portable[0], Generic, "portable.portables", p), scenario(nestedEmptyArrayGroup, null, Generic, "portable.portables[any]", p), scenario(nestedEmptyArrayGroup, null, Generic, "portable.portables[0]", p), scenario(nestedEmptyArrayGroup, null, Generic, "portable.portables[1]", p), scenario(nestedEmptyArrayGroup, null, Generic, "portable.portables[2]", p)));
result.addAll(expandPortableArrayPrimitiveScenario(nestedEmptyArrayGroup, (GroupPortable) nestedEmptyArrayGroup.portable, "portable.portableArray.primitiveUTF_", p));
NestedGroupPortable nestedEmpty = nested(new GroupPortable[0]);
result.addAll(asList(scenario(nestedEmpty, null, PortableArray, "portable.portables", p), scenario(nestedEmpty, null, PortableArray, "portable.portables[any]", p), scenario(nestedEmpty, null, Portable, "portable.portables[0]", p), scenario(nestedEmpty, null, Portable, "portable.portables[1]", p), scenario(nestedEmpty, null, Portable, "portable.portables[2]", p)));
result.addAll(asList(scenario(nestedEmpty, null, Generic, "portable.portables", p), scenario(nestedEmpty, null, Generic, "portable.portables[any]", p), scenario(nestedEmpty, null, Generic, "portable.portables[0]", p), scenario(nestedEmpty, null, Generic, "portable.portables[1]", p), scenario(nestedEmpty, null, Generic, "portable.portables[2]", p)));
result.addAll(expandPortableArrayPrimitiveScenario(nestedEmpty, (GroupPortable) nestedEmpty.portable, "portable.portableArray.primitiveUTF_", p));
NestedGroupPortable nestedNull = nested((GroupPortable[]) null);
result.addAll(asList(scenario(nestedNull, null, PortableArray, "portable.portables", p), scenario(nestedNull, null, PortableArray, "portable.portables[any]", p), scenario(nestedNull, null, Portable, "portable.portables[0]", p), scenario(nestedNull, null, Portable, "portable.portables[1]", p), scenario(nestedNull, null, Portable, "portable.portables[2]", p)));
result.addAll(asList(scenario(nestedNull, null, Generic, "portable.portables", p), scenario(nestedNull, null, Generic, "portable.portables[any]", p), scenario(nestedNull, null, Generic, "portable.portables[0]", p), scenario(nestedNull, null, Generic, "portable.portables[1]", p), scenario(nestedNull, null, Generic, "portable.portables[2]", p)));
result.addAll(expandPortableArrayPrimitiveScenario(nestedNull, (GroupPortable) nestedNull.portable, "portable.portableArray.primitiveUTF_", p));
}
use of com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable 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)));
}
Aggregations