Search in sources :

Example 16 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testTimestampInObjectField.

/**
     *
     */
public void testTimestampInObjectField() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    obj.foo = new Timestamp(100020003);
    BinaryObjectBuilderImpl mutableObj = wrap(obj);
    assertEquals(Timestamp.class, mutableObj.getField("foo").getClass());
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses) Timestamp(java.sql.Timestamp)

Example 17 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testHashSetModification.

/**
     *
     */
public void testHashSetModification() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    obj.foo = Sets.newHashSet("a", "b", "c");
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    Set<String> set = mutObj.getField("foo");
    set.remove("b");
    set.add("!");
    assertEquals(Sets.newHashSet("a", "!", "c"), set);
    assertTrue(set.contains("a"));
    assertTrue(set.contains("!"));
    GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
    assertTrue(res.foo instanceof HashSet);
    assertEquals(Sets.newHashSet("a", "!", "c"), res.foo);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 18 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testIntArrayModification.

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

Example 19 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testModifyObjectArray.

/**
     *
     */
public void testModifyObjectArray() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    obj.foo = new Object[] { "a" };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    Object[] arr = mutObj.getField("foo");
    Assert.assertArrayEquals(new Object[] { "a" }, arr);
    arr[0] = "b";
    GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new Object[] { "b" }, (Object[]) 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 20 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testOverrideObjectArrayField.

/**
     *
     */
public void testOverrideObjectArrayField() {
    BinaryObjectBuilderImpl mutObj = wrap(new GridBinaryTestClasses.TestObjectContainer());
    Object[] createdArr = { mutObj, "a", 1, new String[] { "s", "s" }, new byte[] { 1, 2 }, new UUID(3, 0) };
    mutObj.setField("foo", createdArr.clone(), Object.class);
    GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
    createdArr[0] = res;
    assertTrue(Objects.deepEquals(createdArr, res.foo));
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) BinaryObject(org.apache.ignite.binary.BinaryObject) UUID(java.util.UUID) 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