Search in sources :

Example 36 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testCharArrayModification.

/**
     *
     */
public void testCharArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.cArr = new char[] { 'a', 'a', 'a' };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    char[] arr = mutObj.getField("cArr");
    arr[0] = 'b';
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new char[] { 'b', 'a', 'a' }, res.cArr);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 37 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testSimpleTypeFieldSerialize.

/**
     *
     */
public void testSimpleTypeFieldSerialize() {
    GridBinaryTestClasses.TestObjectAllTypes exp = new GridBinaryTestClasses.TestObjectAllTypes();
    exp.setDefaultData();
    BinaryObjectBuilderImpl mutPo = wrap(exp);
    GridBinaryTestClasses.TestObjectAllTypes res = mutPo.build().deserialize();
    GridTestUtils.deepEquals(exp, res);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 38 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testUUIDArrayModification.

/**
     *
     */
public void testUUIDArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.uuidArr = new UUID[] { new UUID(1, 1), new UUID(1, 1), new UUID(1, 1) };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    UUID[] arr = mutObj.getField("uuidArr");
    arr[0] = new UUID(2, 2);
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new UUID[] { new UUID(2, 2), new UUID(1, 1), new UUID(1, 1) }, res.uuidArr);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) UUID(java.util.UUID) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 39 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testRemoveFromExistingObject.

/**
     *
     */
public void testRemoveFromExistingObject() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.setDefaultData();
    BinaryObjectBuilderImpl wrapper = wrap(toBinary(obj));
    wrapper.removeField("str");
    TestCase.assertNull(wrapper.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 40 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testLinkedListWriteUnmodifiable.

/**
     *
     */
public void testLinkedListWriteUnmodifiable() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    LinkedList<Object> src = Lists.newLinkedList(Arrays.asList(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)

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