Esempio n. 1
0
    def test_SplitterDelLinkBoth(self):
        """Sending an delSink message to splitter unlinks in the extra outbox and signal"""
        Axon.Scheduler.scheduler.run = Axon.Scheduler.scheduler()
        split = Splitter().activate()

        target1 = Axon.Component.component().activate()
        target2 = Axon.Component.component().activate()

        target1.link( (split,"outbox"), (target1, "inbox") )
        target1.link( (split,"signal"), (target1, "control") )

        addmsg = addsink(target2, "inbox", "control")
        split._deliver(addmsg, "configuration")

        execute = Axon.Scheduler.scheduler.run.main()

        for i in xrange(1,10):
            execute.next()

        for i in xrange(1,10):
            if i == 5:
                delmsg = removesink(target2, "inbox", "control")
                split._deliver(delmsg, "configuration")

            split._deliver(i, "inbox")
            split._deliver(10+i, "control")

            for j in xrange(1,10):
                execute.next()

        for i in xrange(1,40):
            execute.next()

        # verify that the data has made it to the targets
        for i in xrange(1,5):
            self.assert_(target1.dataReady("inbox"))
            self.assert_(target1.dataReady("control"))
            self.assert_(i == target1.recv("inbox"))
            self.assert_(10+i == target1.recv("control"))

            self.assert_(target2.dataReady("inbox"))
            self.assert_(target2.dataReady("control"))
            self.assert_(i == target2.recv("inbox"))
            self.assert_(10+i == target2.recv("control"))

        for i in xrange(5,10):
            self.assert_(target1.dataReady("inbox"))
            self.assert_(target1.dataReady("control"))
            self.assert_(i == target1.recv("inbox"))
            self.assert_(10+i == target1.recv("control"))

            self.assert_(not target2.dataReady("inbox"))
            self.assert_(not target2.dataReady("control"))

        # verify there is nothing left
        self.assert_(not target1.dataReady("inbox"))
        self.assert_(not target1.dataReady("control"))

        self.assert_(not target2.dataReady("inbox"))
        self.assert_(not target2.dataReady("control"))
Esempio n. 2
0
   def test_removeOutboxes(self):
      """mainBody - addsink|removesink->configuration inbox - Tests addition and
      removal of sinks.  Adds a array of sinks, removes the odd items and then
      checks that messages are delivered to the even sinks and not the odd ones."""
      boxes = 10
      boxlist = {}

      for x in xrange(boxes): 
            C = TestComponent().activate()
            boxlist[x] = C
            self.W.send(addsink(C,"test"), "outbox")

      self.runCycles()

      for x in xrange(1,boxes,2):
            C = boxlist[x]
            self.W.send(removesink(C,"test"), "outbox")

      self.runCycles()

      for i in xrange(20):
         self.S._deliver(i, "inbox")
         self.runCycles()

         for j in xrange(0,boxes,2):
            self.failUnless(boxlist[j].dataReady("test"))
            self.failUnless(boxlist[j].recv("test") == i)   
         for j in xrange(1,boxes,2):
            self.failIf(boxlist[j].dataReady("test"))
Esempio n. 3
0
    def test_SplitterDelLinkBoth(self):
        """Sending an delSink message to splitter unlinks in the extra outbox and signal"""
        Axon.Scheduler.scheduler.run = Axon.Scheduler.scheduler()
        split = Splitter().activate()

        target1 = Axon.Component.component().activate()
        target2 = Axon.Component.component().activate()

        target1.link((split, "outbox"), (target1, "inbox"))
        target1.link((split, "signal"), (target1, "control"))

        addmsg = addsink(target2, "inbox", "control")
        split._deliver(addmsg, "configuration")

        execute = Axon.Scheduler.scheduler.run.main()

        for i in xrange(1, 10):
            execute.next()

        for i in xrange(1, 10):
            if i == 5:
                delmsg = removesink(target2, "inbox", "control")
                split._deliver(delmsg, "configuration")

            split._deliver(i, "inbox")
            split._deliver(10 + i, "control")

            for j in xrange(1, 10):
                execute.next()

        for i in xrange(1, 40):
            execute.next()

        # verify that the data has made it to the targets
        for i in xrange(1, 5):
            self.assert_(target1.dataReady("inbox"))
            self.assert_(target1.dataReady("control"))
            self.assert_(i == target1.recv("inbox"))
            self.assert_(10 + i == target1.recv("control"))

            self.assert_(target2.dataReady("inbox"))
            self.assert_(target2.dataReady("control"))
            self.assert_(i == target2.recv("inbox"))
            self.assert_(10 + i == target2.recv("control"))

        for i in xrange(5, 10):
            self.assert_(target1.dataReady("inbox"))
            self.assert_(target1.dataReady("control"))
            self.assert_(i == target1.recv("inbox"))
            self.assert_(10 + i == target1.recv("control"))

            self.assert_(not target2.dataReady("inbox"))
            self.assert_(not target2.dataReady("control"))

        # verify there is nothing left
        self.assert_(not target1.dataReady("inbox"))
        self.assert_(not target1.dataReady("control"))

        self.assert_(not target2.dataReady("inbox"))
        self.assert_(not target2.dataReady("control"))
Esempio n. 4
0
    def test_removeOutboxes(self):
        """mainBody - addsink|removesink->configuration inbox - Tests addition and
      removal of sinks.  Adds a array of sinks, removes the odd items and then
      checks that messages are delivered to the even sinks and not the odd ones."""
        boxes = 10
        boxlist = {}

        for x in xrange(boxes):
            C = TestComponent().activate()
            boxlist[x] = C
            self.W.send(addsink(C, "test"), "outbox")

        self.runCycles()

        for x in xrange(1, boxes, 2):
            C = boxlist[x]
            self.W.send(removesink(C, "test"), "outbox")

        self.runCycles()

        for i in xrange(20):
            self.S._deliver(i, "inbox")
            self.runCycles()

            for j in xrange(0, boxes, 2):
                self.failUnless(boxlist[j].dataReady("test"))
                self.failUnless(boxlist[j].recv("test") == i)
            for j in xrange(1, boxes, 2):
                self.failIf(boxlist[j].dataReady("test"))
Esempio n. 5
0
 def test_cleanup(self):
    """mainBody - addsink|removesink->configuration - Checks that there are no
    object leakages by adding and then removing a sink and checking the
    garbage collecter for its count of AxonObjects and lists."""
    self.controller.send(addsink(self.dst))
    before = 0
    for x in gc.get_objects():
       if isinstance(x, AxonObject) or isinstance(x,list):
          before = before + 1
    self.controller.send(addsink(self.dst))
    self.controller.send(removesink(self.dst))
    after = 0
    for x in gc.get_objects():
       if isinstance(x, AxonObject) or isinstance(x,list):
          after = after + 1
    self.failUnless(before == after)
Esempio n. 6
0
 def test_cleanup(self):
     """mainBody - addsink|removesink->configuration - Checks that there are no
   object leakages by adding and then removing a sink and checking the
   garbage collecter for its count of AxonObjects and lists."""
     self.controller.send(addsink(self.dst))
     before = 0
     for x in gc.get_objects():
         if isinstance(x, AxonObject) or isinstance(x, list):
             before = before + 1
     self.controller.send(addsink(self.dst))
     self.controller.send(removesink(self.dst))
     after = 0
     for x in gc.get_objects():
         if isinstance(x, AxonObject) or isinstance(x, list):
             after = after + 1
     self.failUnless(before == after)
Esempio n. 7
0
   def test_multipleboxessinglecomponent(self):
      """mainBody - addsink|removesink->configuration - Checks that multiple sink
      inboxes on a single component can be added and removed independently."""

      self.W.send(addsink(self.D2,"test"), "outbox")
      self.runCycles()
      self.S._deliver("ba", "inbox")
      self.runCycles()

      self.failUnless(self.D2.dataReady("test"))
      self.failIf(self.D2.dataReady("inbox"))
      self.failIf(self.D2.dataReady("control"))
      self.failUnless(self.D2.recv("test") == "ba")

      self.W.send(addsink(self.D2), "outbox")
      self.runCycles()
      self.S._deliver("da", "inbox")
      self.runCycles()

      self.failUnless(self.D2.dataReady("test"))
      self.failUnless(self.D2.dataReady("inbox"))         #### FAILING : Should not(?)
      self.failIf(self.D2.dataReady("control"))
      self.failUnless(self.D2.recv("test") == "da")
      self.failUnless(self.D2.recv("inbox") == "da")      #### FAILING : Should not(?)

      self.W.send(addsink(self.D2, "control"), "outbox")
      self.runCycles()
      self.S._deliver("bing", "inbox")
      self.runCycles()

      self.failUnless(self.D2.dataReady("test"))
      self.failUnless(self.D2.dataReady("inbox"))         #### FAILING : Should not(?)
      self.failUnless(self.D2.dataReady("control"))       #### FAILING : Should not(?)
      self.failUnless(self.D2.recv("test") == "bing")
      self.failUnless(self.D2.recv("inbox") == "bing")    #### FAILING : Should not(?)
      self.failUnless(self.D2.recv("control") == "bing")  #### FAILING : Should not(?)

      self.W.send(removesink(self.D2, "inbox"), "outbox")
      self.runCycles()
      self.S._deliver("a", "inbox")
      self.runCycles()
  
      self.failUnless(self.D2.dataReady("test"))
      self.failIf(self.D2.dataReady("inbox"))
      self.failUnless(self.D2.dataReady("control"))   #### FAILING : Should not(?)
      self.failUnless(self.D2.recv("test") == 'a')
      self.failUnless(self.D2.recv("control") == 'a') #### FAILING : Should not(?)

      self.W.send(removesink(self.D2, "control"), "outbox")
      self.runCycles()
      self.S._deliver("b", "inbox")
      self.runCycles()

      self.failUnless(self.D2.dataReady("test"))
      self.failIf(self.D2.dataReady("inbox"))
      self.failIf(self.D2.dataReady("control"))
      self.failUnless(self.D2.recv("test") == 'b')

      self.W.send(removesink(self.D2, "test"), "outbox")
      self.runCycles()
      self.S._deliver("c", "inbox")
      self.runCycles()

      self.failIf(self.D2.dataReady("test"))          #### FAILING : Should not
      self.failIf(self.D2.dataReady("inbox"))
      self.failIf(self.D2.dataReady("control"))
Esempio n. 8
0
    def test_multipleboxessinglecomponent(self):
        """mainBody - addsink|removesink->configuration - Checks that multiple sink
      inboxes on a single component can be added and removed independently."""

        self.W.send(addsink(self.D2, "test"), "outbox")
        self.runCycles()
        self.S._deliver("ba", "inbox")
        self.runCycles()

        self.failUnless(self.D2.dataReady("test"))
        self.failIf(self.D2.dataReady("inbox"))
        self.failIf(self.D2.dataReady("control"))
        self.failUnless(self.D2.recv("test") == "ba")

        self.W.send(addsink(self.D2), "outbox")
        self.runCycles()
        self.S._deliver("da", "inbox")
        self.runCycles()

        self.failUnless(self.D2.dataReady("test"))
        self.failUnless(
            self.D2.dataReady("inbox"))  #### FAILING : Should not(?)
        self.failIf(self.D2.dataReady("control"))
        self.failUnless(self.D2.recv("test") == "da")
        self.failUnless(
            self.D2.recv("inbox") == "da")  #### FAILING : Should not(?)

        self.W.send(addsink(self.D2, "control"), "outbox")
        self.runCycles()
        self.S._deliver("bing", "inbox")
        self.runCycles()

        self.failUnless(self.D2.dataReady("test"))
        self.failUnless(
            self.D2.dataReady("inbox"))  #### FAILING : Should not(?)
        self.failUnless(
            self.D2.dataReady("control"))  #### FAILING : Should not(?)
        self.failUnless(self.D2.recv("test") == "bing")
        self.failUnless(
            self.D2.recv("inbox") == "bing")  #### FAILING : Should not(?)
        self.failUnless(
            self.D2.recv("control") == "bing")  #### FAILING : Should not(?)

        self.W.send(removesink(self.D2, "inbox"), "outbox")
        self.runCycles()
        self.S._deliver("a", "inbox")
        self.runCycles()

        self.failUnless(self.D2.dataReady("test"))
        self.failIf(self.D2.dataReady("inbox"))
        self.failUnless(
            self.D2.dataReady("control"))  #### FAILING : Should not(?)
        self.failUnless(self.D2.recv("test") == 'a')
        self.failUnless(
            self.D2.recv("control") == 'a')  #### FAILING : Should not(?)

        self.W.send(removesink(self.D2, "control"), "outbox")
        self.runCycles()
        self.S._deliver("b", "inbox")
        self.runCycles()

        self.failUnless(self.D2.dataReady("test"))
        self.failIf(self.D2.dataReady("inbox"))
        self.failIf(self.D2.dataReady("control"))
        self.failUnless(self.D2.recv("test") == 'b')

        self.W.send(removesink(self.D2, "test"), "outbox")
        self.runCycles()
        self.S._deliver("c", "inbox")
        self.runCycles()

        self.failIf(self.D2.dataReady("test"))  #### FAILING : Should not
        self.failIf(self.D2.dataReady("inbox"))
        self.failIf(self.D2.dataReady("control"))