Search in sources :

Example 51 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testLinkedListRead.

/**
 */
public void testLinkedListRead() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    obj.foo = Lists.newLinkedList(Arrays.asList(obj, "a"));
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    List<Object> list = mutObj.getField("foo");
    assert list.equals(Lists.newLinkedList(Arrays.asList(mutObj, "a")));
}
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 52 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testDoubleArrayModification.

/**
 */
public void testDoubleArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.dArr = new double[] { 1.0, 1.0, 1.0 };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    double[] arr = mutObj.getField("dArr");
    arr[0] = 2.0;
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new double[] { 2.0, 1.0, 1.0 }, res.dArr, 0);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 53 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testArrayListOverride.

/**
 */
public void testArrayListOverride() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    ArrayList<Object> list = Lists.newArrayList(mutObj, "a", Lists.newArrayList(1, 2));
    mutObj.setField("foo", list, Object.class);
    GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
    list.set(0, res);
    assertNotSame(list, res.foo);
    assertEquals(list, res.foo);
}
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 54 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testEditObjectWithRawData.

/**
 */
public void testEditObjectWithRawData() {
    GridBinaryMarshalerAwareTestClass obj = new GridBinaryMarshalerAwareTestClass();
    obj.s = "a";
    obj.sRaw = "aa";
    BinaryObjectBuilderImpl mutableObj = wrap(obj);
    mutableObj.setField("s", "z");
    GridBinaryMarshalerAwareTestClass res = mutableObj.build().deserialize();
    assertEquals("z", res.s);
    assertEquals("aa", res.sRaw);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryMarshalerAwareTestClass(org.apache.ignite.internal.binary.mutabletest.GridBinaryMarshalerAwareTestClass)

Example 55 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testBooleanArrayModification.

/**
 */
public void testBooleanArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.zArr = new boolean[] { false, false, false };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    boolean[] arr = mutObj.getField("zArr");
    arr[0] = true;
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    boolean[] expected = new boolean[] { true, false, false };
    assertEquals(expected.length, res.zArr.length);
    for (int i = 0; i < expected.length; i++) assertEquals(expected[i], res.zArr[i]);
}
Also used : 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)63 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 BinaryField (org.apache.ignite.binary.BinaryField)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