Ejemplo n.º 1
0
 def test_ping(self):
     """ test sending a ping"""
     eb = Eventbus(port=7001,options={"vertxbus_ping_interval":500},debug=self.debug)
     eb.wait(State.OPEN)
     time.sleep(1.2)
     eb.close()
     assert eb.pongCount==2
Ejemplo n.º 2
0
 def test_reply(self):
     """ test sending a message with a reply handler """
     eb = Eventbus(port=7001,debug=self.debug)
     handler=Handler(self.debug)
     body = {'msg': 'test reply' }
     eb.wait(State.OPEN)
     eb.send('echo',body,callback=handler.handle)
     # wait for the message to arrive
     time.sleep(RECEIVE_WAIT)
     eb.close()
     assert handler.result==body
Ejemplo n.º 3
0
 def test_send(self):
     """ test sending a message"""
     eb = Eventbus(port=7001,debug=self.debug)
     handler=Handler(self.debug)
     address="echoMe"
     eb.registerHandler(address, handler.handle)
     cmd=EchoCommand("time","send",address)
     eb.wait(State.OPEN)
     eb.send('echo',cmd)
     # wait for the message to arrive
     time.sleep(RECEIVE_WAIT)
     eb.close()
     assert 'received_nanotime' in handler.result
     assert 'iso_time' in handler.result
Ejemplo n.º 4
0
 def test_publish(self):
     """ test publishing a message to the echo server """
     eb = Eventbus(port=7001,debug=True)
     handler=Handler(self.debug)
     eb.registerHandler("echo", handler.handle)
     #jsonObject -body
     body1 = {'msg': 'testpublish 1'}
     eb.wait(State.OPEN)
     # publish without headers
     eb.publish('echo', body1)
     # wait for the message to arrive
     time.sleep(RECEIVE_WAIT)
     eb.close()
     assert handler.result == body1
Ejemplo n.º 5
0
 def test_publishWithMultipleHandlers(self):
     """ test publishing a message to be handle by multiple handlers"""
     eb = Eventbus(port=7001,debug=self.debug)
     handler1=Handler(self.debug)
     handler2=Handler(self.debug)
     address="echoMe"
     eb.registerHandler(address, handler1.handle)
     eb.registerHandler(address, handler2.handle)
     eb.wait(State.OPEN)
     eb.send('echo',EchoCommand("reset","send",address))
     cmd=EchoCommand("counter","publish",address)
     eb.send('echo',cmd)
     time.sleep(RECEIVE_WAIT)
     eb.close()
     assert 'counter' in handler1.result
     assert handler1.result['counter']==1
     assert 'counter' in handler2.result
     assert handler1.result['counter']==1
Ejemplo n.º 6
0
 def testWait(self):
     """
     test waiting for the eventbus to open and close
     """
     eb=Eventbus(port=7001,debug=True)
     eb.wait()
     eb.close()
     eb.wait(State.CLOSED)
     eb=Eventbus(port=7001,debug=True,connect=False)
     timedOut=False
     try:
         eb.wait(State.OPEN,timeOut=0.1)
     except Exception as e:
         print(e)
         timedOut=e is not None
     assert timedOut