Search in sources :

Example 1 with MainPortable

use of com.hazelcast.internal.serialization.impl.portable.MainPortable in project hazelcast by hazelcast.

the class AbstractGenericRecordIntegrationTest method testPutWithoutFactory_readAsGenericRecord.

@Test
public void testPutWithoutFactory_readAsGenericRecord() {
    MainPortable expectedPortable = createMainPortable();
    GenericRecord expected = createGenericRecord(expectedPortable);
    assertEquals(expectedPortable.c, expected.getChar("c"));
    assertEquals(expectedPortable.f, expected.getFloat32("f"), 0.1);
    HazelcastInstance[] instances = createCluster();
    IMap<Object, Object> clusterMap = instances[0].getMap("test");
    clusterMap.put(1, expected);
    HazelcastInstance instance = createAccessorInstance(new SerializationConfig());
    IMap<Object, Object> map = instance.getMap("test");
    GenericRecord actual = (GenericRecord) map.get(1);
    assertEquals(expected, actual);
}
Also used : MainPortable(com.hazelcast.internal.serialization.impl.portable.MainPortable) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SerializationConfig(com.hazelcast.config.SerializationConfig) GenericRecord(com.hazelcast.nio.serialization.GenericRecord) PortableTest(com.hazelcast.internal.serialization.impl.portable.PortableTest) Test(org.junit.Test)

Example 2 with MainPortable

use of com.hazelcast.internal.serialization.impl.portable.MainPortable in project hazelcast by hazelcast.

the class AbstractGenericRecordIntegrationTest method createMainPortable.

@Nonnull
private MainPortable createMainPortable() {
    NamedPortable[] nn = new NamedPortable[2];
    nn[0] = new NamedPortable("name", 123);
    nn[1] = new NamedPortable("name", 123);
    InnerPortable inner = new InnerPortable(new byte[] { 0, 1, 2 }, new char[] { 'c', 'h', 'a', 'r' }, new short[] { 3, 4, 5 }, new int[] { 9, 8, 7, 6 }, new long[] { 0, 1, 5, 7, 9, 11 }, new float[] { 0.6543f, -3.56f, 45.67f }, new double[] { 456.456, 789.789, 321.321 }, nn, new BigDecimal[] { new BigDecimal("12345"), new BigDecimal("123456") }, new LocalTime[] { LocalTime.now(), LocalTime.now() }, new LocalDate[] { LocalDate.now(), LocalDate.now() }, new LocalDateTime[] { LocalDateTime.now() }, new OffsetDateTime[] { OffsetDateTime.now() });
    return new MainPortable((byte) 113, true, 'x', (short) -500, 56789, -50992225L, 900.5678f, -897543.3678909d, "this is main portable object created for testing!", inner, new BigDecimal("12312313"), LocalTime.now(), LocalDate.now(), LocalDateTime.now(), OffsetDateTime.now());
}
Also used : MainPortable(com.hazelcast.internal.serialization.impl.portable.MainPortable) InnerPortable(com.hazelcast.internal.serialization.impl.portable.InnerPortable) BigDecimal(java.math.BigDecimal) NamedPortable(com.hazelcast.internal.serialization.impl.portable.NamedPortable) Nonnull(javax.annotation.Nonnull)

Example 3 with MainPortable

use of com.hazelcast.internal.serialization.impl.portable.MainPortable in project hazelcast by hazelcast.

the class AbstractGenericRecordIntegrationTest method testPutWithoutFactory_readAsPortable.

@Test
public void testPutWithoutFactory_readAsPortable() {
    MainPortable expectedPortable = createMainPortable();
    GenericRecord expected = createGenericRecord(expectedPortable);
    assertEquals(expectedPortable.c, expected.getChar("c"));
    assertEquals(expectedPortable.f, expected.getFloat32("f"), 0.1);
    HazelcastInstance[] instances = createCluster();
    IMap<Object, Object> clusterMap = instances[0].getMap("test");
    clusterMap.put(1, expected);
    HazelcastInstance instance = createAccessorInstance(serializationConfig);
    IMap<Object, Object> map = instance.getMap("test");
    MainPortable actual = (MainPortable) map.get(1);
    assertEquals(expectedPortable, actual);
}
Also used : MainPortable(com.hazelcast.internal.serialization.impl.portable.MainPortable) HazelcastInstance(com.hazelcast.core.HazelcastInstance) GenericRecord(com.hazelcast.nio.serialization.GenericRecord) PortableTest(com.hazelcast.internal.serialization.impl.portable.PortableTest) Test(org.junit.Test)

Example 4 with MainPortable

use of com.hazelcast.internal.serialization.impl.portable.MainPortable in project hazelcast by hazelcast.

the class AbstractGenericRecordIntegrationTest method testToStringIsValidJson.

@Test
public void testToStringIsValidJson() {
    MainPortable expectedPortable = createMainPortable();
    GenericRecord expected = createGenericRecord(expectedPortable);
    Json.parse(expected.toString());
}
Also used : MainPortable(com.hazelcast.internal.serialization.impl.portable.MainPortable) GenericRecord(com.hazelcast.nio.serialization.GenericRecord) PortableTest(com.hazelcast.internal.serialization.impl.portable.PortableTest) Test(org.junit.Test)

Aggregations

MainPortable (com.hazelcast.internal.serialization.impl.portable.MainPortable)4 PortableTest (com.hazelcast.internal.serialization.impl.portable.PortableTest)3 GenericRecord (com.hazelcast.nio.serialization.GenericRecord)3 Test (org.junit.Test)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 SerializationConfig (com.hazelcast.config.SerializationConfig)1 InnerPortable (com.hazelcast.internal.serialization.impl.portable.InnerPortable)1 NamedPortable (com.hazelcast.internal.serialization.impl.portable.NamedPortable)1 BigDecimal (java.math.BigDecimal)1 Nonnull (javax.annotation.Nonnull)1