Search in sources :

Example 56 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testHashSetOverride.

/**
 */
public void testHashSetOverride() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    Set<Object> c = Sets.newHashSet(mutObj, "a", Sets.newHashSet(1, 2));
    mutObj.setField("foo", c, Object.class);
    GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
    c.remove(mutObj);
    c.add(res);
    assertNotSame(c, res.foo);
    assertEquals(c, 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 57 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testDecimalArrayModification.

/**
 */
public void testDecimalArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.bdArr = new BigDecimal[] { new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000) };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    BigDecimal[] arr = mutObj.getField("bdArr");
    arr[0] = new BigDecimal(2000);
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new BigDecimal[] { new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000) }, res.bdArr);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses) BigDecimal(java.math.BigDecimal)

Example 58 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 59 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testSavingObjectWithNotZeroStart.

/**
 */
public void testSavingObjectWithNotZeroStart() {
    GridBinaryTestClasses.TestObjectOuter out = new GridBinaryTestClasses.TestObjectOuter();
    GridBinaryTestClasses.TestObjectInner inner = new GridBinaryTestClasses.TestObjectInner();
    out.inner = inner;
    inner.outer = out;
    BinaryObjectBuilderImpl builder = wrap(out);
    BinaryObjectBuilderImpl innerBuilder = builder.getField("inner");
    GridBinaryTestClasses.TestObjectInner res = innerBuilder.build().deserialize();
    assertSame(res, res.outer.inner);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 60 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testSimpleTypeFieldOverride.

/**
 * @throws Exception If any error occurs.
 */
public void testSimpleTypeFieldOverride() throws Exception {
    GridBinaryTestClasses.TestObjectAllTypes exp = new GridBinaryTestClasses.TestObjectAllTypes();
    exp.setDefaultData();
    BinaryObjectBuilderImpl mutPo = wrap(new GridBinaryTestClasses.TestObjectAllTypes());
    for (Field field : GridBinaryTestClasses.TestObjectAllTypes.class.getDeclaredFields()) mutPo.setField(field.getName(), field.get(exp));
    GridBinaryTestClasses.TestObjectAllTypes res = mutPo.build().deserialize();
    GridTestUtils.deepEquals(exp, 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)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