Exemple #1
0
    def __init__(self, command = "", port_space = 10, startup_wait = 0.8):
        super(ServerCreator, self).__init__()
        proxy_server.QUIET = True
        self.address = ''
        self.startup_wait = startup_wait
        self.temporary_folder = tempfile.mkdtemp(prefix = 'remove_me_', suffix = '_testcase_script')
        self.weblab_dir = os.path.join(self.temporary_folder, 'weblab')
        self.argv = list(sys.argv)
        self.exc_info = None
        try:
            start_port = new_port()
            # Make a port space
            for _ in xrange(port_space):
                new_port()
            self.shutdown_port = new_port()
            self.public_port = new_port()
            self.address = 'http://localhost:%s/weblab/' % self.public_port
            sys.argv = shlex.split("weblab-admin create %s --ignore-locations --quiet --not-interactive --socket-wait=%s --start-port=%s %s --http-server-port=%s" % (self.weblab_dir, self.shutdown_port, start_port, command, self.public_port))

            weblab_admin()

            variables = {}
            execfile(os.path.join(self.temporary_folder, 'weblab', 'debugging.py'), variables, variables)
            self.ports = variables['PORTS']
            self.temporal_addresses = []
            for port in self.ports:
                self.temporal_addresses.append('http://localhost:%s/weblab/' % port)
        except:
            shutil.rmtree(self.temporary_folder)
            raise
        finally:
            sys.argv = self.argv
    def test_get_reservation_status(self):
        port = new_port()
        self.configurationManager._set_value(self.rfs.FACADE_JSON_PORT, port)
        self.rfs.start()
        try:
            client = WebLabDeustoClient("http://localhost:%s/weblab/" % port)

            expected_sess_id = SessionId.SessionId("whatever")
            NUMBER   = 5

            expected_confirmed_reservation = Reservation.ConfirmedReservation("reservation_id", NUMBER, "{}", 'http://www.weblab.deusto.es/...', '')
            self.mock_server.return_values['get_reservation_status'] = expected_confirmed_reservation

            confirmed_reservation = client.get_reservation_status(expected_sess_id)

            self.assertEquals(
                    expected_sess_id.id,
                    self.mock_server.arguments['get_reservation_status'][0]
                )
            self.assertEquals(
                    expected_confirmed_reservation.time,    
                    confirmed_reservation.time
                )
            self.assertEquals(
                    expected_confirmed_reservation.status,
                    confirmed_reservation.status
                )
        finally:
            self.rfs.stop()
    def generate_laboratory_server(self, cfg_manager, protocols):
        generated_laboratory_server = ServerSkel.factory(
                cfg_manager,
                protocols,
                weblab_exported_methods.Laboratory
            )
        locator = self.generate_locator()

        class RealLaboratoryServer(LaboratoryServer.LaboratoryServer,generated_laboratory_server):
            def __init__(self, coord_address, locator, cfg_manager, *args,**kargs):
                LaboratoryServer.LaboratoryServer.__init__(
                        self,
                        coord_address,
                        locator,
                        cfg_manager,
                        *args,
                        **kargs
                    )

        real_laboratory_server = RealLaboratoryServer(
                self.map['WL_MACHINE1']['WL_SERVER1']['laboratory1'].address,
                locator,
                cfg_manager,
                Direct = (self.map['WL_MACHINE1']['WL_SERVER1']['laboratory1'].address.address,),
                SOAP   = ('',new_port())
            )
        real_laboratory_server.start()

        laboratory_client = locator.get_server(ServerType.Laboratory, None)
        return laboratory_client, real_laboratory_server
    def generate_coordinator_server(self, protocol, cfg_manager):
        map = self.gen_coordination_map(protocol)

        protocols = protocol
        if protocol[0] != Protocols.Direct:
            protocols += (Protocols.Direct,)

        generated_coordinator = ServerSkel.factory(
                cfg_manager,
                protocols,
                voodoo_exported_methods.coordinator
            )

        class RealCoordinatorServer(CoordinatorServer.CoordinatorServer,generated_coordinator):
            def __init__(self,cfg_manager,map,*args,**kargs):
                CoordinatorServer.CoordinatorServer.__init__(self,cfg_manager,map,*args,**kargs)

        real_coordinator_server = RealCoordinatorServer(
                cfg_manager,
                map,
                Direct = (map['WL_MACHINE1']['WL_SERVER1']['coordinator1'].address.address,),
                SOAP   = ('',new_port())
            )
        real_coordinator_server.start()
        self.map = map
        return real_coordinator_server
        def test_send_file(self):
            port = new_port()
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, port)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:%s/weblab/soap/" % port)

                expected_sess_id = SessionId.SessionId("whatever")
                expected_content = 'my file'
                expected_result  = 'hello there'
                file_info        = 'program'

                self.mock_server.return_values['send_file'   ]     = Command.Command(expected_result)

                result = wds.send_file(expected_sess_id, expected_content, file_info)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['send_file'][0]
                    )
                self.assertEquals(
                        expected_content,
                        self.mock_server.arguments['send_file'][1]
                    )
                self.assertEquals(
                        expected_result,
                        result.commandstring
                    )
            finally:
                self.rfs.stop()
        def test_list_experiments(self):
            port = new_port()
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, port)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:%s/weblab/soap/" % port)

                expected_sess_id = SessionId.SessionId("whatever")

                expected_experiments = self._generate_experiments_allowed()
                self.mock_server.return_values['list_experiments'] = expected_experiments

                experiments = wds.list_experiments(expected_sess_id)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['list_experiments'][0]
                    )

                self.assertEquals(
                        len(expected_experiments),
                        len(experiments)
                    )

                self.assertEquals(
                        expected_experiments[0].experiment.name,
                        experiments[0].experiment.name
                    )

                self.assertEquals(
                        expected_experiments[0].experiment.category.name,
                        experiments[0].experiment.category.name
                    )
            finally:
                self.rfs.stop()
        def test_logout(self):
            port = new_port()
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, port)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:%s/weblab/soap/" % port)

                expected_sess_id = SessionId.SessionId("whatever")
                MESSAGE  = 'my message'

                self.mock_server.return_values['logout'] = expected_sess_id

                wds.logout(expected_sess_id)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['logout'][0]
                    )

                self.mock_server.exceptions['logout'] = coreExc.SessionNotFoundError(MESSAGE)

                try:
                    wds.logout(expected_sess_id)
                    self.fail('exception expected')
                except ZSI.FaultException as e:
                    self.assertEquals(
                        UserProcessingRFCodes.CLIENT_SESSION_NOT_FOUND_EXCEPTION_CODE,
                        e.fault.code[1]
                    )
                    self.assertEquals(
                        MESSAGE,
                        e.fault.string
                    )
            finally:
                self.rfs.stop()
    def generate_login_server(self, protocols, cfg_manager):
        login_coord_address = CoordAddress.CoordAddress.translate_address("login1:WL_SERVER1@WL_MACHINE1")
        locator = self.generate_locator()

        generated_login_server = ServerSkel.factory(
                self.generate_configuration_server(),
                protocols,
                weblab_exported_methods.Login
            )

        class RealLoginServer(LoginServer.LoginServer,generated_login_server):
            def __init__(self, coord_address, locator, cfg_manager, *args,**kargs):
                LoginServer.LoginServer.__init__(self, coord_address, locator, cfg_manager, *args, **kargs)

        real_login_server = RealLoginServer(
                login_coord_address,
                locator,
                cfg_manager,
                Direct = (login_coord_address.address,),
                SOAP   = ('',new_port())
            )
        real_login_server.start()

        login_client = locator.get_server(ServerType.Login, None)
        return login_client, real_login_server
    def test_send_command(self):
        port = new_port()
        self.configurationManager._set_value(self.rfs.FACADE_JSON_PORT, port)
        self.rfs.start()
        try:
            client = WebLabDeustoClient("http://localhost:%s/weblab/" % port)

            expected_sess_id = SessionId.SessionId("whatever")
            expected_request_command  = Command.Command('my request command')
            expected_response_command = Command.Command('my response command')

            self.mock_server.return_values['send_command'] = expected_response_command

            obtained_response_command = client.send_command(expected_sess_id, expected_request_command)

            self.assertEquals(
                    expected_sess_id.id,
                    self.mock_server.arguments['send_command'][0]
                )
            self.assertEquals(
                    expected_request_command.get_command_string(),
                    self.mock_server.arguments['send_command'][1].get_command_string()
                )
            self.assertEquals(
                    expected_response_command.get_command_string(),
                    obtained_response_command.get_command_string()
                )
        finally:
            self.rfs.stop()
 def test_server_on_off(self):
     methods = ["method0", "method1", "method2"]
     klz = ServerInternetSocket.generate(self.cfg_manager, methods)
     internet_socket_server = klz("127.0.0.1", new_port())
     parent = TestServer()
     internet_socket_server.register_parent(parent)
     internet_socket_server.start(False)
     time.sleep(0.1)
     internet_socket_server.stop()
    def setUp(self):
        self.cfg_manager = ConfigurationManager()
        self.cfg_manager.append_module(configuration_module)

        self.cfg_manager._set_value(configuration_doc.FACADE_TIMEOUT, 0.001)

        self.current_port = new_port()
        self.cfg_manager._set_value(configuration_doc.CORE_FACADE_PORT, self.current_port)

        app = HelloWorldApp()
        self.server = wsgi_manager.WebLabWsgiServer(self.cfg_manager,  application = app)
    def setUp(self):
        self.cfg_manager = ConfigurationManager()
        self.cfg_manager.append_module(configuration_module)

        self.cfg_manager._set_value(configuration_doc.FACADE_TIMEOUT, 0.001)

        self.current_port = new_port()
        self.cfg_manager._set_value(configuration_doc.CORE_FACADE_PORT,
                                    self.current_port)

        app = HelloWorldApp()
        self.server = wsgi_manager.WebLabWsgiServer(self.cfg_manager,
                                                    application=app)
Exemple #13
0
    def __init__(self, command="", port_space=10, startup_wait=0.8):
        super(ServerCreator, self).__init__()
        proxy_server.QUIET = True
        self.address = ''
        self.startup_wait = startup_wait
        self.temporary_folder = tempfile.mkdtemp(prefix='remove_me_',
                                                 suffix='_testcase_script')
        self.weblab_dir = os.path.join(self.temporary_folder, 'weblab')
        self.argv = list(sys.argv)
        self.exc_info = None
        try:
            start_port = new_port()
            # Make a port space
            for _ in xrange(port_space):
                new_port()
            self.shutdown_port = new_port()
            self.public_port = new_port()
            self.address = 'http://localhost:%s/weblab/' % self.public_port
            sys.argv = shlex.split(
                "weblab-admin create %s --ignore-locations --quiet --not-interactive --socket-wait=%s --start-port=%s %s --http-server-port=%s"
                % (self.weblab_dir, self.shutdown_port, start_port, command,
                   self.public_port))

            weblab_admin()

            variables = {}
            execfile(
                os.path.join(self.temporary_folder, 'weblab', 'debugging.py'),
                variables, variables)
            self.ports = variables['PORTS']
            self.temporal_addresses = []
            for port in self.ports:
                self.temporal_addresses.append('http://localhost:%s/weblab/' %
                                               port)
        except:
            shutil.rmtree(self.temporary_folder)
            raise
        finally:
            sys.argv = self.argv
 def test_server_on_request_off(self):
     methods = ["method0", "method1", "method2"]
     klz_server = ServerInternetSocket.generate(self.cfg_manager, methods)
     yet_other_port = new_port()
     server = klz_server("127.0.0.1", yet_other_port)
     parent = TestServer()
     server.register_parent(parent)
     server.start(False)
     klz_client = ClientInternetSocket.generate(methods)
     client = klz_client("127.0.0.1", yet_other_port)
     result = client.method0()
     self.assertEquals(result, "This is the result of method0()")
     result = client.method1("foobar")
     self.assertEquals(result, "This is the result of method1() (arg1=foobar)")
     result = client.method2("foo", "bar")
     self.assertEquals(result, "This is the result of method2() (arg1=foo and arg2=bar)")
     server.stop()
    def test_get_experiment_use_by_id(self):
        port = new_port()
        self.configurationManager._set_value(self.rfs.FACADE_JSON_PORT, port)
        self.rfs.start()
        try:
            client = WebLabDeustoClient("http://localhost:%s/weblab/" % port)

            expected_sess_id = SessionId.SessionId("whatever")
            expected_reservation_id = SessionId.SessionId("foobar")
            expected_alive_result = RunningReservationResult()

            self.mock_server.return_values['get_experiment_use_by_id'] = expected_alive_result


            obtained_result = client.get_experiment_use_by_id(expected_sess_id, expected_reservation_id)
            self.assertEquals(RunningReservationResult(), obtained_result)
        finally:
            self.rfs.stop()
    def test_login(self):
        port = new_port()
        self.configurationManager._set_value(self.rfs.FACADE_JSON_PORT, port)
        self.rfs.start()
        try:
            client = WebLabDeustoClient('http://127.0.0.1:%s/weblab/' % port)

            expected_sess_id = SessionId.SessionId("whatever")
            USERNAME = '******'
            PASSWORD = '******'
            self.mock_server.return_values['login'] = expected_sess_id

            session = client.login(USERNAME, PASSWORD)
            self.assertEquals(expected_sess_id.id, session.id)

            self.assertEquals( USERNAME, self.mock_server.arguments['login'][0])
            self.assertEquals( PASSWORD, self.mock_server.arguments['login'][1])
        finally:
            self.rfs.stop()
    def test_finished_experiment(self):
        port = new_port()
        self.configurationManager._set_value(self.rfs.FACADE_JSON_PORT, port)
        self.rfs.start()
        try:
            client = WebLabDeustoClient("http://localhost:%s/weblab/" % port)

            expected_sess_id = SessionId.SessionId("whatever")

            self.mock_server.return_values['finished_experiment'] = None

            client.finished_experiment(expected_sess_id)

            self.assertEquals(
                    expected_sess_id.id,
                    self.mock_server.arguments['finished_experiment'][0]
                )
        finally:
            self.rfs.stop()
        def test_login(self):
            port = new_port()
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, port)
            self.rfs.start()
            try:
                wds = LoginWebLabDeustoSOAP("http://localhost:%s/weblab/soap/" % port)

                expected_sess_id = SessionId.SessionId("whatever")
                USERNAME = '******'
                PASSWORD = '******'
                MESSAGE  = 'my message'

                self.mock_server.return_values['login'] = expected_sess_id

                session = wds.login(USERNAME, PASSWORD)
                self.assertEquals(expected_sess_id.id, session.id)

                self.assertEquals(
                        USERNAME,
                        self.mock_server.arguments['login'][0]
                    )
                self.assertEquals(
                        PASSWORD,
                        self.mock_server.arguments['login'][1]
                    )

                self.mock_server.exceptions['login'] = LoginErrors.InvalidCredentialsError(MESSAGE)

                try:
                    wds.login(USERNAME, PASSWORD)
                    self.fail('exception expected')
                except ZSI.FaultException as e:
                    self.assertEquals(
                        LoginRFCodes.CLIENT_INVALID_CREDENTIALS_EXCEPTION_CODE,
                        e.fault.code[1]
                    )
                    self.assertEquals(
                        MESSAGE,
                        e.fault.string
                    )
            finally:
                self.rfs.stop()
        def test_extensible_login(self):
            port = new_port()
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, port)
            self.rfs.start()
            try:
                wds = LoginWebLabDeustoSOAP("http://localhost:%s/weblab/soap/" % port)

                expected_sess_id = SessionId.SessionId("whatever")
                SYSTEM = 'facebook'
                CREDENTIALS = '(my credentials)'
                MESSAGE  = 'my message'

                self.mock_server.return_values['login_based_on_other_credentials'] = expected_sess_id

                session = wds.login_based_on_other_credentials(SYSTEM, CREDENTIALS)
                self.assertEquals(expected_sess_id.id, session.id)

                self.assertEquals(
                        SYSTEM,
                        self.mock_server.arguments['login_based_on_other_credentials'][0]
                    )
                self.assertEquals(
                        CREDENTIALS,
                        self.mock_server.arguments['login_based_on_other_credentials'][1]
                    )

                self.mock_server.exceptions['login_based_on_other_credentials'] = LoginErrors.InvalidCredentialsError(MESSAGE)

                try:
                    wds.login_based_on_other_credentials(SYSTEM, CREDENTIALS)
                    self.fail('exception expected')
                except ZSI.FaultException as e:
                    self.assertEquals(
                        LoginRFCodes.CLIENT_INVALID_CREDENTIALS_EXCEPTION_CODE,
                        e.fault.code[1]
                    )
                    self.assertEquals(
                        MESSAGE,
                        e.fault.string
                    )
            finally:
                self.rfs.stop()
        def test_get_user_information(self):
            port = new_port()
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, port)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://*****:*****@deusto.es',
                        Role("student")
                    )
                self.mock_server.return_values['get_user_information'] = expected_user_information

                user_information = wds.get_user_information(expected_sess_id)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['get_user_information'][0]
                    )
                self.assertEquals(
                        expected_user_information.full_name,    
                        user_information.full_name
                    )
                self.assertEquals(
                        expected_user_information.login,    
                        user_information.login
                    )
                self.assertEquals(
                        expected_user_information.email,
                        user_information.email
                    )
                self.assertEquals(
                        expected_user_information.role.name,
                        user_information.role.name
                    )
            finally:
                self.rfs.stop()
    def test_reserve_experiment(self):
        port = new_port()
        self.configurationManager._set_value(self.rfs.FACADE_JSON_PORT, port)
        self.rfs.start()
        try:
            client = WebLabDeustoClient("http://127.0.0.1:%s/weblab/" % port)

            expected_sess_id = SessionId.SessionId("whatever")
            NUMBER   = 5

            expected_confirmed_reservation = Reservation.ConfirmedReservation("reservation_id", NUMBER, "{}", 'http://www.weblab.deusto.es/...', '')
            expected_experiment_id = self._generate_two_experiments()[0].to_experiment_id()

            self._generate_experiments_allowed()
            self.mock_server.return_values['reserve_experiment'] = expected_confirmed_reservation

            confirmed_reservation = client.reserve_experiment(expected_sess_id, expected_experiment_id, "{}", "{}")

            self.assertEquals(
                    expected_sess_id.id,
                    self.mock_server.arguments['reserve_experiment'][0]
                )
            self.assertEquals(
                    expected_experiment_id.exp_name,
                    self.mock_server.arguments['reserve_experiment'][1].exp_name
                )
            self.assertEquals(
                    expected_experiment_id.cat_name,
                    self.mock_server.arguments['reserve_experiment'][1].cat_name
                )
            self.assertEquals(
                    expected_confirmed_reservation.time,    
                    confirmed_reservation.time
                )
            self.assertEquals(
                    expected_confirmed_reservation.status,
                    confirmed_reservation.status
                )
        finally:
            self.rfs.stop()
    def test_get_experiment_uses_by_id(self):
        port = new_port()
        self.configurationManager._set_value(self.rfs.FACADE_JSON_PORT, port)
        self.rfs.start()
        try:
            client = WebLabDeustoClient("http://localhost:%s/weblab/" % port)

            expected_sess_id = SessionId.SessionId("whatever")
            expected_usage = ExperimentUsage(10, time.time(), time.time(), '127.0.0.1', ExperimentId("exp","cat"), 'reser1', CoordAddress('machine','instance','server'))

            command_sent = CommandSent(Command.Command("request"), time.time(), Command.Command("response"), time.time())
            expected_usage.append_command(command_sent)

            loaded_file_sent = LoadedFileSent('content-of-the-file', time.time(), Command.Command("response"), time.time(), 'program')
            expected_usage.append_file(loaded_file_sent)

            expected_finished_result  = FinishedReservationResult(expected_usage)
            expected_alive_result     = RunningReservationResult()
            expected_cancelled_result = CancelledReservationResult()

            self.mock_server.return_values['get_experiment_uses_by_id'] = (expected_finished_result, expected_alive_result, expected_cancelled_result)

            expected_reservations = (SessionId.SessionId('reservation'), SessionId.SessionId('reservation2'), SessionId.SessionId('reservation3') )

            results = client.get_experiment_uses_by_id(expected_sess_id, expected_reservations)

            self.assertEquals( expected_sess_id.id, self.mock_server.arguments['get_experiment_uses_by_id'][0])
            self.assertEquals( expected_reservations, tuple(self.mock_server.arguments['get_experiment_uses_by_id'][1]))


            self.assertEquals(3, len(results))
            self.assertEquals(expected_finished_result.status,  results[0].status)
            self.assertEquals(expected_alive_result.status,     results[1].status)
            self.assertEquals(expected_cancelled_result.status, results[2].status)

            self.assertEquals(expected_usage, results[0].experiment_use)

        finally:
            self.rfs.stop()
    def generate_fake_experiment(self, cfg_manager, fake_xilinx_impact, fake_serial_port, number, experiment_name, experiment_category_name, protocols):
        generated_experiment = ServerSkel.factory(
                cfg_manager,
                protocols,
                weblab_exported_methods.Experiment
            )
        locator = self.generate_locator()

        class RealUdXilinxExperiment(FakeUdXilinxExperiment,generated_experiment):
            def __init__(self, coord_address, locator, cfg_manager, fake_xilinx_impact, fake_serial_port, *args,**kargs):
                FakeUdXilinxExperiment.__init__(
                        self,
                        coord_address,
                        locator,
                        cfg_manager,
                        fake_xilinx_impact,
                        fake_serial_port,
                        *args,
                        **kargs
                    )

        real_experiment = RealUdXilinxExperiment(
                None,
                None,
                cfg_manager,
                fake_xilinx_impact,
                fake_serial_port,
                Direct = ( self.map['WL_MACHINE1']['WL_SERVER1']['experiment' + number].address.address,),
                SOAP   = ('',new_port() + (int(number)-1))
            )
        real_experiment.start()

        def on_finish():
            experiment_client = locator.get_server(
                            ServerType.Experiment,
                            experiment_name + '@' + experiment_category_name
                        )
            return experiment_client, real_experiment
        return on_finish
        def test_send_command(self):
            port = new_port()
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, port)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:%s/weblab/soap/" % port)

                expected_sess_id = SessionId.SessionId("whatever")
                expected_command = Command.Command('my command')

                self.mock_server.return_values['send_command'] = expected_command

                wds.send_command(expected_sess_id, expected_command)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['send_command'][0]
                    )
                self.assertEquals(
                        expected_command.get_command_string(),
                        self.mock_server.arguments['send_command'][1].get_command_string()
                    )
            finally:
                self.rfs.stop()
    def generate_core_server(self, cfg_manager, protocols):
        ups_coord_address = CoordAddress.CoordAddress.translate_address("ups1:WL_SERVER1@WL_MACHINE1")
        locator = self.generate_locator()

        generated_ups = ServerSkel.factory(
                cfg_manager,
                protocols,
                weblab_exported_methods.UserProcessing
            )

        class RealUserProcessingServer(UserProcessingServer.UserProcessingServer,generated_ups):
            def __init__(self, coord_address, locator, cfg_manager, *args,**kargs):
                UserProcessingServer.UserProcessingServer.__init__(
                        self,
                        coord_address,
                        locator,
                        cfg_manager,
                        *args,
                        **kargs
                    )

        coordinator = coordinator_create(SQLALCHEMY, self.locator, self.cfg_manager)
        coordinator._clean()
        coordinator.stop()

        real_core_server = RealUserProcessingServer(
                ups_coord_address,
                locator,
                cfg_manager,
                Direct = (ups_coord_address.address,),
                SOAP   = ('',new_port())
            )
        real_core_server.start()

        core_client = locator.get_server(ServerType.UserProcessing, None)
        return core_client, real_core_server
import experiments.ud_xilinx.server as UdXilinxExperiment
import weblab.lab.server as LaboratoryServer
import weblab.login.server as LoginServer
import weblab.methods as weblab_exported_methods
import weblab.core.reservations as Reservation
import weblab.core.server    as UserProcessingServer
import weblab.core.user_processor       as UserProcessor
import weblab.core.exc             as core_exc
from weblab.core.coordinator.gateway import create as coordinator_create, SQLALCHEMY



# Wait that time at most for the board to finish programming before giving up.
XILINX_TIMEOUT = 4

PORT1 = new_port()
PORT2 = new_port()
PORT3 = new_port()
PORT5 = new_port()
PORT7 = new_port()
PORT8 = new_port()
PORT9 = new_port()

########################################################
# Case 001: a single instance of everything on a       #
# single instance of the WebLab, with two experiments #
########################################################

class FakeUdXilinxExperiment(UdXilinxExperiment.UdXilinxExperiment):
    def __init__(self, coord_address, locator, cfg_manager, fake_xilinx_impact, fake_serial_port, *args, **kargs):
        super(FakeUdXilinxExperiment,self).__init__(coord_address, locator, cfg_manager, *args, **kargs)
REAL_ID          ='this_is_the_real_id'


class WrappedRemoteFacadeServer(LoginFacadeServer.LoginRemoteFacadeServer):
    rfm_mock = None
    
    def _create_zsi_remote_facade_manager(self, *args, **kwargs):
        return self.rfm_mock
    
    def _create_json_remote_facade_manager(self, *args, **kwargs):
        return self.rfm_mock
    
    def _create_xmlrpc_remote_facade_manager(self, *args, **kwargs):
        return self.rfm_mock

ZSI_PORT    = new_port()
JSON_PORT   = new_port()
XMLRPC_PORT = new_port()

class LoginRemoteFacadeServerTestCase(mocker.MockerTestCase):

    def setUp(self):
        self.configurationManager = ConfigurationManager.ConfigurationManager()
        self.configurationManager.append_module(configuration)
        self.configurationManager._set_value(configuration_doc.FACADE_TIMEOUT, 0.01)

        time.sleep( 0.01 * 5 )

        self.configurationManager._set_value(LoginFacadeServer.LOGIN_FACADE_ZSI_PORT, ZSI_PORT)
        self.configurationManager._set_value(LoginFacadeServer.LOGIN_FACADE_ZSI_SERVICE_NAME, '/weblab/login/soap/')
        self.configurationManager._set_value(LoginFacadeServer.LOGIN_FACADE_ZSI_LISTEN, '')
# This software consists of contributions made by many individuals,
# listed below:
#
# Author: Pablo Orduña <*****@*****.**>
#
import unittest

import traceback
import types
import voodoo.log as log

from test.util.ports import new as new_port
from test.util.module_disposer import uses_module
import voodoo.gen.protocols.XMLRPC.ServerXMLRPC as ServerXMLRPC

PORT = new_port()

class ServerXMLRPCTestCase(unittest.TestCase):

    @uses_module(ServerXMLRPC)
    def test_method(self):
        msg1 = "hello"
        msg2 = " world"
        exc_msg = "Haw haw! (with Nelson's voice)"
        methods = ('method1','method2')
        class Fake(object):
            def __init__(self):
                super(Fake, self).__init__()
                self._parent = self
            def do_method1(self,arg1):
                return arg1 + msg2