Search in sources :

Example 21 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testArrayListRead.

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

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

the class BinaryObjectBuilderAdditionalSelfTest method testHashSetRead.

/**
     *
     */
public void testHashSetRead() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    obj.foo = Sets.newHashSet(obj, "a");
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    Set<Object> set = mutObj.getField("foo");
    assert set.equals(Sets.newHashSet(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 23 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testDateArrayOverride.

/**
     *
     */
@SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
public void testDateArrayOverride() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    BinaryObjectBuilderImpl mutableObj = wrap(obj);
    Date[] arr = { new Date() };
    mutableObj.setField("foo", arr, Object.class);
    GridBinaryTestClasses.TestObjectContainer res = mutableObj.build().deserialize();
    assertEquals(Date[].class, res.foo.getClass());
    assertTrue(Objects.deepEquals(arr, res.foo));
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses) Date(java.util.Date)

Example 24 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testMetadataChangingDoublePut.

/**
     *
     */
public void testMetadataChangingDoublePut() {
    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 25 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testArrayListModification.

/**
     *
     */
public void testArrayListModification() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    obj.foo = Lists.newArrayList("a", "b", "c");
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    List<String> list = mutObj.getField("foo");
    // "a", "b", "c", "!"
    list.add("!");
    // "_", "a", "b", "c", "!"
    list.add(0, "_");
    // "_", "b", "c", "!"
    String s = list.remove(1);
    assertEquals("a", s);
    assertEquals(Arrays.asList("c", "!"), list.subList(2, 4));
    assertEquals(1, list.indexOf("b"));
    assertEquals(1, list.lastIndexOf("b"));
    GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
    assertTrue(res.foo instanceof ArrayList);
    assertEquals(Arrays.asList("_", "b", "c", "!"), res.foo);
}
Also used : ArrayList(java.util.ArrayList) 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