Search in sources :

Example 1 with BinaryObjectBuilderImpl

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);
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl)

Example 2 with BinaryObjectBuilderImpl

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);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) BinaryObject(org.apache.ignite.binary.BinaryObject) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 3 with BinaryObjectBuilderImpl

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));
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) BinaryObject(org.apache.ignite.binary.BinaryObject) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 4 with BinaryObjectBuilderImpl

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);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 5 with BinaryObjectBuilderImpl

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));
    }
}
Also used : Field(java.lang.reflect.Field) BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Aggregations

BinaryObjectBuilderImpl (org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl)62 GridBinaryTestClasses (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)56 BinaryObject (org.apache.ignite.binary.BinaryObject)24 ArrayList (java.util.ArrayList)6 LinkedList (java.util.LinkedList)5 List (java.util.List)5 Timestamp (java.sql.Timestamp)4 Date (java.util.Date)4 BinaryType (org.apache.ignite.binary.BinaryType)3 Field (java.lang.reflect.Field)2 UUID (java.util.UUID)2 BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)2 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 BinaryBuilderEnum (org.apache.ignite.internal.binary.builder.BinaryBuilderEnum)1 GridBinaryMarshalerAwareTestClass (org.apache.ignite.internal.binary.mutabletest.GridBinaryMarshalerAwareTestClass)1 GridBinaryTestClass2 (org.apache.ignite.internal.binary.test.GridBinaryTestClass2)1