示例#1
0
        public void unreg6()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, 30);
            mb.UnregisterNotify(notify);
        }
示例#2
0
        public Mailbox TransportCall(Who recipient, Message msg)
        {
            if (msg.MessageId != null)
            {
                throw new Exception(" message has already been sent");
            }
            if (msg.InReplyTo != null)
            {
                throw new Exception(" message is marked as a reply");
            }

            long mid = idGen.Next();

            msg.MessageId = mid;
            Mailbox mb = new PlainMailbox(this, mid);

            Register(mb);
            try
            {
                transport.TransportMessage(recipient, msg);
            }
            catch (Exception e)
            {
                Unregister(mb);
                throw e;
            }
            return(mb);
        }
示例#3
0
        public void reg2()
        {
            // maxDelay < 0
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, -1);
        }
示例#4
0
        private void testConstruct(long messageId)
        {
            PlainMailbox mb = new PlainMailbox(this, messageId);

            Assert.AreEqual(this, mb.GetMailboxManager());
            Assert.AreEqual(messageId, mb.GetMessageId());
        }
示例#5
0
        public void reg1()
        {
            // notify == null
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(null, null, 0);
        }
示例#6
0
        public void reg5()
        {
            // this.notify != null
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, 0);
            mb.RegisterNotify(notify1x, null, 0);
        }
示例#7
0
        public void unreg5()
        {
            // notify != this.notify
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, 0);
            mb.UnregisterNotify(notify1x);
        }
示例#8
0
        public void read8()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkRead(mb, 1, false, null, null);
            checkMailbox(mb, true, false, false, false, 0);
        }
示例#9
0
 private void checkMailbox(PlainMailbox mb, bool empty, bool full,
                           bool closed, bool unreg, int size)
 {
     Assert.AreEqual(empty, mb.IsEmpty());
     Assert.AreEqual(full, mb.IsFull());
     Assert.AreEqual(closed, mb.IsClosed());
     Assert.AreEqual(unreg, unregistered);
     Assert.AreEqual(size, redelivered.Count);
 }
示例#10
0
        public void closeRead1()
        {
            // open mailbox and close it for reading while empty.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseRead(mb, true);
            checkMailbox(mb, true, false, true, true, 0);
        }
示例#11
0
        public void read5()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            Thread.Sleep(1000);

            checkRead(mb, false, null, null);
            checkMailbox(mb, true, false, true, true, 0);
        }
示例#12
0
        public void closeDelivery1()
        {
            // open mailbox and close it for delivery while empty.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, true, false, true, true, 0);
        }
示例#13
0
        public void full1()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkDeliver(mb, true, fred_who, foo_msg);
            checkMailbox(mb, false, true, false, false, 0);

            checkDeliver(mb, false, alice_who, bar_msg);
            checkMailbox(mb, false, true, false, false, 0);
        }
示例#14
0
        public void deliver1()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, true, false, true, true, 0);

            checkDeliver(mb, false, fred_who, bar_msg);
            checkMailbox(mb, true, false, true, true, 0);
        }
示例#15
0
        public void read4()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, true, false, true, true, 0);

            checkRead(mb, false, null, null);
            checkMailbox(mb, true, false, true, true, 0);
        }
示例#16
0
        private void checkRead(PlainMailbox mb, bool present, Who who, Message msg)
        {
            Element e = mb.Read();

            if (present)
            {
                checkElement(e, who, msg);
            }
            else
            {
                Assert.IsNull(e);
            }
        }
示例#17
0
        public void notify4()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            notify.checkMailboxStatus(false, null, null, false);

            Object state = new Object();

            mb.RegisterNotify(notify, state, 0);
            notify.checkMailboxStatus(false, null, null, false);

            mb.Message(alice_who, foo_msg);
            notify.checkMailboxStatus(true, mb, state, false);
        }
示例#18
0
        public void notify1()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            notify.checkMailboxStatus(false, null, null, false);

            Object state = new Object();

            mb.RegisterNotify(notify, state, 0);
            notify.checkMailboxStatus(false, null, null, false);

            checkCloseDelivery(mb, true);
            notify.checkMailboxStatus(true, mb, state, true);
        }
示例#19
0
        public void notify3()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            notify.checkMailboxStatus(false, null, null, false);

            Object state = new Object();

            mb.RegisterNotify(notify, state, 0);
            notify.checkMailboxStatus(false, null, null, false);

            Thread.Sleep(2000);
            notify.checkMailboxStatus(false, null, null, false);
        }
示例#20
0
        public void closeDelivery3()
        {
            // open mailbox and close it for delivery twice.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, true, false, true, true, 0);

            checkCloseDelivery(mb, false);
            checkMailbox(mb, true, false, true, true, 0);
        }
示例#21
0
        public void closeDelivery2()
        {
            // open mailbox and close it for delivery while not empty.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkDeliver(mb, true, alice_who, foo_msg);
            checkMailbox(mb, false, true, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, false, true, true, true, 0);
        }
示例#22
0
        public void closeRead2()
        {
            // open mailbox and close it for reading while not empty.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkDeliver(mb, true, alice_who, foo_msg);
            checkMailbox(mb, false, true, false, false, 0);

            checkCloseRead(mb, true);
            checkMailbox(mb, true, false, true, true, 1);
            checkRedelivered(0, alice_who, foo_msg);
        }
示例#23
0
        public void read3()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkDeliver(mb, true, alice_who, bar_msg);
            checkMailbox(mb, false, true, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, false, true, true, true, 0);

            checkRead(mb, true, alice_who, bar_msg);
            checkMailbox(mb, true, false, true, true, 0);
        }
示例#24
0
        public void reg3()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, 0);
        }
示例#25
0
 private void checkCloseDelivery(PlainMailbox mb, bool closed)
 {
     Assert.AreEqual(closed, mb.CloseDelivery());
 }
示例#26
0
 private void checkCloseRead(PlainMailbox mb, bool closed)
 {
     Assert.AreEqual(closed, mb.CloseRead());
 }
示例#27
0
        public void unreg1()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.UnregisterNotify(notify);
        }
示例#28
0
 private void checkDeliver(PlainMailbox mb, bool handled, Who who,
                           Message msg)
 {
     Assert.AreEqual(handled, mb.Message(who, msg));
 }