Search in sources :

Example 41 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 42 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 43 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testDateArrayModification.

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

Example 44 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testEnumArrayModification.

/**
     *
     */
public void testEnumArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.enumArr = new GridBinaryTestClasses.TestObjectEnum[] { GridBinaryTestClasses.TestObjectEnum.A, GridBinaryTestClasses.TestObjectEnum.B };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    BinaryBuilderEnum[] arr = mutObj.getField("enumArr");
    arr[0] = new BinaryBuilderEnum(mutObj.typeId(), GridBinaryTestClasses.TestObjectEnum.B);
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new GridBinaryTestClasses.TestObjectEnum[] { GridBinaryTestClasses.TestObjectEnum.A, GridBinaryTestClasses.TestObjectEnum.B }, res.enumArr);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) BinaryBuilderEnum(org.apache.ignite.internal.binary.builder.BinaryBuilderEnum) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 45 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testLongArrayModification.

/**
     *
     */
public void testLongArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.lArr = new long[] { 1, 1, 1 };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    long[] arr = mutObj.getField("lArr");
    arr[0] = 2;
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new long[] { 2, 1, 1 }, res.lArr);
}
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)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