Esempio n. 1
0
    def setupBrokers(self):

        self.targetBroker = broker.Broker(TubRef("targetBroker"))
        self.callingBroker = broker.Broker(TubRef("callingBroker"))

        t1 = Loopback()
        t1.peer = self.callingBroker
        t1.protocol = self.targetBroker
        self.targetBroker.transport = t1
        self.loopbacks.append(t1)

        t2 = Loopback()
        t2.peer = self.targetBroker
        t2.protocol = self.callingBroker
        self.callingBroker.transport = t2
        self.loopbacks.append(t2)

        self.targetBroker.connectionMade()
        self.callingBroker.connectionMade()
Esempio n. 2
0
 def test_tubid_must_match(self):
     good_tubid = "fu2bixsrymp34hwrnukv7hzxc2vrhqqa"
     bad_tubid = "v5mwmba42j4hu5jxuvgciasvo4aqldkq"
     good_furl = "pb://" + good_tubid + "@127.0.0.1:1234/swissnum"
     bad_furl = "pb://" + bad_tubid + "@127.0.0.1:1234/swissnum"
     ri = "remote_interface_name"
     good_broker = broker.Broker(referenceable.TubRef(good_tubid))
     good_tracker = referenceable.RemoteReferenceTracker(
         good_broker, 0, good_furl, ri)
     del good_tracker
     self.failUnlessRaises(api.BananaError,
                           referenceable.RemoteReferenceTracker,
                           good_broker, 0, bad_furl, ri)
Esempio n. 3
0
    def test_remotereference(self):
        # we need to create a fake RemoteReference here
        tracker = RemoteReferenceTracker(broker.Broker(TubRef("fake-tubid")),
                                         0, None,
                                         common.RIHelper.__remote_name__)
        rr = RemoteReference(tracker)

        c1 = RemoteInterfaceConstraint(common.RIHelper)
        self.check_inbound(rr, c1)
        self.check_outbound(rr, c1)  # gift

        c2 = RemoteInterfaceConstraint(common.RIMyTarget)
        self.violates_inbound(rr, c2)
        self.violates_outbound(rr, c2)
Esempio n. 4
0
    def testCalled(self):
        """
        The object passed to L{Broker._notifyOnConnectionLost} is called when the
        L{Broker} is notify that its connection has been lost.
        """
        transport = NullTransport()
        protocol = broker.Broker(None)
        protocol.makeConnection(transport)
        disconnected = []
        protocol._notifyOnConnectionLost(lambda: disconnected.append(1))
        protocol._notifyOnConnectionLost(lambda: disconnected.append(2))
        protocol.connectionLost(failure.Failure(Exception("Connection lost")))

        d = flushEventualQueue()

        def flushed(ignored):
            self.assertEqual([1, 2], disconnected)

        d.addCallback(flushed)
        return d
Esempio n. 5
0
 def setUp(self):
     self.broker = broker.Broker(None)
     self.broker.transport = NullTransport()
     self.broker.connectionMade()