示例#1
0
class TestBlockingMethods(unittest.TestCase):
    def setUp(self):
        self.quiet=True
        self.random = Random()
        self._timers = []
        self.namespaces = []
        self.iface = PyRQIface(quiet=self.quiet, ref="test")
        self.dummyQueue = Queue()
        self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
        desiredPort = "19001"
        self.r = SubprocessQueueServer(
                                       desiredPort=desiredPort,
                                       handlerClazz=Linkage.create(MockHandler),
                                       quiet=self.quiet
#           includePydevd="/home/francis/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc"
           )
        PyRQIface.setGlobalPYRQ(self.r.details())
        self.r.start().waitUntilRunning()
        pass
    def tearDown(self):
        try:
            self.dummyQueue.close()
            del self.dummyQueue
        except Exception, _e:
            pass
        for namespace in self.namespaces:
            self.iface.setNamespace(namespace)
        try:    self.iface.close()
        except ClosedError, _e:
            pass
示例#2
0
class TestRRQReader(_BaseReader):
    def setUp(self):
        self.logger = self._getLogger()
        self.quiet = True
        self._queues = []
        self.random = Random()
        self.timerTerminate = 0
        self._timers = []
        self.namespaces = []
        self.iface = PyRQIface(quiet=self.quiet, ref="default", loggingModule=testLoggingModule)
        self.dummyQueue = Queue()
        self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
        desiredPort = "19001"
        self.r = SubprocessQueueServer(
                                       desiredPort=desiredPort,
                                       quiet=self.quiet,
                                       handlerClazz=Linkage.create(MockHandler),
#           includePydevd="/home/francis/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc"
           )
        PyRQIface.setGlobalPYRQ(self.r.details())
        self.r.start().waitUntilRunning()
        pass
    def tearDown(self):
        self.logger.info("------------ TEST END ------------")
        self.timerTerminate = 1
        time.sleep(2)
        try:
            self.dummyQueue.close()
            del self.dummyQueue
        except Exception, _e:
            pass
        for namespace in self.namespaces:
            self.iface.setNamespace(namespace)
        try:    self.iface.close()
        except ClosedError, _e:
            pass
示例#3
0
 def setUp(self):
     self.logger = self._getLogger()
     self.quiet=True
     self.random = Random()
     self.timerTerminate = 0
     self._timers = []
     self.namespaces = []
     self.dummyQueue = Queue()
     self.iface = PyRQIface(ref="test", quiet=self.quiet, loggingModule=testLoggingModule)
     self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
     desiredPort = "19001"
     self.r = SubprocessQueueServer(
                                    desiredPort=desiredPort,
                                    handlerClazz=Linkage.create(TimeoutMockHandler),
                                    quiet=self.quiet,
        )
     PyRQIface.setGlobalPYRQ(self.r.details())
示例#4
0
    def setUp(self):
        self.quiet=True
        self.random = Random()
        self._timers = []
        self.namespaces = []
        self.iface = PyRQIface(quiet=self.quiet, ref="test")
        self.dummyQueue = Queue()
        self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
        desiredPort = "19001"
        self.r = SubprocessQueueServer(
                                       desiredPort=desiredPort,
                                       handlerClazz=Linkage.create(MockHandler),
                                       quiet=self.quiet
#           includePydevd="/home/francis/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc"
           )
        PyRQIface.setGlobalPYRQ(self.r.details())
        self.r.start().waitUntilRunning()
        pass
示例#5
0
 def _createQueueServer(self):
     #    Create the QueueServer by using os.system or Subprocess.
     #    Create a reply-to Ping server:
     self.rqs= QueueServer(host=self.host,
                           port=self.portReplyTo,
                           target=self.target,
                           marshaller=self.m,
                           hunt=True,
                           quiet=self.quiet,
                           maxClients=self.maxClients,
                           recvChunkSize=self.recvChunkSize,
                           readTimeout=self.readTimeout,
                           )
     self.rqs.start().waitUntilRunning()
     #    Now create the subprocess server:
     desiredPort = 50001
     linkage = Linkage.create(Pinger)
     self.qs = SubprocessQueueServer(handlerClazz=Linkage.create(QueueServerHandler),
                                     desiredPort=desiredPort,
                                     linkage=linkage,
                                     quiet=self.quiet)
     self.details = self.qs.details()
示例#6
0
class TestWithTimeouts(_BaseReader):
    def setUp(self):
        self.logger = self._getLogger()
        self.quiet=True
        self.random = Random()
        self.timerTerminate = 0
        self._timers = []
        self.namespaces = []
        self.dummyQueue = Queue()
        self.iface = PyRQIface(ref="test", quiet=self.quiet, loggingModule=testLoggingModule)
        self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
        desiredPort = "19001"
        self.r = SubprocessQueueServer(
                                       desiredPort=desiredPort,
                                       handlerClazz=Linkage.create(TimeoutMockHandler),
                                       quiet=self.quiet,
           )
        PyRQIface.setGlobalPYRQ(self.r.details())
    def _createInterface(self):
        namespace = self.iface.create()
        self.iface = PyRQIface(namespace=namespace, ref="test", quiet=self.quiet, loggingModule=testLoggingModule)
        self.namespaces.append(namespace)
        return namespace
    def tearDown(self):
        self.timerTerminate = 1
        time.sleep(2)
        try:
            self.dummyQueue.close()
            del self.dummyQueue
        except Exception, _e:
            pass
        for namespace in self.namespaces:
            self.iface.setNamespace(namespace)
        try:    self.iface.close()
        except ClosedError, _e:
            pass
示例#7
0
class TestSameProcessExternalServer(TestServer):
    def tearDown(self):
        try:    self.rqs.close()
        except: pass
        super(TestSameProcessExternalServer, self).tearDown()
    def testDoubleClose(self):
        assert self.qs.close()
        assert self.qs.close()
    def _createQueueServer(self):
        #    Create the QueueServer by using os.system or Subprocess.
        #    Create a reply-to Ping server:
        self.rqs= QueueServer(host=self.host,
                              port=self.portReplyTo,
                              target=self.target,
                              marshaller=self.m,
                              hunt=True,
                              quiet=self.quiet,
                              maxClients=self.maxClients,
                              recvChunkSize=self.recvChunkSize,
                              readTimeout=self.readTimeout,
                              )
        self.rqs.start().waitUntilRunning()
        #    Now create the subprocess server:
        desiredPort = 50001
        linkage = Linkage.create(Pinger)
        self.qs = SubprocessQueueServer(handlerClazz=Linkage.create(QueueServerHandler),
                                        desiredPort=desiredPort,
                                        linkage=linkage,
                                        quiet=self.quiet)
        self.details = self.qs.details()
    def testSimpleSendPingRoundtrip(self):
        details = self.rqs.details()
        eResult = Ping(replyTo=details, data={"hello.world!":{123:456}}, quiet=self.quiet)
        self.qw.put(eResult)
        received = self.target.get(True, timeout=self.TIMEOUT)
        assert received==eResult