'Set up communicator tests.'

def setUp(self):

    super(HTTPClientTests, self).setUp()
    self.config_stubber = test_lib.PreserveConfig()
    self.config_stubber.Start()
    certificate = self.ClientCertFromPrivateKey(config.CONFIG['Client.private_key'])
    self.server_serial_number = 0
    self.server_private_key = config.CONFIG['PrivateKeys.server_key']
    self.server_certificate = config.CONFIG['Frontend.certificate']
    self.client_cn = certificate.GetCN()
    self.CreateNewClientObject()
    utils.InterruptableThread.exit = True
    stats.StatsCollector.exit = True
    self.client = aff4.FACTORY.Create(self.client_cn, aff4_grr.VFSGRRClient, mode='rw', token=self.token)
    self.client.Set(self.client.Schema.CERT(certificate.AsPEM()))
    self.client.Flush()
    self.out_queue_overrider = test_lib.ConfigOverrider({'Client.max_out_queue': 0})
    self.out_queue_overrider.Start()
    self.CreateNewServerCommunicator()
    self.requests_stubber = utils.Stubber(requests, 'request', self.UrlMock)
    self.requests_stubber.Start()
    self.sleep_stubber = utils.Stubber(time, 'sleep', (lambda x: None))
    self.sleep_stubber.Start()
    self.messages = []
    ca_enroller.enrolment_cache.Flush()
    self.server_response = dict(session_id='aff4:/W:session', name='Echo', response_id=2)
