Example #1
0
    def testRoundtrip(self):

        goodScope = Scope("/good")

        inconnector = self._getInPushConnector(goodScope)
        outconnector = self._getOutConnector(goodScope)

        receiver = SettingReceiver(goodScope)
        inconnector.setObserverAction(receiver)

        # first an event that we do not want
        event = Event(EventId(uuid.uuid4(), 0))
        event.scope = Scope("/notGood")
        event.data = "dummy data"
        event.type = str
        event.metaData.senderId = uuid.uuid4()
        outconnector.handle(event)

        # and then a desired event
        event.scope = goodScope
        outconnector.handle(event)

        with receiver.resultCondition:
            while receiver.resultEvent is None:
                receiver.resultCondition.wait(10)
            self.assertTrue(receiver.resultEvent)
            # ignore meta data here
            event.setMetaData(None)
            receiver.resultEvent.setMetaData(None)
            self.assertEqual(receiver.resultEvent, event)

        inconnector.deactivate()
        outconnector.deactivate()
Example #2
0
    def testPullRoundtrip(self):

        goodScope = Scope("/good")

        try:
            inconnector = self._getInPullConnector(goodScope)
        except NotImplementedError:
            return
        outconnector = self._getOutConnector(goodScope)

        # first an event that we do not want
        event = Event(EventId(uuid.uuid4(), 0))
        event.scope = Scope("/notGood")
        event.data = "dummy data"
        event.type = str
        event.metaData.senderId = uuid.uuid4()
        outconnector.handle(event)

        # and then a desired event
        event.scope = goodScope
        outconnector.handle(event)

        received = inconnector.raiseEvent(True)
        # ignore meta data here
        event.setMetaData(None)
        received.setMetaData(None)
        self.assertEqual(received, event)

        inconnector.deactivate()
        outconnector.deactivate()
Example #3
0
    def testSequencing(self):
        goodScope = Scope("/good")
        inConnector = getConnector(goodScope, clazz=rsbspread.InPushConnector)
        outConnector = getConnector(goodScope, clazz=rsbspread.OutConnector)

        try:
            receiver = SettingReceiver(goodScope)
            inConnector.setObserverAction(receiver)

            # first an event that we do not want
            event = Event(EventId(uuid.uuid4(), 0))
            event.scope = Scope("/notGood")
            event.data = "".join(
                random.choice(string.ascii_uppercase + string.ascii_lowercase +
                              string.digits) for i in range(300502))
            event.type = str
            event.metaData.senderId = uuid.uuid4()
            outConnector.handle(event)

            # and then a desired event
            event.scope = goodScope
            outConnector.handle(event)

            with receiver.resultCondition:
                receiver.resultCondition.wait(10)
                if receiver.resultEvent is None:
                    self.fail("Did not receive an event")
                # self.assertEqual(receiver.resultEvent, event)
        finally:
            inConnector.deactivate()
            outConnector.deactivate()
Example #4
0
    def testSendTimeAdaption(self):
        scope = Scope("/notGood")
        connector = self._getOutConnector(scope)

        event = Event(EventId(uuid.uuid4(), 0))
        event.scope = scope
        event.data = "".join(
            random.choice(string.ascii_uppercase + string.ascii_lowercase +
                          string.digits) for i in range(300502))
        event.type = str
        event.metaData.senderId = uuid.uuid4()

        before = time.time()
        connector.handle(event)
        after = time.time()

        self.assertTrue(event.getMetaData().getSendTime() >= before)
        self.assertTrue(event.getMetaData().getSendTime() <= after)

        connector.deactivate()