public void TestOrderByWildcard() { var stmtText = "select * from " + typeof(SupportMarketDataBean).FullName + "#length(5) order by Symbol, Volume"; var stmt = _epService.EPAdministrator.CreateEPL(stmtText); Assert.IsFalse(stmt.GetEnumerator().MoveNext()); object eventOne = SendEvent("SYM", 1); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventOne }, stmt.GetEnumerator()); object eventTwo = SendEvent("OCC", 2); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventOne }, stmt.GetEnumerator()); object eventThree = SendEvent("TOC", 3); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventOne, eventThree }, stmt.GetEnumerator()); object eventFour = SendEvent("SYM", 0); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventFour, eventOne, eventThree }, stmt.GetEnumerator()); object eventFive = SendEvent("SYM", 10); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventFour, eventOne, eventFive, eventThree }, stmt.GetEnumerator()); object eventSix = SendEvent("SYM", 4); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventFour, eventSix, eventFive, eventThree }, stmt.GetEnumerator()); }
private void RunAssertionTimeAccumRStream(EPServiceProvider epService, SupportMarketDataBean[] events) { long startTime = 1000; SendTimer(epService, startTime); EPStatement stmt = epService.EPAdministrator.CreateEPL( "select rstream * from " + typeof(SupportMarketDataBean).FullName + "#time_accum(10 sec)"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; EPRuntime engine = epService.EPRuntime; SendTimer(epService, startTime + 10000); Assert.IsFalse(listener.IsInvoked); // some events at 10 sec engine.SendEvent(events[0]); engine.SendEvent(events[1]); engine.SendEvent(events[2]); Assert.IsFalse(listener.IsInvoked); // flush out of the window SendTimer(epService, startTime + 20000); Assert.AreEqual(1, listener.NewDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[0], events[1], events[2] }, listener.GetNewDataListFlattened()); listener.Reset(); stmt.Dispose(); }
public void Run(RegressionEnvironment env) { long startTime = 1000; SendTimer(env, startTime); var events = Get100Events(); var epl = "@Name('s0') select rstream * from SupportMarketDataBean#time_accum(10 sec)"; env.CompileDeployAddListenerMileZero(epl, "s0"); SendTimer(env, startTime + 10000); Assert.IsFalse(env.Listener("s0").IsInvoked); // some events at 10 sec env.SendEventBean(events[0]); env.SendEventBean(events[1]); env.SendEventBean(events[2]); Assert.IsFalse(env.Listener("s0").IsInvoked); // flush out of the window SendTimer(env, startTime + 20000); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[0], events[1], events[2]}, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var epl = "@Name('s0') select irstream * from SupportBean#length_batch(1)"; env.CompileDeployAddListenerMileZero(epl, "s0"); var events = Get10Events(); SendEvent(events[0], env); EPAssertionUtil.AssertUnderlyingPerRow( env.Listener("s0").AssertInvokedAndReset(), new[] {events[0]}, null); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, env.Statement("s0").GetEnumerator()); SendEvent(events[1], env); EPAssertionUtil.AssertUnderlyingPerRow( env.Listener("s0").AssertInvokedAndReset(), new[] {events[1]}, new[] {events[0]}); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, env.Statement("s0").GetEnumerator()); SendEvent(events[2], env); EPAssertionUtil.AssertUnderlyingPerRow( env.Listener("s0").AssertInvokedAndReset(), new[] {events[2]}, new[] {events[1]}); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, env.Statement("s0").GetEnumerator()); env.UndeployAll(); }
public void TestTimeAccumRStream() { long startTime = 1000; SendTimer(startTime); EPStatement stmt = _epService.EPAdministrator.CreateEPL( "select rstream * from " + typeof(SupportMarketDataBean).FullName + "#time_accum(10 sec)"); stmt.Events += _listener.Update; EPRuntime engine = _epService.EPRuntime; SendTimer(startTime + 10000); Assert.IsFalse(_listener.IsInvoked); // some events at 10 sec engine.SendEvent(_events[0]); engine.SendEvent(_events[1]); engine.SendEvent(_events[2]); Assert.IsFalse(_listener.IsInvoked); // flush out of the window SendTimer(startTime + 20000); Assert.AreEqual(1, _listener.NewDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[0], _events[1], _events[2] }, _listener.GetNewDataListFlattened()); _listener.Reset(); }
private void RunAssertionOrderByWildcard(EPServiceProvider epService) { string stmtText = "select * from " + typeof(SupportMarketDataBean).FullName + "#length(5) order by symbol, volume"; EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtText); Assert.IsFalse(stmt.HasFirst()); object eventOne = SendEvent(epService, "SYM", 1); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventOne }, stmt.GetEnumerator()); object eventTwo = SendEvent(epService, "OCC", 2); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventOne }, stmt.GetEnumerator()); object eventThree = SendEvent(epService, "TOC", 3); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventOne, eventThree }, stmt.GetEnumerator()); object eventFour = SendEvent(epService, "SYM", 0); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventFour, eventOne, eventThree }, stmt.GetEnumerator()); object eventFive = SendEvent(epService, "SYM", 10); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventFour, eventOne, eventFive, eventThree }, stmt.GetEnumerator()); object eventSix = SendEvent(epService, "SYM", 4); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { eventTwo, eventFour, eventSix, eventFive, eventThree }, stmt.GetEnumerator()); stmt.Dispose(); }
private void RunAssertionLengthBatchSize1(EPServiceProvider epService, SupportBean[] events) { EPStatement stmt = epService.EPAdministrator.CreateEPL( "select irstream * from " + typeof(SupportBean).FullName + "#length_batch(1)"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendEvent(events[0], epService); EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(), new SupportBean[] { events[0] }, null); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); SendEvent(events[1], epService); EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(), new SupportBean[] { events[1] }, new SupportBean[] { events[0] }); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); SendEvent(events[2], epService); EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(), new SupportBean[] { events[2] }, new SupportBean[] { events[1] }); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); stmt.Dispose(); }
public void TestLengthBatchSize2() { EPStatement stmt = _epService.EPAdministrator.CreateEPL( "select irstream * from " + typeof(SupportBean).FullName + "#length_batch(2)"); stmt.Events += _listener.Update; SendEvent(_events[0]); Assert.IsFalse(_listener.IsInvoked); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new SupportBean[] { _events[0] }, stmt.GetEnumerator()); SendEvent(_events[1]); EPAssertionUtil.AssertUnderlyingPerRow(_listener.AssertInvokedAndReset(), new SupportBean[] { _events[0], _events[1] }, null); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); SendEvent(_events[2]); Assert.IsFalse(_listener.IsInvoked); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new SupportBean[] { _events[2] }, stmt.GetEnumerator()); SendEvent(_events[3]); EPAssertionUtil.AssertUnderlyingPerRow(_listener.AssertInvokedAndReset(), new SupportBean[] { _events[2], _events[3] }, new SupportBean[] { _events[0], _events[1] }); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); SendEvent(_events[4]); Assert.IsFalse(_listener.IsInvoked); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new SupportBean[] { _events[4] }, stmt.GetEnumerator()); SendEvent(_events[5]); EPAssertionUtil.AssertUnderlyingPerRow(_listener.AssertInvokedAndReset(), new SupportBean[] { _events[4], _events[5] }, new SupportBean[] { _events[2], _events[3] }); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); }
private void RunAssertionLengthBatchSize3And2Staggered(EPServiceProvider epService, SupportBean[] events) { if (SupportConfigFactory.SkipTest(typeof(ExecViewLengthBatch))) { return; } EPStatement stmt = epService.EPAdministrator.CreateEPL( "select irstream * from " + typeof(SupportBean).FullName + "#length_batch(3)#length_batch(2)"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendEvent(events[0], epService); Assert.IsFalse(listener.IsInvoked); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); SendEvent(events[1], epService); Assert.IsFalse(listener.IsInvoked); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); SendEvent(events[2], epService); EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(), new SupportBean[] { events[0], events[1], events[2] }, null); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); SendEvent(events[3], epService); Assert.IsFalse(listener.IsInvoked); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); SendEvent(events[4], epService); Assert.IsFalse(listener.IsInvoked); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); SendEvent(events[5], epService); EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(), new SupportBean[] { events[3], events[4], events[5] }, new SupportBean[] { events[0], events[1], events[2] }); EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator()); stmt.Dispose(); }
public void Run(RegressionEnvironment env) { var stmtText = "@Name('s0') select * from SupportMarketDataBean#length(5) order by Symbol, Volume"; env.CompileDeploy(stmtText).AddListener("s0"); Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext()); object eventOne = SendEvent(env, "SYM", 1); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new[] {eventOne}, env.Statement("s0").GetEnumerator()); object eventTwo = SendEvent(env, "OCC", 2); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new[] {eventTwo, eventOne}, env.Statement("s0").GetEnumerator()); object eventThree = SendEvent(env, "TOC", 3); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new[] {eventTwo, eventOne, eventThree}, env.Statement("s0").GetEnumerator()); object eventFour = SendEvent(env, "SYM", 0); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new[] {eventTwo, eventFour, eventOne, eventThree}, env.Statement("s0").GetEnumerator()); object eventFive = SendEvent(env, "SYM", 10); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new[] {eventTwo, eventFour, eventOne, eventFive, eventThree}, env.Statement("s0").GetEnumerator()); object eventSix = SendEvent(env, "SYM", 4); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new[] {eventTwo, eventFour, eventSix, eventFive, eventThree}, env.Statement("s0").GetEnumerator()); env.UndeployAll(); }
public void TestTimeAccum() { long startTime = 1000; SendTimer(startTime); EPStatement stmt = _epService.EPAdministrator.CreateEPL( "select irstream * from " + typeof(SupportMarketDataBean).FullName + "#time_accum(10 sec)"); stmt.Events += _listener.Update; EPRuntime engine = _epService.EPRuntime; SendTimer(startTime + 10000); Assert.IsFalse(_listener.IsInvoked); // 1st at 10 sec engine.SendEvent(_events[0]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[0]); // 2nd event at 14 sec SendTimer(startTime + 14000); engine.SendEvent(_events[1]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[1]); // 3nd event at 14 sec SendTimer(startTime + 14000); engine.SendEvent(_events[2]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[2]); // 3rd event at 23 sec SendTimer(startTime + 23000); engine.SendEvent(_events[3]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[3]); // no event till 33 sec SendTimer(startTime + 32999); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 33000); Assert.IsNull(_listener.LastNewData); Assert.AreEqual(1, _listener.OldDataList.Count); Assert.AreEqual(4, _listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[0], _events[1], _events[2], _events[3] }, _listener.GetOldDataListFlattened()); _listener.Reset(); // no events till 50 sec SendTimer(startTime + 50000); Assert.IsFalse(_listener.IsInvoked); // next two events at 55 sec SendTimer(startTime + 55000); engine.SendEvent(_events[4]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[4]); engine.SendEvent(_events[5]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[5]); // no event till 65 sec SendTimer(startTime + 64999); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 65000); Assert.IsNull(_listener.LastNewData); Assert.AreEqual(1, _listener.OldDataList.Count); Assert.AreEqual(2, _listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[4], _events[5] }, _listener.GetOldDataListFlattened()); _listener.Reset(); // next window engine.SendEvent(_events[6]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[6]); SendTimer(startTime + 74999); engine.SendEvent(_events[7]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[7]); SendTimer(startTime + 74999 + 10000); Assert.IsNull(_listener.LastNewData); Assert.AreEqual(1, _listener.OldDataList.Count); Assert.AreEqual(2, _listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[6], _events[7] }, _listener.GetOldDataListFlattened()); _listener.Reset(); }
public void Run(RegressionEnvironment env) { long startTime = 1000; var events = Get100Events(); SendTimer(env, startTime); var epl = "@Name('s0') select irstream * " + "from SupportMarketDataBean#time_length_batch(10 sec, 3, 'FORCE_UPDATE')"; env.CompileDeployAddListenerMileZero(epl, "s0"); // Send 3 events in batch env.SendEventBean(events[0]); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(events[1]); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(events[2]); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[0], events[1], events[2]}, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); // Send another 3 events in batch env.SendEventBean(events[3]); env.SendEventBean(events[4]); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(events[5]); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[0], events[1], events[2]}, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[3], events[4], events[5]}, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); // Expire the last 3 events by moving time SendTimer(env, startTime + 9999); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 10000); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[3], events[4], events[5]}, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] { }, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); SendTimer(env, startTime + 10001); Assert.IsFalse(env.Listener("s0").IsInvoked); // Send an event, let the timer send the batch SendTimer(env, startTime + 10100); env.SendEventBean(events[6]); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 19999); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 20000); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] { }, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[6]}, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); SendTimer(env, startTime + 20001); Assert.IsFalse(env.Listener("s0").IsInvoked); // Send two events, let the timer send the batch SendTimer(env, startTime + 29998); env.SendEventBean(events[7]); env.SendEventBean(events[8]); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 29999); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 30000); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[6]}, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[7], events[8]}, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); // Send three events, the the 3 events batch SendTimer(env, startTime + 30001); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(events[9]); env.SendEventBean(events[10]); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 39000); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(events[11]); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[7], events[8]}, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[9], events[10], events[11]}, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); // Send 1 event, let the timer to do the batch SendTimer(env, startTime + 39000 + 9999); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(events[12]); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 39000 + 10000); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[9], events[10], events[11]}, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[12]}, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); SendTimer(env, startTime + 39000 + 10001); Assert.IsFalse(env.Listener("s0").IsInvoked); // Send no events, let the timer to do the batch SendTimer(env, startTime + 39000 + 19999); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 39000 + 20000); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[12]}, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] { }, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); SendTimer(env, startTime + 39000 + 20001); Assert.IsFalse(env.Listener("s0").IsInvoked); // Send no events, let the timer do a batch SendTimer(env, startTime + 39000 + 29999); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 39000 + 30000); Assert.AreEqual(1, env.Listener("s0").NewDataList.Count); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] { }, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] { }, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); SendTimer(env, startTime + 39000 + 30001); Assert.IsFalse(env.Listener("s0").IsInvoked); // Send no events, let the timer do a batch SendTimer(env, startTime + 39000 + 39999); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 39000 + 40000); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] { }, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] { }, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); SendTimer(env, startTime + 39000 + 40001); Assert.IsFalse(env.Listener("s0").IsInvoked); // Send 1 more event SendTimer(env, startTime + 80000); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(events[13]); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 88999); // 10 sec from last batch Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 89000); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] { }, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[13]}, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); // Send 3 more events SendTimer(env, startTime + 90000); env.SendEventBean(events[14]); env.SendEventBean(events[15]); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 92000); env.SendEventBean(events[16]); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[13]}, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[14], events[15], events[16]}, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); // Send no events, let the timer do a batch SendTimer(env, startTime + 101999); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 102000); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[14], events[15], events[16]}, env.Listener("s0").OldDataListFlattened); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] { }, env.Listener("s0").NewDataListFlattened); env.Listener("s0").Reset(); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { long startTime = 1000; SendTimer(env, startTime); var events = Get100Events(); var epl = "@Name('s0') select irstream * from SupportMarketDataBean#time_accum(10 sec)"; env.CompileDeployAddListenerMileZero(epl, "s0"); SendTimer(env, startTime + 10000); Assert.IsFalse(env.Listener("s0").IsInvoked); // 1st at 10 sec env.SendEventBean(events[0]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[0]); // 2nd event at 14 sec SendTimer(env, startTime + 14000); env.SendEventBean(events[1]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[1]); // 3nd event at 14 sec SendTimer(env, startTime + 14000); env.SendEventBean(events[2]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[2]); // 3rd event at 23 sec SendTimer(env, startTime + 23000); env.SendEventBean(events[3]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[3]); // no event till 33 sec SendTimer(env, startTime + 32999); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 33000); Assert.IsNull(env.Listener("s0").LastNewData); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); Assert.AreEqual(4, env.Listener("s0").LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[0], events[1], events[2], events[3]}, env.Listener("s0").OldDataListFlattened); env.Listener("s0").Reset(); // no events till 50 sec SendTimer(env, startTime + 50000); Assert.IsFalse(env.Listener("s0").IsInvoked); // next two events at 55 sec SendTimer(env, startTime + 55000); env.SendEventBean(events[4]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[4]); env.SendEventBean(events[5]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[5]); // no event till 65 sec SendTimer(env, startTime + 64999); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(env, startTime + 65000); Assert.IsNull(env.Listener("s0").LastNewData); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); Assert.AreEqual(2, env.Listener("s0").LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[4], events[5]}, env.Listener("s0").OldDataListFlattened); env.Listener("s0").Reset(); // next window env.SendEventBean(events[6]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[6]); SendTimer(env, startTime + 74999); env.SendEventBean(events[7]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[7]); SendTimer(env, startTime + 74999 + 10000); Assert.IsNull(env.Listener("s0").LastNewData); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); Assert.AreEqual(2, env.Listener("s0").LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[6], events[7]}, env.Listener("s0").OldDataListFlattened); env.Listener("s0").Reset(); env.UndeployAll(); }
public void TestGroupedWindow() { long startTime = 1000; SendTimer(startTime); EPStatement stmt = _epService.EPAdministrator.CreateEPL( "select irstream * from " + typeof(SupportMarketDataBean).FullName + "#groupwin(symbol)#time_accum(10 sec)"); stmt.Events += _listener.Update; EPRuntime engine = _epService.EPRuntime; // 1st S1 event SendTimer(startTime + 10000); engine.SendEvent(_events[1]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[1]); // 1st S2 event SendTimer(startTime + 12000); engine.SendEvent(_events[2]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[2]); // 2nd S1 event SendTimer(startTime + 15000); engine.SendEvent(_events[11]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[11]); // 2nd S2 event SendTimer(startTime + 18000); engine.SendEvent(_events[12]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[12]); // 3rd S1 event SendTimer(startTime + 21000); engine.SendEvent(_events[21]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[21]); SendTimer(startTime + 28000); Assert.IsNull(_listener.LastNewData); Assert.AreEqual(1, _listener.OldDataList.Count); Assert.AreEqual(2, _listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[2], _events[12] }, _listener.GetOldDataListFlattened()); _listener.Reset(); // 3rd S2 event SendTimer(startTime + 29000); engine.SendEvent(_events[32]); Assert.AreSame(_listener.AssertOneGetNewAndReset().Underlying, _events[32]); SendTimer(startTime + 31000); Assert.IsNull(_listener.LastNewData); Assert.AreEqual(1, _listener.OldDataList.Count); Assert.AreEqual(3, _listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[1], _events[11], _events[21] }, _listener.GetOldDataListFlattened()); _listener.Reset(); SendTimer(startTime + 39000); Assert.IsNull(_listener.LastNewData); Assert.AreEqual(1, _listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[32] }, _listener.GetOldDataListFlattened()); _listener.Reset(); }
public void Run(RegressionEnvironment env) { long startTime = 1000; SendTimer(env, startTime); var events = Get100Events(); var epl = "@Name('s0') select irstream * from SupportMarketDataBean#groupwin(Symbol)#time_accum(10 sec)"; env.CompileDeployAddListenerMileZero(epl, "s0"); // 1st S1 event SendTimer(env, startTime + 10000); env.SendEventBean(events[1]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[1]); // 1st S2 event SendTimer(env, startTime + 12000); env.SendEventBean(events[2]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[2]); // 2nd S1 event SendTimer(env, startTime + 15000); env.SendEventBean(events[11]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[11]); // 2nd S2 event SendTimer(env, startTime + 18000); env.SendEventBean(events[12]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[12]); // 3rd S1 event SendTimer(env, startTime + 21000); env.SendEventBean(events[21]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[21]); SendTimer(env, startTime + 28000); Assert.IsNull(env.Listener("s0").LastNewData); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); Assert.AreEqual(2, env.Listener("s0").LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[2], events[12]}, env.Listener("s0").OldDataListFlattened); env.Listener("s0").Reset(); // 3rd S2 event SendTimer(env, startTime + 29000); env.SendEventBean(events[32]); Assert.AreSame(env.Listener("s0").AssertOneGetNewAndReset().Underlying, events[32]); SendTimer(env, startTime + 31000); Assert.IsNull(env.Listener("s0").LastNewData); Assert.AreEqual(1, env.Listener("s0").OldDataList.Count); Assert.AreEqual(3, env.Listener("s0").LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[1], events[11], events[21]}, env.Listener("s0").OldDataListFlattened); env.Listener("s0").Reset(); SendTimer(env, startTime + 39000); Assert.IsNull(env.Listener("s0").LastNewData); Assert.AreEqual(1, env.Listener("s0").LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying( new object[] {events[32]}, env.Listener("s0").OldDataListFlattened); env.Listener("s0").Reset(); env.UndeployAll(); }
private void RunAssertionTimeAccum(EPServiceProvider epService, SupportMarketDataBean[] events) { long startTime = 1000; SendTimer(epService, startTime); EPStatement stmt = epService.EPAdministrator.CreateEPL( "select irstream * from " + typeof(SupportMarketDataBean).FullName + "#time_accum(10 sec)"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; EPRuntime engine = epService.EPRuntime; SendTimer(epService, startTime + 10000); Assert.IsFalse(listener.IsInvoked); // 1st at 10 sec engine.SendEvent(events[0]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[0]); // 2nd event at 14 sec SendTimer(epService, startTime + 14000); engine.SendEvent(events[1]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[1]); // 3nd event at 14 sec SendTimer(epService, startTime + 14000); engine.SendEvent(events[2]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[2]); // 3rd event at 23 sec SendTimer(epService, startTime + 23000); engine.SendEvent(events[3]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[3]); // no event till 33 sec SendTimer(epService, startTime + 32999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 33000); Assert.IsNull(listener.LastNewData); Assert.AreEqual(1, listener.OldDataList.Count); Assert.AreEqual(4, listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[0], events[1], events[2], events[3] }, listener.GetOldDataListFlattened()); listener.Reset(); // no events till 50 sec SendTimer(epService, startTime + 50000); Assert.IsFalse(listener.IsInvoked); // next two events at 55 sec SendTimer(epService, startTime + 55000); engine.SendEvent(events[4]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[4]); engine.SendEvent(events[5]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[5]); // no event till 65 sec SendTimer(epService, startTime + 64999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 65000); Assert.IsNull(listener.LastNewData); Assert.AreEqual(1, listener.OldDataList.Count); Assert.AreEqual(2, listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[4], events[5] }, listener.GetOldDataListFlattened()); listener.Reset(); // next window engine.SendEvent(events[6]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[6]); SendTimer(epService, startTime + 74999); engine.SendEvent(events[7]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[7]); SendTimer(epService, startTime + 74999 + 10000); Assert.IsNull(listener.LastNewData); Assert.AreEqual(1, listener.OldDataList.Count); Assert.AreEqual(2, listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[6], events[7] }, listener.GetOldDataListFlattened()); listener.Reset(); stmt.Dispose(); }
private void RunAssertionGroupedWindow(EPServiceProvider epService, SupportMarketDataBean[] events) { long startTime = 1000; SendTimer(epService, startTime); EPStatement stmt = epService.EPAdministrator.CreateEPL( "select irstream * from " + typeof(SupportMarketDataBean).FullName + "#groupwin(symbol)#time_accum(10 sec)"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; EPRuntime engine = epService.EPRuntime; // 1st S1 event SendTimer(epService, startTime + 10000); engine.SendEvent(events[1]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[1]); // 1st S2 event SendTimer(epService, startTime + 12000); engine.SendEvent(events[2]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[2]); // 2nd S1 event SendTimer(epService, startTime + 15000); engine.SendEvent(events[11]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[11]); // 2nd S2 event SendTimer(epService, startTime + 18000); engine.SendEvent(events[12]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[12]); // 3rd S1 event SendTimer(epService, startTime + 21000); engine.SendEvent(events[21]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[21]); SendTimer(epService, startTime + 28000); Assert.IsNull(listener.LastNewData); Assert.AreEqual(1, listener.OldDataList.Count); Assert.AreEqual(2, listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[2], events[12] }, listener.GetOldDataListFlattened()); listener.Reset(); // 3rd S2 event SendTimer(epService, startTime + 29000); engine.SendEvent(events[32]); Assert.AreSame(listener.AssertOneGetNewAndReset().Underlying, events[32]); SendTimer(epService, startTime + 31000); Assert.IsNull(listener.LastNewData); Assert.AreEqual(1, listener.OldDataList.Count); Assert.AreEqual(3, listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[1], events[11], events[21] }, listener.GetOldDataListFlattened()); listener.Reset(); SendTimer(epService, startTime + 39000); Assert.IsNull(listener.LastNewData); Assert.AreEqual(1, listener.LastOldData.Length); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[32] }, listener.GetOldDataListFlattened()); listener.Reset(); stmt.Dispose(); }
public void TestTimeLengthBatchForceOutput() { long startTime = 1000; SendTimer(startTime); EPStatement stmt = _epService.EPAdministrator.CreateEPL( "select irstream * from " + typeof(SupportMarketDataBean).FullName + ".win:time_length_batch(10 sec, 3, 'FORCE_UPDATE')"); stmt.Events += _listener.Update; EPRuntime engine = _epService.EPRuntime; // Send 3 events in batch engine.SendEvent(_events[0]); Assert.IsFalse(_listener.IsInvoked); engine.SendEvent(_events[1]); Assert.IsFalse(_listener.IsInvoked); engine.SendEvent(_events[2]); Assert.AreEqual(1, _listener.NewDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[0], _events[1], _events[2] }, _listener.GetNewDataListFlattened()); _listener.Reset(); // Send another 3 events in batch engine.SendEvent(_events[3]); engine.SendEvent(_events[4]); Assert.IsFalse(_listener.IsInvoked); engine.SendEvent(_events[5]); Assert.AreEqual(1, _listener.NewDataList.Count); Assert.AreEqual(1, _listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[0], _events[1], _events[2] }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[3], _events[4], _events[5] }, _listener.GetNewDataListFlattened()); _listener.Reset(); // Expire the last 3 events by moving time SendTimer(startTime + 9999); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 10000); Assert.AreEqual(1, _listener.NewDataList.Count); Assert.AreEqual(1, _listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[3], _events[4], _events[5] }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { }, _listener.GetNewDataListFlattened()); _listener.Reset(); SendTimer(startTime + 10001); Assert.IsFalse(_listener.IsInvoked); // Send an event, let the timer send the batch SendTimer(startTime + 10100); engine.SendEvent(_events[6]); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 19999); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 20000); Assert.AreEqual(1, _listener.NewDataList.Count); Assert.AreEqual(1, _listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[6] }, _listener.GetNewDataListFlattened()); _listener.Reset(); SendTimer(startTime + 20001); Assert.IsFalse(_listener.IsInvoked); // Send two events, let the timer send the batch SendTimer(startTime + 29998); engine.SendEvent(_events[7]); engine.SendEvent(_events[8]); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 29999); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 30000); Assert.AreEqual(1, _listener.NewDataList.Count); Assert.AreEqual(1, _listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[6] }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[7], _events[8] }, _listener.GetNewDataListFlattened()); _listener.Reset(); // Send three events, the the 3 events batch SendTimer(startTime + 30001); Assert.IsFalse(_listener.IsInvoked); engine.SendEvent(_events[9]); engine.SendEvent(_events[10]); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 39000); Assert.IsFalse(_listener.IsInvoked); engine.SendEvent(_events[11]); Assert.AreEqual(1, _listener.NewDataList.Count); Assert.AreEqual(1, _listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[7], _events[8] }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[9], _events[10], _events[11] }, _listener.GetNewDataListFlattened()); _listener.Reset(); // Send 1 event, let the timer to do the batch SendTimer(startTime + 39000 + 9999); Assert.IsFalse(_listener.IsInvoked); engine.SendEvent(_events[12]); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 39000 + 10000); Assert.AreEqual(1, _listener.NewDataList.Count); Assert.AreEqual(1, _listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[9], _events[10], _events[11] }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[12] }, _listener.GetNewDataListFlattened()); _listener.Reset(); SendTimer(startTime + 39000 + 10001); Assert.IsFalse(_listener.IsInvoked); // Send no events, let the timer to do the batch SendTimer(startTime + 39000 + 19999); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 39000 + 20000); Assert.AreEqual(1, _listener.NewDataList.Count); Assert.AreEqual(1, _listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[12] }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { }, _listener.GetNewDataListFlattened()); _listener.Reset(); SendTimer(startTime + 39000 + 20001); Assert.IsFalse(_listener.IsInvoked); // Send no events, let the timer do a batch SendTimer(startTime + 39000 + 29999); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 39000 + 30000); Assert.AreEqual(1, _listener.NewDataList.Count); Assert.AreEqual(1, _listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { }, _listener.GetNewDataListFlattened()); _listener.Reset(); SendTimer(startTime + 39000 + 30001); Assert.IsFalse(_listener.IsInvoked); // Send no events, let the timer do a batch SendTimer(startTime + 39000 + 39999); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 39000 + 40000); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { }, _listener.GetNewDataListFlattened()); _listener.Reset(); SendTimer(startTime + 39000 + 40001); Assert.IsFalse(_listener.IsInvoked); // Send 1 more event SendTimer(startTime + 80000); Assert.IsFalse(_listener.IsInvoked); engine.SendEvent(_events[13]); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 88999); // 10 sec from last batch Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 89000); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[13] }, _listener.GetNewDataListFlattened()); _listener.Reset(); // Send 3 more events SendTimer(startTime + 90000); engine.SendEvent(_events[14]); engine.SendEvent(_events[15]); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 92000); engine.SendEvent(_events[16]); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[13] }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[14], _events[15], _events[16] }, _listener.GetNewDataListFlattened()); _listener.Reset(); // Send no events, let the timer do a batch SendTimer(startTime + 101999); Assert.IsFalse(_listener.IsInvoked); SendTimer(startTime + 102000); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { _events[14], _events[15], _events[16] }, _listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new Object[] { }, _listener.GetNewDataListFlattened()); _listener.Reset(); }
private void RunAssertionTimeLengthBatch(EPServiceProvider epService, SupportMarketDataBean[] events) { long startTime = 1000; SendTimer(epService, startTime); EPStatement stmt = epService.EPAdministrator.CreateEPL( "select irstream * from " + typeof(SupportMarketDataBean).FullName + "#time_length_batch(10 sec, 3)"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; EPRuntime engine = epService.EPRuntime; // Send 3 events in batch engine.SendEvent(events[0]); Assert.IsFalse(listener.IsInvoked); engine.SendEvent(events[1]); Assert.IsFalse(listener.IsInvoked); engine.SendEvent(events[2]); Assert.AreEqual(1, listener.NewDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[0], events[1], events[2] }, listener.GetNewDataListFlattened()); listener.Reset(); // Send another 3 events in batch engine.SendEvent(events[3]); engine.SendEvent(events[4]); Assert.IsFalse(listener.IsInvoked); engine.SendEvent(events[5]); Assert.AreEqual(1, listener.NewDataList.Count); Assert.AreEqual(1, listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[0], events[1], events[2] }, listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[3], events[4], events[5] }, listener.GetNewDataListFlattened()); listener.Reset(); // Expire the last 3 events by moving time SendTimer(epService, startTime + 9999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 10000); Assert.AreEqual(1, listener.NewDataList.Count); Assert.AreEqual(1, listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[3], events[4], events[5] }, listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] {}, listener.GetNewDataListFlattened()); listener.Reset(); SendTimer(epService, startTime + 10001); Assert.IsFalse(listener.IsInvoked); // Send an event, let the timer send the batch SendTimer(epService, startTime + 10100); engine.SendEvent(events[6]); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 19999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 20000); Assert.AreEqual(1, listener.NewDataList.Count); Assert.AreEqual(1, listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] {}, listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[6] }, listener.GetNewDataListFlattened()); listener.Reset(); SendTimer(epService, startTime + 20001); Assert.IsFalse(listener.IsInvoked); // Send two events, let the timer send the batch SendTimer(epService, startTime + 29998); engine.SendEvent(events[7]); engine.SendEvent(events[8]); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 29999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 30000); Assert.AreEqual(1, listener.NewDataList.Count); Assert.AreEqual(1, listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[6] }, listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[7], events[8] }, listener.GetNewDataListFlattened()); listener.Reset(); // Send three events, the the 3 events batch SendTimer(epService, startTime + 30001); Assert.IsFalse(listener.IsInvoked); engine.SendEvent(events[9]); engine.SendEvent(events[10]); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 39000); Assert.IsFalse(listener.IsInvoked); engine.SendEvent(events[11]); Assert.AreEqual(1, listener.NewDataList.Count); Assert.AreEqual(1, listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[7], events[8] }, listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[9], events[10], events[11] }, listener.GetNewDataListFlattened()); listener.Reset(); // Send 1 event, let the timer to do the batch SendTimer(epService, startTime + 39000 + 9999); Assert.IsFalse(listener.IsInvoked); engine.SendEvent(events[12]); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 39000 + 10000); Assert.AreEqual(1, listener.NewDataList.Count); Assert.AreEqual(1, listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[9], events[10], events[11] }, listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[12] }, listener.GetNewDataListFlattened()); listener.Reset(); SendTimer(epService, startTime + 39000 + 10001); Assert.IsFalse(listener.IsInvoked); // Send no events, let the timer to do the batch SendTimer(epService, startTime + 39000 + 19999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 39000 + 20000); Assert.AreEqual(1, listener.NewDataList.Count); Assert.AreEqual(1, listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[12] }, listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] {}, listener.GetNewDataListFlattened()); listener.Reset(); SendTimer(epService, startTime + 39000 + 20001); Assert.IsFalse(listener.IsInvoked); // Send no events, let the timer to do NO batch SendTimer(epService, startTime + 39000 + 29999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 39000 + 30000); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 39000 + 30001); Assert.IsFalse(listener.IsInvoked); // Send 1 more event SendTimer(epService, startTime + 90000); Assert.IsFalse(listener.IsInvoked); engine.SendEvent(events[13]); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 99999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, startTime + 100000); Assert.AreEqual(1, listener.NewDataList.Count); Assert.AreEqual(1, listener.OldDataList.Count); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] {}, listener.GetOldDataListFlattened()); EPAssertionUtil.AssertEqualsExactOrderUnderlying(new object[] { events[13] }, listener.GetNewDataListFlattened()); listener.Reset(); stmt.Dispose(); }