Esempio n. 1
0
 def test_build_protocol_different_delegates(self):
     """Test building AMQClient getting different delegates."""
     address = IPv4Address("TCP", "127.0.0.1", 5672)
     factory = AMQFactory()
     client1 = factory.buildProtocol(address)
     client2 = factory.buildProtocol(address)
     self.assertIsNot(client2.delegate, client1.delegate)
Esempio n. 2
0
 def setUp(self):
     super(NotificationSourceTest, self).setUp()
     self.useFixture(CaptureTwistedLogs())
     self.logger = Logger()
     self.clock = Clock()
     self.factory = AMQFactory(clock=self.clock, spec=AMQP0_8_SPEC_PATH)
     self.connector = FakeConnector(self.factory, logger=self.logger)
     self.source = NotificationSource(self.connector, clock=self.clock)
Esempio n. 3
0
 def test_build_protocol(self):
     """Test building AMQClient instances with default parameters."""
     address = IPv4Address("TCP", "127.0.0.1", 5672)
     factory = AMQFactory()
     client = factory.buildProtocol(address)
     self.assertIsInstance(client, AMQClient)
     self.assertEqual("/", client.vhost)
     self.assertEqual(DEFAULT_SPEC, client.spec.file)
     self.assertEqual(0, client.heartbeatInterval)
Esempio n. 4
0
 def test_build_protocol_custom_parameters(self):
     """Test building AMQClient instances with custom parameters."""
     address = IPv4Address("TCP", "127.0.0.1", 5672)
     spec = "../specs/rabbitmq/amqp0-8.stripped.rabbitmq.xml"
     clock = Clock()
     factory = AMQFactory(spec=spec, clock=clock)
     factory.set_vhost("foo")
     factory.set_heartbeat(1)
     client = factory.buildProtocol(address)
     self.assertEqual("foo", client.vhost)
     self.assertEqual(spec, client.spec.file)
     self.assertEqual(1, client.heartbeatInterval)
     self.assertEqual(1, len(clock.getDelayedCalls()))
Esempio n. 5
0
 def test_connect(self):
     """
     The endpoint returns a connected and authenticated client.
     """
     factory = AMQFactory(spec=self.spec)
     endpoint = AMQEndpoint(reactor,
                            self.host,
                            self.port,
                            username=self.user,
                            password=self.password,
                            vhost=self.vhost)
     client = yield endpoint.connect(factory)
     channel = yield client.channel(1)
     yield channel.channel_open()
     yield client.close()
    def setUp(self):
        super(NotificationSourceIntegrationTest, self).setUp()
        self.endpoint = AMQEndpoint(reactor,
                                    self.rabbit.config.hostname,
                                    self.rabbit.config.port,
                                    username="******",
                                    password="******",
                                    heartbeat=1)
        self.policy = backoffPolicy(initialDelay=0)
        self.factory = AMQFactory(spec=AMQP0_8_SPEC_PATH)
        self.service = ClientService(self.endpoint,
                                     self.factory,
                                     retryPolicy=self.policy)
        self.connector = NotificationConnector(self.service)
        self.source = NotificationSource(self.connector)

        self.client = yield self.endpoint.connect(self.factory)
        self.channel = yield self.client.channel(1)
        yield self.channel.channel_open()
        yield self.channel.queue_declare(queue="uuid")

        self.service.startService()
Esempio n. 7
0
 def setUp(self):
     super(NotificationConnectorTest, self).setUp()
     self.clock = Clock()
     self.factory = AMQFactory(spec=AMQP0_8_SPEC_PATH, clock=self.clock)
     self.service = FakeClientService(self.factory)
     self.connector = NotificationConnector(self.service, clock=self.clock)
Esempio n. 8
0
 def setUp(self):
     super(AMQEndpointTest, self).setUp()
     self.reactor = MemoryReactorClock()
     self.factory = AMQFactory(clock=Clock())