示例#1
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)
示例#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"))
示例#3
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"))
示例#4
0
 def test_addSinkInboxes_passthrough(self):
     """mainBody - addsink->configurations - Adds a whole set of sinks and checks
   they all receive expected messages.  Complicated by setting the sink to
   passthrough and to be to an inbox."""
     boxes = 10
     boxlist = []
     for x in xrange(boxes):
         c = component()
         boxlist.append(c)
         self.links.append(
             linkage(source=c,
                     sourcebox="outbox",
                     sink=c,
                     sinkbox="control"))
         self.controller.send(addsink(c, "outbox", 2))
         self.deliverhelper()
         runrepeat(self.runner)
     for i in xrange(20):
         self.src.send(i)
         self.deliverhelper()
         runrepeat(self.runner)
         self.deliverhelper()
         self.deliverhelper()
         for comp in boxlist:
             self.failUnless(comp.dataReady("control"))
             self.failUnless(comp.recv("control") == i)
示例#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)
示例#6
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"))
示例#7
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"))
示例#8
0
   def test_simplepassthrough_defaultbox(self):
      """mainBody - This test sets up a sink and checks it receives sent messages using the default box."""

      self.W.send(addsink(self.D), "outbox")
      data = [ 1,2,3,4,5,6]
      for i in data:
          self.S._deliver(i, "inbox")

      try:
          self.waitEvent(10, self.D.dataReady, "inbox" )
      except Timeout, e:
          self.fail("Data hasn't arrived after "+str(e.t)+" cycles")
示例#9
0
    def test_simplepassthrough_defaultbox(self):
        """mainBody - This test sets up a sink and checks it receives sent messages using the default box."""

        self.W.send(addsink(self.D), "outbox")
        data = [1, 2, 3, 4, 5, 6]
        for i in data:
            self.S._deliver(i, "inbox")

        try:
            self.waitEvent(10, self.D.dataReady, "inbox")
        except Timeout, e:
            self.fail("Data hasn't arrived after " + str(e.t) + " cycles")
示例#10
0
   def test_simplepassthrough(self):
      """mainBody - addsink -> configuration - An addsink object is sent to the
      configuration box and it creates a new sink.  A new outbox is created and
      linked to the sink."""
      self.W.send(addsink(self.D2, "test"))
      
      data = [ 1,2,3,4,5,6]
      for i in data:
          self.S._deliver(i, "inbox")

      try:
          self.waitEvent(10, self.D2.dataReady, "test" )
      except Timeout, e:
          self.fail("Data hasn't arrived after "+str(e.t)+" cycles")
示例#11
0
    def test_simplepassthrough(self):
        """mainBody - addsink -> configuration - An addsink object is sent to the
      configuration box and it creates a new sink.  A new outbox is created and
      linked to the sink."""
        self.W.send(addsink(self.D2, "test"))

        data = [1, 2, 3, 4, 5, 6]
        for i in data:
            self.S._deliver(i, "inbox")

        try:
            self.waitEvent(10, self.D2.dataReady, "test")
        except Timeout, e:
            self.fail("Data hasn't arrived after " + str(e.t) + " cycles")
示例#12
0
 def test_addOutboxes(self):
     """mainBody - addsink->configurations - Adds a whole set of sinks and checks
   they all receive expected messages."""
     boxes = 10
     boxlist = []
     for x in xrange(boxes):
         c = component()
         boxlist.append(c)
         self.controller.send(addsink(c))
         self.deliverhelper()
         runrepeat(self.runner)
     for i in xrange(20):
         self.src.send(i)
         self.deliverhelper()
         runrepeat(self.runner)
         self.deliverhelper()
         for comp in boxlist:
             self.failUnless(comp.dataReady())
             self.failUnless(comp.recv() == i)
示例#13
0
 def test_addOutboxes(self):
    """mainBody - addsink->configurations - Adds a whole set of sinks and checks
    they all receive expected messages."""
    boxes = 10
    boxlist = []
    for x in xrange(boxes):
       c=component()
       boxlist.append(c)
       self.controller.send(addsink(c))
       self.deliverhelper()
       runrepeat(self.runner)
    for i in xrange(20):
       self.src.send(i)
       self.deliverhelper()
       runrepeat(self.runner)
       self.deliverhelper()
       for comp in boxlist:
          self.failUnless(comp.dataReady())
          self.failUnless(comp.recv() == i)
示例#14
0
    def test_SplitterAddLinkSignalOnly(self):
        """Sending an addSink message to splitter links in an extra 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, None, "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):
            split._deliver(i, "inbox")
            split._deliver(10+i, "control")
            for j in xrange(1,10):
                execute.next()

        # verify that the data has made it to the targets
        for i in xrange(1,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_(target2.dataReady("control"))
            self.assert_(10+i == target2.recv("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"))
示例#15
0
    def test_SplitterAddLinkSignalOnly(self):
        """Sending an addSink message to splitter links in an extra 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, None, "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):
            split._deliver(i, "inbox")
            split._deliver(10 + i, "control")
            for j in xrange(1, 10):
                execute.next()

        # verify that the data has made it to the targets
        for i in xrange(1, 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_(target2.dataReady("control"))
            self.assert_(10 + i == target2.recv("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"))
示例#16
0
 def test_addSinkInboxes_passthrough(self):
    """mainBody - addsink->configurations - Adds a whole set of sinks and checks
    they all receive expected messages.  Complicated by setting the sink to
    passthrough and to be to an inbox."""
    boxes = 10
    boxlist = []
    for x in xrange(boxes):
       c=component()
       boxlist.append(c)
       self.links.append(linkage(source=c, sourcebox="outbox", sink=c, sinkbox="control"))
       self.controller.send(addsink(c,"outbox",2))
       self.deliverhelper()
       runrepeat(self.runner)
    for i in xrange(20):
       self.src.send(i)
       self.deliverhelper()
       runrepeat(self.runner)
       self.deliverhelper()
       self.deliverhelper()
       for comp in boxlist:
          self.failUnless(comp.dataReady("control"))
          self.failUnless(comp.recv("control") == i)
示例#17
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"))
示例#18
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"))