def setUp(self):
        """
        Load the DB fixtures for the AM (running using Apache).
        Create an xml-rpc client to talk to the AM Proxy through GAPI.
        Run the test Expedient, and create client to talk to it.
        """
        
        import time, httplib, os
        
        call_env_command(settings.CH_PROJECT_DIR, "flush", interactive=False)
        call_env_command(settings.CH_PROJECT_DIR, "syncdb", interactive=False)

        logger.debug("setup started")
        
        # now we can import django stuff
        from django.core.urlresolvers import reverse
        from django.conf import settings as djangosettings
        from openflow.plugin.models import OpenFlowAggregate

        self.assertEqual(OpenFlowAggregate.objects.all().count(), 0)

        self.create_users()
        
        self.browser = Browser()
        self.browser.login(get_base_url(reverse("auth_login")),
                           username="expedient",
                           password="expedient")
        
        self.setup_dummy_oms()
        
        # store the trusted CA dir
        self.before = os.listdir(djangosettings.XMLRPC_TRUSTED_CA_PATH)
        
        # Create the ssl certificates
        cmd = settings.SSL_DIR % "make -C %s"
        run_cmd(cmd).wait()
        
        # add the certificate to apache's certificate dir
        try:
            os.unlink(join(settings.APACHE_CERTS_DIR, "test-ca.crt"))
        except OSError as e:
            if "Errno 2" in "%s" % e:
                pass
            else:
                raise
        os.symlink(
            os.path.abspath(join(settings.SSL_DIR, "ca.crt")),
            join(settings.APACHE_CERTS_DIR, "test-ca.crt")
        )
        subprocess.call(shlex.split("make -C %s" % settings.APACHE_CERTS_DIR))
        
        # run the CH
        kill_old_procs(settings.GCH_PORT, settings.GAM_PORT)
        cmd = "python %s -u %s -r %s -c %s -k %s -p %s --debug -H 0.0.0.0" % (
            join(settings.GCF_DIR, "gch.py"),
            join(settings.SSL_DIR, "experimenter.crt"),
            join(settings.SSL_DIR, "certs"),
            join(settings.SSL_DIR, "ch.crt"), join(settings.SSL_DIR, "ch.key"),
            settings.GCH_PORT,
        )
        self.ch_proc = run_cmd(cmd, pause=True)
        
#        # run the AM proxy
#        cmd = "python %s -r %s -c %s -k %s -p %s -u %s --debug -H 0.0.0.0" % (
#            join(settings.GCF_DIR, "gam.py"),
#            join(settings.SSL_DIR, "certs"),
#            join(settings.SSL_DIR, "server.crt"),
#            join(settings.SSL_DIR, "server.key"),
#            settings.GAM_PORT,
#            SCHEME + "://%s:%s/openflow/gapi/" % (settings.HOST, settings.CH_PORT),
#        )
#        self.am_proc = run_cmd(cmd, pause=True)
        
        ch_host = "%s:%s" % (settings.HOST, settings.GCH_PORT)
        cert_transport = SafeTransportWithCert(
            keyfile=join(settings.SSL_DIR, "experimenter.key"),
            certfile=join(settings.SSL_DIR, "experimenter.crt"))
        self.ch_client = xmlrpclib.ServerProxy(
            "https://"+ch_host+"/",
            transport=cert_transport)
        
        am_host = "%s:%s" % (settings.HOST, settings.CH_PORT)
        cert_transport = SafeTransportWithCert(
            keyfile=join(settings.SSL_DIR, "experimenter.key"),
            certfile=join(settings.SSL_DIR, "experimenter.crt"))
        self.am_client = xmlrpclib.ServerProxy(
            "https://"+am_host+"/openflow/gapi/",
            transport=cert_transport)
        
        logger.debug("setup done")
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/plugins/openflow/tests/gapi/gapi.py/GAPITests.setUp/swapped operands of `%`