Search in sources :

Example 6 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testMapEntryOverride.

/**
     *
     */
public void testMapEntryOverride() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    BinaryObjectBuilderImpl mutableObj = wrap(obj);
    mutableObj.setField("foo", new GridMapEntry<>(1, "a"));
    GridBinaryTestClasses.TestObjectContainer res = mutableObj.build().deserialize();
    assertEquals(new GridMapEntry<>(1, "a"), res.foo);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 7 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testMapOverride.

/**
     *
     */
public void testMapOverride() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    Map<Object, Object> map = Maps.newHashMap(ImmutableMap.of(mutObj, "a", "b", mutObj));
    mutObj.setField("foo", map, Object.class);
    GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
    assertEquals(ImmutableMap.of(res, "a", "b", res), 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 8 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testMetadataChangingDoublePut2.

/**
     *
     */
public void testMetadataChangingDoublePut2() {
    BinaryObjectBuilderImpl mutableObj = wrap(new GridBinaryTestClasses.TestObjectContainer());
    mutableObj.setField("xx567", "a");
    mutableObj.setField("xx567", "b");
    mutableObj.build();
    BinaryType metadata = binaries().type(GridBinaryTestClasses.TestObjectContainer.class);
    assertEquals("String", metadata.fieldTypeName("xx567"));
}
Also used : BinaryType(org.apache.ignite.binary.BinaryType) BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 9 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testLinkedListOverride.

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

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

the class BinaryObjectBuilderAdditionalSelfTest method testBuildFromObjectWithoutSchema.

/**
     * Ensure that object w/o schema can be re-built.
     */
public void testBuildFromObjectWithoutSchema() {
    BinaryObjectBuilderImpl binBuilder = wrap(new GridBinaryTestClass2());
    BinaryObject binObj = binBuilder.build();
    BinaryObjectBuilderImpl binBuilder2 = wrap(binObj);
    binBuilder2.build();
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClass2(org.apache.ignite.internal.binary.test.GridBinaryTestClass2)

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