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