Search in sources :

Example 66 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testByteArrayField.

/**
 * @throws Exception If failed.
 */
public void testByteArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("byteArrayField", new byte[] { 1, 2, 3 });
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertTrue(Arrays.equals(new byte[] { 1, 2, 3 }, po.<byte[]>field("byteArrayField")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 67 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testLongField.

/**
 * @throws Exception If failed.
 */
public void testLongField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("longField", 1L);
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertEquals(1L, po.<Long>field("longField").longValue());
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 68 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testShortArrayField.

/**
 * @throws Exception If failed.
 */
public void testShortArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("shortArrayField", new short[] { 1, 2, 3 });
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertTrue(Arrays.equals(new short[] { 1, 2, 3 }, po.<short[]>field("shortArrayField")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 69 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testDontBrokeCyclicDependency.

/**
 * @throws IgniteCheckedException If any error occurs.
 */
public void testDontBrokeCyclicDependency() throws IgniteCheckedException {
    GridBinaryTestClasses.TestObjectOuter outer = new GridBinaryTestClasses.TestObjectOuter();
    outer.inner = new GridBinaryTestClasses.TestObjectInner();
    outer.inner.outer = outer;
    outer.foo = "a";
    BinaryObjectBuilder builder = builder(toBinary(outer));
    builder.setField("foo", "b");
    GridBinaryTestClasses.TestObjectOuter res = builder.build().deserialize();
    assertEquals("b", res.foo);
    assertSame(res, res.inner.outer);
}
Also used : GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 70 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testUuidField.

/**
 * @throws Exception If failed.
 */
public void testUuidField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    UUID uuid = UUID.randomUUID();
    builder.setField("uuidField", uuid);
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertEquals(uuid, po.<UUID>field("uuidField"));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) UUID(java.util.UUID) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Aggregations

BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)83 BinaryObject (org.apache.ignite.binary.BinaryObject)63 Ignite (org.apache.ignite.Ignite)11 IgniteBinary (org.apache.ignite.IgniteBinary)8 GridBinaryTestClasses (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)7 Date (java.util.Date)4 HashMap (java.util.HashMap)4 BinaryType (org.apache.ignite.binary.BinaryType)4 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 GridQueryProperty (org.apache.ignite.internal.processors.query.GridQueryProperty)3 GridQueryTypeDescriptor (org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor)3 GridH2RowDescriptor (org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor)3 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)3 Column (org.h2.table.Column)3 Field (java.lang.reflect.Field)2 SQLException (java.sql.SQLException)2 LinkedHashMap (java.util.LinkedHashMap)2 UUID (java.util.UUID)2