Search in sources :

Example 31 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testMakeCyclicDependency.

/**
     * @throws IgniteCheckedException If any error occurs.
     */
public void testMakeCyclicDependency() throws IgniteCheckedException {
    GridBinaryTestClasses.TestObjectOuter outer = new GridBinaryTestClasses.TestObjectOuter();
    outer.inner = new GridBinaryTestClasses.TestObjectInner();
    BinaryObjectBuilderImpl mutOuter = wrap(outer);
    BinaryObjectBuilderImpl mutInner = mutOuter.getField("inner");
    mutInner.setField("outer", mutOuter);
    mutInner.setField("foo", mutInner);
    GridBinaryTestClasses.TestObjectOuter res = mutOuter.build().deserialize();
    assertEquals(res, res.inner.outer);
    assertEquals(res.inner, res.inner.foo);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 32 with BinaryObjectBuilderImpl

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

the class BinaryMarshallerSelfTest method testThreadLocalArrayReleased.

/**
     * @throws IgniteCheckedException If failed.
     */
public void testThreadLocalArrayReleased() throws Exception {
    // Checking the writer directly.
    assertEquals(false, INSTANCE.isAcquired());
    BinaryMarshaller marsh = binaryMarshaller();
    try (BinaryWriterExImpl writer = new BinaryWriterExImpl(binaryContext(marsh))) {
        assertEquals(true, INSTANCE.isAcquired());
        writer.writeString("Thread local test");
        writer.array();
        assertEquals(true, INSTANCE.isAcquired());
    }
    // Checking the binary marshaller.
    assertEquals(false, INSTANCE.isAcquired());
    marsh = binaryMarshaller();
    marsh.marshal(new SimpleObject());
    assertEquals(false, INSTANCE.isAcquired());
    marsh = binaryMarshaller();
    // Checking the builder.
    BinaryObjectBuilder builder = new BinaryObjectBuilderImpl(binaryContext(marsh), "org.gridgain.foo.bar.TestClass");
    builder.setField("a", "1");
    BinaryObject binaryObj = builder.build();
    assertEquals(false, INSTANCE.isAcquired());
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 33 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testDateInCollection.

/**
     *
     */
public void testDateInCollection() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    obj.foo = Lists.newArrayList(new Date());
    BinaryObjectBuilderImpl mutableObj = wrap(obj);
    assertEquals(Date.class, ((List<?>) mutableObj.getField("foo")).get(0).getClass());
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses) Date(java.util.Date)

Example 34 with BinaryObjectBuilderImpl

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

the class BinaryObjectBuilderAdditionalSelfTest method testDeepArray.

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

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

the class BinaryObjectBuilderAdditionalSelfTest method testTimestampInCollection.

/**
     *
     */
public void testTimestampInCollection() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    obj.foo = Lists.newArrayList(new Timestamp(100020003));
    BinaryObjectBuilderImpl mutableObj = wrap(obj);
    assertEquals(Timestamp.class, ((List<?>) mutableObj.getField("foo")).get(0).getClass());
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses) Timestamp(java.sql.Timestamp)

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