Search in sources :

Example 31 with BinaryObject

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testObjectArrayField.

/**
 * @throws Exception If failed.
 */
public void testObjectArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("objectArrayField", new Value[] { new Value(1), new Value(2) });
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    Object[] arr = po.field("objectArrayField");
    assertEquals(2, arr.length);
    assertEquals(1, ((BinaryObject) arr[0]).<Value>deserialize().i);
    assertEquals(2, ((BinaryObject) arr[1]).<Value>deserialize().i);
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 32 with BinaryObject

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testBooleanArrayField.

/**
 * @throws Exception If failed.
 */
public void testBooleanArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("booleanArrayField", new boolean[] { true, false });
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    boolean[] arr = po.field("booleanArrayField");
    assertEquals(2, arr.length);
    assertTrue(arr[0]);
    assertFalse(arr[1]);
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 33 with BinaryObject

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testMetaData2.

/**
 * @throws Exception If failed.
 */
public void testMetaData2() throws Exception {
    BinaryObjectBuilder builder = builder("org.test.MetaTest2");
    builder.setField("objectField", "a", Object.class);
    BinaryObject bo = builder.build();
    BinaryType meta = bo.type();
    assertEquals(expectedTypeName("org.test.MetaTest2"), meta.typeName());
    assertEquals("Object", meta.fieldTypeName("objectField"));
}
Also used : BinaryType(org.apache.ignite.binary.BinaryType) BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 34 with BinaryObject

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testByteField.

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

Example 35 with BinaryObject

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testStringArrayField.

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

Aggregations

BinaryObject (org.apache.ignite.binary.BinaryObject)200 BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)55 Ignite (org.apache.ignite.Ignite)28 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)26 IgniteCache (org.apache.ignite.IgniteCache)25 HashMap (java.util.HashMap)16 Cache (javax.cache.Cache)15 ArrayList (java.util.ArrayList)13 Map (java.util.Map)13 LinkedHashMap (java.util.LinkedHashMap)12 List (java.util.List)10 BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)10 IgniteEx (org.apache.ignite.internal.IgniteEx)10 BinaryObjectBuilderImpl (org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl)10 IgniteException (org.apache.ignite.IgniteException)9 GridBinaryTestClasses (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)9 UUID (java.util.UUID)8 BigInteger (java.math.BigInteger)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 BinaryType (org.apache.ignite.binary.BinaryType)7