'Make sure the RDFValue instance can be serialized.'

def testSerialization(self, sample=None):

    if (sample is None):
        sample = self.GenerateSample()
    serialized = sample.SerializeToString()
    self.assertIsInstance(serialized, str)
    rdfvalue_object = self.rdfvalue_class.FromSerializedString(serialized)
    self.CheckRDFValue(rdfvalue_object, sample)
    serialized = sample.SerializeToDataStore()
    if (self.rdfvalue_class.data_store_type == 'bytes'):
        self.assertIsInstance(serialized, str)
    elif (self.rdfvalue_class.data_store_type == 'string'):
        self.assertIsInstance(serialized, unicode)
    elif (self.rdfvalue_class.data_store_type in ['unsigned_integer', 'integer']):
        self.assertIsInstance(serialized, (int, long))
    else:
        self.fail(('%s    has    no    valid    data_store_type' % self.rdfvalue_class))
    rdfvalue_object = self.rdfvalue_class.FromDatastoreValue(serialized)
    self.CheckRDFValue(rdfvalue_object, sample)
