def test_byte_case(self):
        config = SerializationConfig()
        config.default_integer_type = INTEGER_TYPE.BYTE
        service = SerializationServiceV1(serialization_config=config)

        d1 = service.to_data(byte_val)
        v1 = service.to_object(d1)

        self.assertEqual(d1.get_type(), CONSTANT_TYPE_BYTE)
        self.assertEqual(v1, byte_val)
    def test_byte_case(self):
        config = SerializationConfig()
        config.default_integer_type = INTEGER_TYPE.BYTE
        service = SerializationServiceV1(serialization_config=config)

        d1 = service.to_data(byte_val)
        v1 = service.to_object(d1)

        self.assertEqual(d1.get_type(), CONSTANT_TYPE_BYTE)
        self.assertEqual(v1, byte_val)
        with self.assertRaises(HazelcastSerializationError):
            service.to_data(big_int)
    def test_short_case(self):
        config = SerializationConfig()
        config.default_integer_type = INTEGER_TYPE.SHORT
        service = SerializationServiceV1(serialization_config=config)

        d1 = service.to_data(byte_val)
        d2 = service.to_data(short_val)
        v1 = service.to_object(d1)
        v2 = service.to_object(d2)

        self.assertEqual(d1.get_type(), CONSTANT_TYPE_SHORT)
        self.assertEqual(d2.get_type(), CONSTANT_TYPE_SHORT)
        self.assertEqual(v1, byte_val)
        self.assertEqual(v2, short_val)
    def test_int_case(self):
        config = SerializationConfig()
        config.default_integer_type = INTEGER_TYPE.INT
        service = SerializationServiceV1(serialization_config=config)

        d1 = service.to_data(byte_val)
        d2 = service.to_data(short_val)
        d3 = service.to_data(int_val)
        v1 = service.to_object(d1)
        v2 = service.to_object(d2)
        v3 = service.to_object(d3)

        self.assertEqual(d1.get_type(), CONSTANT_TYPE_INTEGER)
        self.assertEqual(d2.get_type(), CONSTANT_TYPE_INTEGER)
        self.assertEqual(d3.get_type(), CONSTANT_TYPE_INTEGER)
        self.assertEqual(v1, byte_val)
        self.assertEqual(v2, short_val)
        self.assertEqual(v3, int_val)
        with self.assertRaises(HazelcastSerializationError):
            service.to_data(big_int)
    def test_dynamic_case(self):
        config = SerializationConfig()
        config.default_integer_type = INTEGER_TYPE.VAR
        service = SerializationServiceV1(serialization_config=config)

        d1 = service.to_data(byte_val)
        d2 = service.to_data(short_val)
        d3 = service.to_data(int_val)
        d4 = service.to_data(long_val)
        v1 = service.to_object(d1)
        v2 = service.to_object(d2)
        v3 = service.to_object(d3)
        v4 = service.to_object(d4)

        self.assertEqual(d1.get_type(), CONSTANT_TYPE_BYTE)
        self.assertEqual(d2.get_type(), CONSTANT_TYPE_SHORT)
        self.assertEqual(d3.get_type(), CONSTANT_TYPE_INTEGER)
        self.assertEqual(d4.get_type(), CONSTANT_TYPE_LONG)
        self.assertEqual(v1, byte_val)
        self.assertEqual(v2, short_val)
        self.assertEqual(v3, int_val)
        self.assertEqual(v4, long_val)
    def test_dynamic_case(self):
        config = SerializationConfig()
        config.default_integer_type = INTEGER_TYPE.VAR
        service = SerializationServiceV1(serialization_config=config)

        d1 = service.to_data(byte_val)
        d2 = service.to_data(short_val)
        d3 = service.to_data(int_val)
        d4 = service.to_data(long_val)
        v1 = service.to_object(d1)
        v2 = service.to_object(d2)
        v3 = service.to_object(d3)
        v4 = service.to_object(d4)

        self.assertEqual(d1.get_type(), CONSTANT_TYPE_BYTE)
        self.assertEqual(d2.get_type(), CONSTANT_TYPE_SHORT)
        self.assertEqual(d3.get_type(), CONSTANT_TYPE_INTEGER)
        self.assertEqual(d4.get_type(), CONSTANT_TYPE_LONG)
        self.assertEqual(v1, byte_val)
        self.assertEqual(v2, short_val)
        self.assertEqual(v3, int_val)
        self.assertEqual(v4, long_val)
 def setUp(self):
     config = SerializationConfig()
     config.default_integer_type = INTEGER_TYPE.BIG_INT
     self.service = SerializationServiceV1(serialization_config=config)
 def setUp(self):
     config = SerializationConfig()
     config.default_integer_type = INTEGER_TYPE.BIG_INT
     self.service = SerializationServiceV1(serialization_config=config)
 def replace_serialization_service(self, integer_type):
     config = SerializationConfig()
     config.default_integer_type = integer_type
     new_service = SerializationServiceV1(config)
     self.map._wrapped._to_data = new_service.to_data
     self.map._wrapped._to_object = new_service.to_object