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);
}
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]);
}
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"));
}
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());
}
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")));
}
Aggregations