Esempio n. 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);
        }
Esempio n. 2
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);
        }