public virtual void TestNext() { IQueue4 queue = new BlockingQueue(); string[] data = new string[] { "a", "b", "c", "d" }; queue.Add(data[0]); Assert.AreSame(data[0], queue.Next()); queue.Add(data[1]); queue.Add(data[2]); Assert.AreSame(data[1], queue.Next()); Assert.AreSame(data[2], queue.Next()); }
/// <exception cref="System.Exception"></exception> public virtual void TestIsAliveInMultiThread() { IBlockingQueue4 barrier = new BlockingQueue(); client = (ClientObjectContainer)OpenNewSession(); client.MessageListener(new _IMessageListener_23(this, barrier)); Thread workThread = new Thread(new _IRunnable_38(), "Quering"); workThread.SetDaemon(true); workThread.Start(); barrier.Next(); client.IsAlive(); }
public virtual void TestStop() { BlockingQueue queue = new BlockingQueue(); string[] data = new string[] { "a", "b", "c", "d" }; queue.Add(data[0]); Assert.AreSame(data[0], queue.Next()); BlockingQueueTestCase.StopThread notifyThread = new BlockingQueueTestCase.StopThread (queue); notifyThread.Start(); Assert.Expect(typeof(BlockingQueueStoppedException), new _ICodeBlock_110(queue)); }
public virtual void TestBlocking() { IQueue4 queue = new BlockingQueue(); string[] data = new string[] { "a", "b", "c", "d" }; queue.Add(data[0]); Assert.AreSame(data[0], queue.Next()); BlockingQueueTestCase.NotifyThread notifyThread = new BlockingQueueTestCase.NotifyThread (queue, data[1]); notifyThread.Start(); long start = Runtime.CurrentTimeMillis(); Assert.AreSame(data[1], queue.Next()); long end = Runtime.CurrentTimeMillis(); Assert.IsGreater(500, end - start); }