Exemple #1
0
    def test_double_register_custom_serializer(self):
        config = SerializationConfig()
        config.set_custom_serializer(CustomClass, CustomSerializer)
        service = SerializationServiceV1(serialization_config=config)

        with self.assertRaises(ValueError):
            service._registry.safe_register_serializer(TheOtherCustomSerializer, CustomClass)
    def test_double_register_custom_serializer(self):
        config = SerializationConfig()
        config.set_custom_serializer(CustomClass, CustomSerializer)
        service = SerializationServiceV1(serialization_config=config)

        with self.assertRaises(ValueError):
            service._registry.safe_register_serializer(TheOtherCustomSerializer, CustomClass)
    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)
Exemple #4
0
    def test_custom_serializer(self):
        config = SerializationConfig()
        config.set_custom_serializer(CustomClass, CustomSerializer)

        service = SerializationServiceV1(serialization_config=config)
        obj = CustomClass("uid", "some name", "description text")
        data = service.to_data(obj)

        obj2 = service.to_object(data)
        self.assertEqual(obj, obj2)
        self.assertEqual("CUSTOM", obj2.source)
    def test_global_encode_decode(self):
        config = SerializationConfig()
        config.global_serializer = TestGlobalSerializer

        service = SerializationServiceV1(serialization_config=config)
        obj = CustomClass("uid", "some name", "description text")
        data = service.to_data(obj)

        obj2 = service.to_object(data)
        self.assertEqual(obj, obj2)
        self.assertEqual("GLOBAL", obj2.source)
    def test_custom_serializer(self):
        config = SerializationConfig()
        config.set_custom_serializer(CustomClass, CustomSerializer)

        service = SerializationServiceV1(serialization_config=config)
        obj = CustomClass("uid", "some name", "description text")
        data = service.to_data(obj)

        obj2 = service.to_object(data)
        self.assertEqual(obj, obj2)
        self.assertEqual("CUSTOM", obj2.source)
Exemple #7
0
    def test_global_encode_decode(self):
        config = SerializationConfig()
        config.global_serializer = TestGlobalSerializer

        service = SerializationServiceV1(serialization_config=config)
        obj = CustomClass("uid", "some name", "description text")
        data = service.to_data(obj)

        obj2 = service.to_object(data)
        self.assertEqual(obj, obj2)
        self.assertEqual("GLOBAL", obj2.source)
    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 __init__(self, name):
     threading.Thread.__init__(self, name=name)
     self.gets = 0
     self.puts = 0
     self.removes = 0
     self.setDaemon(True)
     self.my_map = dict()
     self.ss = SerializationServiceV1(serialization_config=SerializationConfig())
    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)
Exemple #14
0
    def __init__(self):
        self.service = SerializationServiceV1(SerializationConfig())
        key = "Test" * 1000
        self.name = "name" * 10
        self.key = self.service.to_data(key)
        if six.PY2:
            self.thread_id = long("1l")
        else:
            self.thread_id = 1
        msg = ClientMessage(payload_size=calculate_size_data(self.key)).append_bool(False).append_data(
            self.key).update_frame_length()
        self.response_message = ClientMessage(msg.buffer)

        self.request = None
        self.response = None
 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
Exemple #16
0
 def setUp(self):
     self.service = SerializationServiceV1(
         serialization_config=SerializationConfig())
 def setUp(self):
     n = random_string()
     self.service = SerializationServiceV1(
         serialization_config=SerializationConfig())
 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)