def __init__(self, conn_address, address): super(SimpleSndRecv, self).__init__() self.conn_address = conn_address self.address = address self.sender = None self.receiver = None self.conn = None self.message_received = False def on_start(self, event): self.conn = event.container.connect(self.conn_address) self.receiver = event.container.create_receiver( self.conn, self.address) self.sender = event.container.create_sender(self.conn, self.address) def on_sendable(self, event): msg = Message(body="Hello World") event.sender.send(msg) def on_message(self, event): if "Hello World" == event.message.body: self.message_received = True self.conn.close() def run(self): Container(self).run() if __name__ == '__main__': unittest.main(system_test.main_module())
self.assert_get("https://localhost:%s" % r.ports[1]) # requireSsl=True does not allow simple-ssl HTTP self.assertRaises(Exception, self.assert_get, "http://localhost:%s" % r.ports[1]) # authenticatePeer=True requires a client cert self.assertRaises((URLError, ssl.SSLError), self.assert_get, "https://localhost:%s" % r.ports[2]) # Provide client cert self.assert_get_cert("https://localhost:%d" % r.ports[2]) # Try a get on the HTTP listener we are going to delete self.assert_get_cert("https://localhost:%d" % r.ports[3]) if not self.skip_delete_http_listener_test: # Delete the listener with name 'delete-me' long_type = 'org.apache.qpid.dispatch.listener' mgmt = QdManager(self, address=address()) mgmt.delete(long_type, name=name) # Make sure that the listener got deleted. ret_val = retry(lambda: self.is_get_request_failing("https://localhost:%s/system_tests_http.txt" % r.ports[3], use_get_cert=True), timeout=10, delay=2) self.assertTrue(ret_val) # Make sure other ports are working normally after the above delete. self.assert_get_cert("https://localhost:%d" % r.ports[2]) if __name__ == '__main__': unittest.main(main_module())
class TestMain(unittest.TestCase): def test_main(self): def run_success(argv): self.assertEqual(sys.argv, argv) def run_raises(argv, _Exception): run_success(argv) raise _Exception("some") def run_raises_UsageError(argv): run_raises(argv, UsageError) def run_raises_Exception(argv): run_raises(argv, Exception) def run_raises_KeyboardInterrupt(argv): run_raises(argv, KeyboardInterrupt) self.assertEqual(0, main(run_success)) failed_runs = [ # run_raises_UsageError, ##uncomment this exposes bug run_raises_Exception, run_raises_KeyboardInterrupt, ] for run in failed_runs: self.assertEqual(1, main(run)) if __name__ == '__main__': unittest.main()