'Test that types are properly serialized.'

def testRDFTypes(self):

    obj = aff4.FACTORY.Create('foobar', aff4.AFF4Object, token=self.token)
    str_url = 'aff4:/users'
    url = rdfvalue.RDFURN(str_url, age=1)
    self.assertRaises(AttributeError, obj.Set, 'aff4:stored', url)
    self.assertRaises(ValueError, obj.Set, obj.Schema.STORED, str_url)
    old_time = time.time
    try:
        time.time = (lambda : 100)
        obj.Set(obj.Schema.STORED, url)
        obj.Close()
        obj = aff4.FACTORY.Open('foobar', token=self.token)
        url = obj.Get(obj.Schema.STORED)
        self.assertEqual(url.__class__, rdfvalue.RDFURN)
        self.assertEqual(str(url), str_url)
        self.assertEqual(url.age, (100 * 1000000.0))
    finally:
        time.time = old_time
