use of org.apache.ignite.binary.BinaryObject in project ignite by apache.
the class BinaryMarshallerSelfTest method testCollectionFields.
/**
* @throws Exception If failed.
*/
public void testCollectionFields() throws Exception {
BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(CollectionFieldsObject.class.getName()), new BinaryTypeConfiguration(Key.class.getName()), new BinaryTypeConfiguration(Value.class.getName())));
Object[] arr = new Object[] { new Value(1), new Value(2), new Value(3) };
Collection<Value> col = new ArrayList<>(Arrays.asList(new Value(4), new Value(5), new Value(6)));
Map<Key, Value> map = new HashMap<>(F.asMap(new Key(10), new Value(10), new Key(20), new Value(20), new Key(30), new Value(30)));
CollectionFieldsObject obj = new CollectionFieldsObject(arr, col, map);
BinaryObject po = marshal(obj, marsh);
Object[] arr0 = po.field("arr");
assertEquals(3, arr0.length);
int i = 1;
for (Object valPo : arr0) assertEquals(i++, ((BinaryObject) valPo).<Value>deserialize().val);
Collection<BinaryObject> col0 = po.field("col");
i = 4;
for (BinaryObject valPo : col0) assertEquals(i++, valPo.<Value>deserialize().val);
Map<BinaryObject, BinaryObject> map0 = po.field("map");
for (Map.Entry<BinaryObject, BinaryObject> e : map0.entrySet()) assertEquals(e.getKey().<Key>deserialize().key, e.getValue().<Value>deserialize().val);
}
use of org.apache.ignite.binary.BinaryObject in project ignite by apache.
the class BinaryMarshallerSelfTest method testWriteReplacePrivate.
/**
* @throws Exception If failed.
*/
public void testWriteReplacePrivate() throws Exception {
BinaryMarshaller marsh = binaryMarshaller(Collections.singleton(new BinaryTypeConfiguration(TestObject.class.getName())));
TestObject obj = new TestObject();
BinaryObject po = marshal(obj, marsh);
assertEquals(obj, po.deserialize());
assertEquals(obj.val, ((BinaryObject) po.field("val")).deserialize());
}
use of org.apache.ignite.binary.BinaryObject in project ignite by apache.
the class BinaryMarshallerSelfTest method testBinaryCopyLongArray.
/**
* @throws Exception If failed.
*/
public void testBinaryCopyLongArray() throws Exception {
BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
SimpleObject obj = simpleObject();
BinaryObject po = marshal(obj, marsh);
BinaryObject copy = copy(po, F.<String, Object>asMap("lArr", new long[] { 1, 2, 3 }));
assertArrayEquals(new long[] { 1, 2, 3 }, copy.<long[]>field("lArr"));
SimpleObject obj0 = copy.deserialize();
assertArrayEquals(new long[] { 1, 2, 3 }, obj0.lArr);
}
use of org.apache.ignite.binary.BinaryObject in project ignite by apache.
the class BinaryMarshallerSelfTest method testBinaryCopyUuid.
/**
* @throws Exception If failed.
*/
public void testBinaryCopyUuid() throws Exception {
BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
SimpleObject obj = simpleObject();
BinaryObject po = marshal(obj, marsh);
UUID uuid = UUID.randomUUID();
BinaryObject copy = copy(po, F.<String, Object>asMap("uuid", uuid));
assertEquals(uuid, copy.<UUID>field("uuid"));
SimpleObject obj0 = copy.deserialize();
assertEquals(uuid, obj0.uuid);
}
use of org.apache.ignite.binary.BinaryObject in project ignite by apache.
the class BinaryMarshallerSelfTest method testBinaryCopyCharArray.
/**
* @throws Exception If failed.
*/
public void testBinaryCopyCharArray() throws Exception {
BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
SimpleObject obj = simpleObject();
BinaryObject po = marshal(obj, marsh);
BinaryObject copy = copy(po, F.<String, Object>asMap("cArr", new char[] { 1, 2, 3 }));
assertArrayEquals(new char[] { 1, 2, 3 }, copy.<char[]>field("cArr"));
SimpleObject obj0 = copy.deserialize();
assertArrayEquals(new char[] { 1, 2, 3 }, obj0.cArr);
}
Aggregations