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