'Run basic tests on a subclass of AFF4ImageBase.'

def ExerciseAFF4ImageBase(self, classname):

    path = '/C.12345/aff4image'
    with aff4.FACTORY.Create(path, classname, token=self.token) as fd:
        fd.SetChunksize(10)
        for i in range(10):
            fd.Write(('Test%08X\n' % i))
    with aff4.FACTORY.Open(path, token=self.token) as fd:
        for i in range(10):
            self.assertEqual(fd.Read(13), ('Test%08X\n' % i))
    with aff4.FACTORY.Create(path, classname, mode='rw', token=self.token) as fd:
        fd.Set(fd.Schema._CHUNKSIZE(10))
        fd.Write(('X' * 1100))
        self.assertEqual(fd.size, 1100)
        fd.seek((fd.size - 100))
        fd.Write('Hello    World')
        self.assertEqual(fd.size, 1100)
        fd.seek(fd.size)
        fd.Write(('Y' * 10))
        self.assertEqual(fd.size, 1110)
        fd.seek(997)
        data = fd.Read(17)
        self.assertEqual('XXXHello    WorldXXX', data)
        fd.seek(1097)
        data = fd.Read(6)
        self.assertEqual('XXXYYY', data)
    with test_lib.ConfigOverrider({'Server.max_unbound_read_size': 1110}):
        with aff4.FACTORY.Create(path, classname, mode='rw', token=self.token) as fd:
            fd.Set(fd.Schema._CHUNKSIZE(10))
            data = fd.read()
            self.assertEqual(len(data), 1110)
            fd.seek(fd.size)
            fd.Write(('X' * 10))
            fd.seek(0)
            self.assertRaises(aff4.OversizedRead, fd.read)
