use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderDefaultMappersSelfTest method testGetFromCopiedObj.
/**
*
*/
public void testGetFromCopiedObj() {
BinaryObject objStr = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName()).setField("str", "aaa").build();
BinaryObjectBuilderImpl builder = builder(objStr);
assertEquals("aaa", builder.getField("str"));
builder.setField("str", "bbb");
assertEquals("bbb", builder.getField("str"));
assertNull(builder.getField("i_"));
TestCase.assertEquals("bbb", builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
}
use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testArrayListWriteUnmodifiable.
/**
*
*/
public void testArrayListWriteUnmodifiable() {
GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
ArrayList<Object> src = Lists.newArrayList(obj, "a", "b", "c");
obj.foo = src;
BinaryObjectBuilderImpl mutObj = wrap(obj);
GridBinaryTestClasses.TestObjectContainer deserialized = mutObj.build().deserialize();
List<Object> res = (List<Object>) deserialized.foo;
src.set(0, deserialized);
assertEquals(src, res);
}
use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testMapRead.
/**
*
*/
public void testMapRead() {
GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
obj.foo = Maps.newHashMap(ImmutableMap.of(obj, "a", "b", obj));
BinaryObjectBuilderImpl mutObj = wrap(obj);
Map<Object, Object> map = mutObj.getField("foo");
assert map.equals(ImmutableMap.of(mutObj, "a", "b", mutObj));
}
use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testAssignBinaryObject.
/**
*
*/
public void testAssignBinaryObject() {
GridBinaryTestClasses.TestObjectContainer container = new GridBinaryTestClasses.TestObjectContainer();
BinaryObjectBuilderImpl wrapper = wrap(container);
wrapper.setField("foo", toBinary(new GridBinaryTestClasses.TestObjectArrayList()));
GridBinaryTestClasses.TestObjectContainer deserialized = wrapper.build().deserialize();
assertTrue(deserialized.foo instanceof GridBinaryTestClasses.TestObjectArrayList);
}
use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.
the class BinaryObjectBuilderAdditionalSelfTest method testSimpleTypeFieldSetNull.
/**
* @throws Exception If any error occurs.
*/
public void testSimpleTypeFieldSetNull() throws Exception {
GridBinaryTestClasses.TestObjectAllTypes exp = new GridBinaryTestClasses.TestObjectAllTypes();
exp.setDefaultData();
BinaryObjectBuilderImpl mutPo = wrap(exp);
for (Field field : GridBinaryTestClasses.TestObjectAllTypes.class.getDeclaredFields()) {
if (!field.getType().isPrimitive())
mutPo.setField(field.getName(), null);
}
GridBinaryTestClasses.TestObjectAllTypes res = mutPo.build().deserialize();
for (Field field : GridBinaryTestClasses.TestObjectAllTypes.class.getDeclaredFields()) {
if (!field.getType().isPrimitive())
assertNull(field.getName(), field.get(res));
}
}
Aggregations