示例#1
0
        public void TestViewPushWithRefPoint()
        {
            long startTime = 50000;

            _schedulingServiceStub.Time = startTime;

            _myView    = new TimeBatchView(new TimeBatchViewFactory(), SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_schedulingServiceStub), new ExprTimePeriodEvalDeltaConstMsec(TEST_INTERVAL_MSEC), 1505L, false, false, null);
            _childView = new SupportBeanClassView(typeof(SupportMarketDataBean));
            _myView.AddView(_childView);

            IDictionary <String, EventBean> events = EventFactoryHelper.MakeEventMap(
                new String[] { "A1", "A2", "A3" });

            // Send new events to the view - should have scheduled a callback for X msec after
            _myView.Update(new EventBean[] { events.Get("A1"), events.Get("A2"), events.Get("A3") }, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(1505L) != null);
            _schedulingServiceStub.Added.Clear();
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("A1"), events.Get("A2"), events.Get("A3") }, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);  // Data got batched, no data release till later

            // Pretend we have a callback, check data, check scheduled new callback
            _schedulingServiceStub.Time = (startTime + 1505);
            _myView.SendBatch();
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("A1"), events.Get("A2"), events.Get("A3") });
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(TEST_INTERVAL_MSEC) != null);
        }
示例#2
0
        public void TestRemove()
        {
            IList <IEnumerable <EventBean> > enumerableList = new List <IEnumerable <EventBean> >();

            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "a", "b", "c" }));
            var enumerator = new IterablesListIterator(enumerableList);

            try {
                enumerator.Reset();
                Assert.IsTrue(false);
            }
            catch (NotSupportedException ex) {
                // Expected
            }
        }
示例#3
0
 public void SetUp()
 {
     _events = EventFactoryHelper.MakeEventMap(new String[]
     {
         "a", "b", "c", "d", "f", "g"
     }
                                               );
     _comparator = new MultiKeyCastingComparator(
         new MultiKeyComparator(new bool[]
     {
         false
     }
                                ));
     _testMap = new SortedDictionary <Object, Object>(_comparator);
 }
示例#4
0
        public void TestRemove()
        {
            IEnumerable <EventBean>[][] iterables = new IEnumerable <EventBean> [1][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "a", "b", "c" }));
            IterablesArrayIterator iterator = new IterablesArrayIterator(iterables);

            try
            {
                iterator.Remove();
                Assert.IsTrue(false);
            }
            catch (UnsupportedOperationException ex)
            {
                // Expected
            }
        }
示例#5
0
        public void TestViewPush()
        {
            // Set up a feed for the view under test - it will have a depth of 3 trades
            SupportStreamImpl stream = new SupportStreamImpl(typeof(SupportBean_A), 3);

            stream.AddView(_myView);

            IDictionary <String, EventBean> events = EventFactoryHelper.MakeEventMap(
                new String[] { "a0", "a1", "b0", "c0", "c1", "c2", "d0", "e0" });

            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());

            // View should keep the last element for iteration, should report new data as it arrives
            stream.Insert(new EventBean[] { events.Get("a0"), events.Get("a1") });
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("a0") });
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("a0"), events.Get("a1") });
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("a1") }, _myView.GetEnumerator());

            stream.Insert(new EventBean[] { events.Get("b0") });
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("a1") });
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("b0") });
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("b0") }, _myView.GetEnumerator());

            stream.Insert(new EventBean[] { events.Get("c0"), events.Get("c1"), events.Get("c2") });
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("b0"), events.Get("c0"), events.Get("c1") });
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("c0"), events.Get("c1"), events.Get("c2") });
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("c2") }, _myView.GetEnumerator());

            stream.Insert(new EventBean[] { events.Get("d0") });
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("c2") });
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("d0") });
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("d0") }, _myView.GetEnumerator());

            stream.Insert(new EventBean[] { events.Get("e0") });
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("d0") });
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("e0") });
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("e0") }, _myView.GetEnumerator());
        }
示例#6
0
 private static EventBean[] MakeArray(IDictionary <String, EventBean> events, String[] ids)
 {
     return(EventFactoryHelper.MakeArray(events, ids));
 }
示例#7
0
 public void SetUp()
 {
     _events = EventFactoryHelper.MakeEventMap(new[] { "a", "b", "c", "d", "e", "f", "g" });
 }
示例#8
0
        public void TestIterator()
        {
            IEnumerable <EventBean>[][] iterables = new Iterable[1][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "a", "b", "c" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new string[] { "a", "b", "c" }));

            iterables    = new Iterable[3][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "a" }));
            iterables[1] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "b" }));
            iterables[2] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "c" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new string[] { "a", "b", "c" }));

            iterables    = new Iterable[2][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "a", "b" }));
            iterables[1] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "c" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new string[] { "a", "b", "c" }));

            iterables    = new Iterable[5][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[1] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "a", "b" }));
            iterables[2] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[3] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "c" }));
            iterables[4] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new string[] { "a", "b", "c" }));

            iterables    = new Iterable[1][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            CheckResults(iterables, null);

            iterables    = new Iterable[3][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[1] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[2] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            CheckResults(iterables, null);

            iterables    = new Iterable[4][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[1] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[2] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[3] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "d" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new string[] { "d" }));

            iterables    = new Iterable[4][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "d" }));
            iterables[1] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[2] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[3] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new string[] { "d" }));

            iterables    = new Iterable[8][];
            iterables[0] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "a", "b", "c" }));
            iterables[1] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "d" }));
            iterables[2] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[3] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "e", "f" }));
            iterables[4] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "g" }));
            iterables[5] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables[6] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "h", "i" }));
            iterables[7] = MakeArray(EventFactoryHelper.MakeList(events, new string[] { "z" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "z" }));

            iterables = new Iterable[0][];
            CheckResults(iterables, null);
        }
示例#9
0
 public void SetUp()
 {
     events = EventFactoryHelper.MakeEventMap(new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "z" });
 }
示例#10
0
        public void TestIterator()
        {
            ICollection <IEnumerable <EventBean> > iterables = new LinkedList <IEnumerable <EventBean> >();

            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "a", "b", "c" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new[] { "a", "b", "c" }));

            iterables = new LinkedList <IEnumerable <EventBean> >();
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "a" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "b" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "c" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new[] { "a", "b", "c" }));

            iterables = new LinkedList <IEnumerable <EventBean> >();
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "a", "b" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "c" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new[] { "a", "b", "c" }));

            iterables = new LinkedList <IEnumerable <EventBean> >();
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "a", "b" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "c" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new[] { "a", "b", "c" }));

            iterables = new LinkedList <IEnumerable <EventBean> >();
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            CheckResults(iterables, null);

            iterables = new LinkedList <IEnumerable <EventBean> >();
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            CheckResults(iterables, null);

            iterables = new LinkedList <IEnumerable <EventBean> >();
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "d" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new[] { "d" }));

            iterables = new LinkedList <IEnumerable <EventBean> >();
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "d" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new[] { "d" }));

            iterables = new LinkedList <IEnumerable <EventBean> >();
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "a", "b", "c" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "d" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "e", "f" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "g" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new string[] { }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "h", "i" }));
            iterables.Add(EventFactoryHelper.MakeList(events, new[] { "z" }));
            CheckResults(iterables, EventFactoryHelper.MakeArray(events, new[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "z" }));

            iterables = new LinkedList <IEnumerable <EventBean> >();
            CheckResults(iterables, null);
        }
示例#11
0
 public EventBean[] MakeEvents(String[] ids)
 {
     return(EventFactoryHelper.MakeEvents(ids));
 }
示例#12
0
        public void TestViewPushNoRefPoint()
        {
            long startTime = 1000000;

            _schedulingServiceStub.Time = startTime;

            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);

            IDictionary <String, EventBean> events = EventFactoryHelper.MakeEventMap(
                new String[] { "a1", "b1", "b2", "c1", "d1" });

            // Send new events to the view - should have scheduled a callback for X msec after
            _myView.Update(new EventBean[] { events.Get("a1") }, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(TEST_INTERVAL_MSEC) != null);
            _schedulingServiceStub.Added.Clear();
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("a1") }, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);  // Data got batched, no data release till later

            _schedulingServiceStub.Time = (startTime + 5000);
            _myView.Update(new EventBean[] { events.Get("b1"), events.Get("b2") }, null);
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("a1"), events.Get("b1"), events.Get("b2") }, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);

            // Pretend we have a callback, check data, check scheduled new callback
            _schedulingServiceStub.Time = (startTime + TEST_INTERVAL_MSEC);
            _myView.SendBatch();
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("a1"), events.Get("b1"), events.Get("b2") });
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(TEST_INTERVAL_MSEC) != null);
            _schedulingServiceStub.Added.Clear();

            // Pretend callback received again, should schedule a callback since the last interval showed data
            _schedulingServiceStub.Time = (startTime + TEST_INTERVAL_MSEC * 2);
            _myView.SendBatch();
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("a1"), events.Get("b1"), events.Get("b2") });  // Old data is published
            SupportViewDataChecker.CheckNewData(_childView, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(TEST_INTERVAL_MSEC) != null);
            _schedulingServiceStub.Added.Clear();

            // Pretend callback received again, not schedule a callback since the this and last interval showed no data
            _schedulingServiceStub.Time = (startTime + TEST_INTERVAL_MSEC * 3);
            _myView.SendBatch();
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);

            // Send new event to the view - pretend we are 500 msec into the interval
            _schedulingServiceStub.Time = (startTime + TEST_INTERVAL_MSEC * 3 + 500);
            _myView.Update(new EventBean[] { events.Get("c1") }, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(TEST_INTERVAL_MSEC - 500) != null);
            _schedulingServiceStub.Added.Clear();
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("c1") }, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);  // Data got batched, no data release till later

            // Pretend callback received again
            _schedulingServiceStub.Time = (startTime + TEST_INTERVAL_MSEC * 4);
            _myView.SendBatch();
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("c1") });
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(TEST_INTERVAL_MSEC) != null);
            _schedulingServiceStub.Added.Clear();

            // Send new event to the view
            _schedulingServiceStub.Time = (startTime + TEST_INTERVAL_MSEC * 4 + 500);
            _myView.Update(new EventBean[] { events.Get("d1") }, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("d1") }, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);

            // Pretend callback again
            _schedulingServiceStub.Time = (startTime + TEST_INTERVAL_MSEC * 5);
            _myView.SendBatch();
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("c1") });
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("d1") });
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(TEST_INTERVAL_MSEC) != null);
            _schedulingServiceStub.Added.Clear();

            // Pretend callback again
            _schedulingServiceStub.Time = (startTime + TEST_INTERVAL_MSEC * 6);
            _myView.SendBatch();
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("d1") });
            SupportViewDataChecker.CheckNewData(_childView, null);

            // Pretend callback again
            _schedulingServiceStub.Time = (startTime + TEST_INTERVAL_MSEC * 7);
            _myView.SendBatch();
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);
        }
示例#13
0
        public void TestIterator()
        {
            IList <IEnumerable <EventBean> > enumerableList = new List <IEnumerable <EventBean> >();

            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "a", "b", "c" }));
            CheckResults(enumerableList, EventFactoryHelper.MakeArray(_events, new[] { "a", "b", "c" }));

            enumerableList = new List <IEnumerable <EventBean> >();
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "a" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "b" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "c" }));
            CheckResults(enumerableList, EventFactoryHelper.MakeArray(_events, new[] { "a", "b", "c" }));

            enumerableList = new List <IEnumerable <EventBean> >();
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "a", "b" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "c" }));
            CheckResults(enumerableList, EventFactoryHelper.MakeArray(_events, new[] { "a", "b", "c" }));

            enumerableList = new List <IEnumerable <EventBean> >();
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "a", "b" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "c" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            CheckResults(enumerableList, EventFactoryHelper.MakeArray(_events, new[] { "a", "b", "c" }));

            enumerableList = new List <IEnumerable <EventBean> >();
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            CheckResults(enumerableList, null);

            enumerableList = new List <IEnumerable <EventBean> >();
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            CheckResults(enumerableList, null);

            enumerableList = new List <IEnumerable <EventBean> >();
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "d" }));
            CheckResults(enumerableList, EventFactoryHelper.MakeArray(_events, new[] { "d" }));

            enumerableList = new List <IEnumerable <EventBean> >();
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "d" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            CheckResults(enumerableList, EventFactoryHelper.MakeArray(_events, new[] { "d" }));

            enumerableList = new List <IEnumerable <EventBean> >();
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "a", "b", "c" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "d" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "e", "f" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "g" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new String[] {}));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "h", "i" }));
            enumerableList.Add(EventFactoryHelper.MakeList(_events, new[] { "z" }));
            CheckResults(enumerableList,
                         EventFactoryHelper.MakeArray(_events, new[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "z" }));

            enumerableList = new List <IEnumerable <EventBean> >();
            CheckResults(enumerableList, null);
        }
示例#14
0
 public void SetUp()
 {
     events     = EventFactoryHelper.MakeEventMap(new[] { "a", "b", "c", "d", "f", "g" }, supportEventTypeFactory);
     comparator = new ComparatorHashableMultiKeyCasting(new ComparatorHashableMultiKey(new[] { false }));
     testMap    = new SortedDictionary <object, object>(comparator);
 }
示例#15
0
        public void TestViewPush()
        {
            // Set up a feed for the view under test - it will have a depth of 3 trades
            SupportStreamImpl stream = new SupportStreamImpl(typeof(SupportBean_A), 3);

            stream.AddView(_myView);

            IDictionary <String, EventBean> events = EventFactoryHelper.MakeEventMap(
                new String[] { "a0", "b0", "b1", "c0", "c1", "d0", "e0", "e1", "e2", "f0", "f1",
                               "g0", "g1", "g2", "g3", "g4",
                               "h0", "h1", "h2", "h3", "h4", "h5", "h6",
                               "i0" });

            stream.Insert(MakeArray(events, new String[] { "a0" }));
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(MakeArray(events, new String[] { "a0" }), _myView.GetEnumerator());

            stream.Insert(MakeArray(events, new String[] { "b0", "b1" }));
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(MakeArray(events, new String[] { "a0", "b0", "b1" }), _myView.GetEnumerator());

            stream.Insert(MakeArray(events, new String[] { "c0", "c1" }));
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, MakeArray(events, new String[] { "a0", "b0", "b1", "c0", "c1" }));
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());

            // Send further events, expect to get events back that fall out of the window, i.e. prior batch
            stream.Insert(MakeArray(events, new String[] { "d0" }));
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(MakeArray(events, new String[] { "d0" }), _myView.GetEnumerator());

            stream.Insert(MakeArray(events, new String[] { "e0", "e1", "e2" }));
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(MakeArray(events, new String[] { "d0", "e0", "e1", "e2" }), _myView.GetEnumerator());

            stream.Insert(MakeArray(events, new String[] { "f0", "f1" }));
            SupportViewDataChecker.CheckOldData(_childView, MakeArray(events, new String[] { "a0", "b0", "b1", "c0", "c1" }));
            SupportViewDataChecker.CheckNewData(_childView, MakeArray(events, new String[] { "d0", "e0", "e1", "e2", "f0", "f1" }));
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());

            // Push as many events as the window takes
            stream.Insert(MakeArray(events, new String[] { "g0", "g1", "g2", "g3", "g4" }));
            SupportViewDataChecker.CheckOldData(_childView, MakeArray(events, new String[] { "d0", "e0", "e1", "e2", "f0", "f1" }));
            SupportViewDataChecker.CheckNewData(_childView, MakeArray(events, new String[] { "g0", "g1", "g2", "g3", "g4" }));
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());

            // Push 2 more events then the window takes
            stream.Insert(MakeArray(events, new String[] { "h0", "h1", "h2", "h3", "h4", "h5", "h6" }));
            SupportViewDataChecker.CheckOldData(_childView, MakeArray(events, new String[] { "g0", "g1", "g2", "g3", "g4" }));
            SupportViewDataChecker.CheckNewData(_childView, MakeArray(events, new String[] { "h0", "h1", "h2", "h3", "h4", "h5", "h6" }));
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());

            // Push 1 last event
            stream.Insert(MakeArray(events, new String[] { "i0" }));
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(MakeArray(events, new String[] { "i0" }), _myView.GetEnumerator());
        }
示例#16
0
 public void SetUp()
 {
     events = EventFactoryHelper.MakeEventMap(new[] { "a", "b", "c", "d", "e", "f", "g" }, supportEventTypeFactory);
 }
示例#17
0
        public void TestViewPushAndExpire()
        {
            long startTime = 1000000;

            _schedulingServiceStub.Time = startTime;
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);

            IDictionary <String, EventBean> events = EventFactoryHelper.MakeEventMap(
                new String[] { "a1", "b1", "b2", "c1", "d1", "e1", "f1", "f2" });

            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, null);

            // Send new events to the view - should have scheduled a callback for X msec after
            _myView.Update(new EventBean[] { events.Get("a1") }, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(TEST_WINDOW_MSEC) != null);
            _schedulingServiceStub.Added.Clear();

            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("a1") }, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("a1") });

            // Send more events, check
            _schedulingServiceStub.Time = (startTime + 10000);
            _myView.Update(new EventBean[] { events.Get("b1"), events.Get("b2") }, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);

            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("a1"), events.Get("b1"), events.Get("b2") }, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("b1"), events.Get("b2") });

            // Send more events, check
            _schedulingServiceStub.Time = (startTime + TEST_WINDOW_MSEC - 1);
            _myView.Update(new EventBean[] { events.Get("c1") }, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);

            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("a1"), events.Get("b1"), events.Get("b2"), events.Get("c1") }, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("c1") });

            // Pretend we are getting the callback from scheduling, check old data and check new scheduling
            _schedulingServiceStub.Time = (startTime + TEST_WINDOW_MSEC);
            _myView.Expire();
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("b1"), events.Get("b2"), events.Get("c1") }, _myView.GetEnumerator());
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("a1") });
            SupportViewDataChecker.CheckNewData(_childView, null);

            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(10000L) != null);
            _schedulingServiceStub.Added.Clear();

            // Send another 2 events
            _schedulingServiceStub.Time = (startTime + TEST_WINDOW_MSEC);
            _myView.Update(new EventBean[] { events.Get("d1") }, null);
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("d1") });

            _schedulingServiceStub.Time = (startTime + TEST_WINDOW_MSEC + 1);
            _myView.Update(new EventBean[] { events.Get("e1") }, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("e1") });
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("b1"), events.Get("b2"), events.Get("c1"), events.Get("d1"), events.Get("e1") }, _myView.GetEnumerator());

            // Pretend callback received
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);
            _schedulingServiceStub.Time = (startTime + TEST_WINDOW_MSEC + 10000);
            _myView.Expire();
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("b1"), events.Get("b2") });
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("c1"), events.Get("d1"), events.Get("e1") }, _myView.GetEnumerator());

            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(49999L) != null);
            _schedulingServiceStub.Added.Clear();

            // Pretend callback received
            _schedulingServiceStub.Time = (startTime + TEST_WINDOW_MSEC + 59999);
            _myView.Expire();
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("c1") });
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("d1"), events.Get("e1") }, _myView.GetEnumerator());

            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(1L) != null);
            _schedulingServiceStub.Added.Clear();

            // Send another event
            _schedulingServiceStub.Time = (startTime + TEST_WINDOW_MSEC + 200);
            _myView.Update(new EventBean[] { events.Get("f1"), events.Get("f2") }, null);
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);
            SupportViewDataChecker.CheckOldData(_childView, null);
            SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("f1"), events.Get("f2") });
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("d1"), events.Get("e1"), events.Get("f1"), events.Get("f2") }, _myView.GetEnumerator());

            // Pretend callback received, we didn't schedule for 1 msec after, but for 100 msec after
            // testing what happens when clock resolution or some other delay happens
            _schedulingServiceStub.Time = (startTime + TEST_WINDOW_MSEC + 60099);
            _myView.Expire();
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("d1"), events.Get("e1") });
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("f1"), events.Get("f2") }, _myView.GetEnumerator());

            Assert.IsTrue(_schedulingServiceStub.Added.Count == 1);
            Assert.IsTrue(_schedulingServiceStub.Added.Get(101L) != null);
            _schedulingServiceStub.Added.Clear();

            // Pretend callback received
            _schedulingServiceStub.Time = (startTime + TEST_WINDOW_MSEC + 60201);
            _myView.Expire();
            SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("f1"), events.Get("f2") });
            SupportViewDataChecker.CheckNewData(_childView, null);
            EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator());
            Assert.IsTrue(_schedulingServiceStub.Added.Count == 0);
        }