Search in sources :

Example 46 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testByteArrayModification.

/**
 */
public void testByteArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.bArr = new byte[] { 1, 1, 1 };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    byte[] arr = mutObj.getField("bArr");
    arr[0] = 2;
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new byte[] { 2, 1, 1 }, res.bArr);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 47 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testEnumArrayModification.

/**
 */
public void testEnumArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.enumArr = new GridBinaryTestClasses.TestObjectEnum[] { GridBinaryTestClasses.TestObjectEnum.A, GridBinaryTestClasses.TestObjectEnum.B };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    BinaryBuilderEnum[] arr = mutObj.getField("enumArr");
    arr[0] = new BinaryBuilderEnum(mutObj.typeId(), GridBinaryTestClasses.TestObjectEnum.B);
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new GridBinaryTestClasses.TestObjectEnum[] { GridBinaryTestClasses.TestObjectEnum.A, GridBinaryTestClasses.TestObjectEnum.B }, res.enumArr);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) BinaryBuilderEnum(org.apache.ignite.internal.binary.builder.BinaryBuilderEnum) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 48 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testLinkedListWriteUnmodifiable.

/**
 */
public void testLinkedListWriteUnmodifiable() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    LinkedList<Object> src = Lists.newLinkedList(Arrays.asList(obj, "a", "b", "c"));
    obj.foo = src;
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    GridBinaryTestClasses.TestObjectContainer deserialized = mutObj.build().deserialize();
    List<Object> res = (List<Object>) deserialized.foo;
    src.set(0, deserialized);
    assertEquals(src, res);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) BinaryObject(org.apache.ignite.binary.BinaryObject) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 49 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testHashCode.

/**
 */
public void testHashCode() {
    GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
    BinaryObjectBuilderImpl mutableObj = wrap(obj);
    BinaryObject bo = mutableObj.build();
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(bo), bo.hashCode());
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 50 with BinaryObjectBuilderImpl

use of org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl in project ignite by apache.

the class BinaryObjectBuilderAdditionalSelfTest method testUUIDArrayModification.

/**
 */
public void testUUIDArrayModification() {
    GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
    obj.uuidArr = new UUID[] { new UUID(1, 1), new UUID(1, 1), new UUID(1, 1) };
    BinaryObjectBuilderImpl mutObj = wrap(obj);
    UUID[] arr = mutObj.getField("uuidArr");
    arr[0] = new UUID(2, 2);
    GridBinaryTestClasses.TestObjectAllTypes res = mutObj.build().deserialize();
    Assert.assertArrayEquals(new UUID[] { new UUID(2, 2), new UUID(1, 1), new UUID(1, 1) }, res.uuidArr);
}
Also used : BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) UUID(java.util.UUID) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Aggregations

BinaryObjectBuilderImpl (org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl)63 GridBinaryTestClasses (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)56 BinaryObject (org.apache.ignite.binary.BinaryObject)24 ArrayList (java.util.ArrayList)6 LinkedList (java.util.LinkedList)5 List (java.util.List)5 Timestamp (java.sql.Timestamp)4 Date (java.util.Date)4 BinaryType (org.apache.ignite.binary.BinaryType)3 Field (java.lang.reflect.Field)2 UUID (java.util.UUID)2 BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)2 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 BinaryField (org.apache.ignite.binary.BinaryField)1 BinaryBuilderEnum (org.apache.ignite.internal.binary.builder.BinaryBuilderEnum)1 GridBinaryMarshalerAwareTestClass (org.apache.ignite.internal.binary.mutabletest.GridBinaryMarshalerAwareTestClass)1 GridBinaryTestClass2 (org.apache.ignite.internal.binary.test.GridBinaryTestClass2)1