private void RunAssertionTimeToLive(EPServiceProvider epService) { epService.EPRuntime.SendEvent(new CurrentTimeEvent(0)); string[] fields = "id".Split(','); string epl = "select irstream * from SupportBeanTimestamp#timetolive(timestamp)"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendEvent(epService, "E1", 1000); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } }); SendEvent(epService, "E2", 500); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2" }, new object[] { "E1" } }); epService.EPRuntime.SendEvent(new CurrentTimeEvent(499)); Assert.IsFalse(listener.GetAndClearIsInvoked()); epService.EPRuntime.SendEvent(new CurrentTimeEvent(500)); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E2" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } }); SendEvent(epService, "E3", 200); EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E3" }, new object[] { "E3" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } }); SendEvent(epService, "E4", 1200); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E4" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E4" } }); SendEvent(epService, "E5", 1000); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E5" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E4" }, new object[] { "E5" } }); epService.EPRuntime.SendEvent(new CurrentTimeEvent(999)); Assert.IsFalse(listener.GetAndClearIsInvoked()); epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000)); EPAssertionUtil.AssertPropsPerRowAnyOrder(listener.GetAndResetDataListsFlattened(), fields, null, new object[][] { new object[] { "E1" }, new object[] { "E5" } }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E4" } }); epService.EPRuntime.SendEvent(new CurrentTimeEvent(1199)); Assert.IsFalse(listener.GetAndClearIsInvoked()); epService.EPRuntime.SendEvent(new CurrentTimeEvent(1200)); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E4" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null); SendEvent(epService, "E6", 1200); EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E6" }, new object[] { "E6" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null); epService.EPAdministrator.DestroyAllStatements(); }
public void TestTimeWindow() { SendTimer(0); _stmtCreateWin = _epService.EPAdministrator.CreateEPL( "create window RevQuote.win:time(10 sec) as select * from RevisableQuote"); _epService.EPAdministrator.CreateEPL("insert into RevQuote select * from FullEvent"); _epService.EPAdministrator.CreateEPL("insert into RevQuote select * from D1"); _epService.EPAdministrator.CreateEPL("insert into RevQuote select * from D5"); EPStatement consumerOne = _epService.EPAdministrator.CreateEPL("select irstream * from RevQuote"); consumerOne.Events += _listenerOne.Update; _epService.EPRuntime.SendEvent(new SupportRevisionFull("a", "a10", "a50")); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), _fields, new Object[] { "a", "a10", "a50" }); EPAssertionUtil.AssertProps(_stmtCreateWin.First(), _fields, new Object[] { "a", "a10", "a50" }); SendTimer(1000); _epService.EPRuntime.SendEvent(new SupportDeltaFive("a", "a11", "a51")); EPAssertionUtil.AssertProps(_listenerOne.LastNewData[0], _fields, new Object[] { "a", "a11", "a51" }); EPAssertionUtil.AssertProps(_listenerOne.LastOldData[0], _fields, new Object[] { "a", "a10", "a50" }); EPAssertionUtil.AssertProps(_stmtCreateWin.First(), _fields, new Object[] { "a", "a11", "a51" }); SendTimer(2000); _epService.EPRuntime.SendEvent(new SupportRevisionFull("b", "b10", "b50")); _epService.EPRuntime.SendEvent(new SupportRevisionFull("c", "c10", "c50")); SendTimer(3000); _epService.EPRuntime.SendEvent(new SupportDeltaOne("c", "c11", "c51")); SendTimer(8000); _epService.EPRuntime.SendEvent(new SupportDeltaOne("c", "c12", "c52")); _listenerOne.Reset(); SendTimer(10000); Assert.IsFalse(_listenerOne.IsInvoked); SendTimer(11000); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetOldAndReset(), _fields, new Object[] { "a", "a11", "a51" }); SendTimer(12000); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetOldAndReset(), _fields, new Object[] { "b", "b10", "b50" }); SendTimer(13000); Assert.IsFalse(_listenerOne.IsInvoked); SendTimer(18000); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetOldAndReset(), _fields, new Object[] { "c", "c12", "c52" }); }
private void RunAssertionRemoveStream(EPServiceProvider epService) { var fields = "TheString,IntPrimitive,LongPrimitive".Split(','); var stmtCreate = epService.EPAdministrator.CreateEPL("create window MyWindow#rank(TheString, 3, IntPrimitive asc) as SupportBean"); epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean"); var stmtListen = epService.EPAdministrator.CreateEPL("select irstream * from MyWindow"); var listener = new SupportUpdateListener(); stmtListen.Events += listener.Update; epService.EPAdministrator.CreateEPL("on SupportBean_A delete from MyWindow mw where TheString = id"); epService.EPRuntime.SendEvent(MakeEvent("E1", 10, 0L)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 10, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 10, 0L } }); epService.EPRuntime.SendEvent(MakeEvent("E2", 50, 0L)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2", 50, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 10, 0L }, new object[] { "E2", 50, 0L } }); epService.EPRuntime.SendEvent(MakeEvent("E3", 5, 0L)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E3", 5, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E3", 5, 0L }, new object[] { "E1", 10, 0L }, new object[] { "E2", 50, 0L } }); epService.EPRuntime.SendEvent(MakeEvent("E4", 5, 0L)); EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E4", 5, 0L }, new object[] { "E2", 50, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E3", 5, 0L }, new object[] { "E4", 5, 0L }, new object[] { "E1", 10, 0L } }); epService.EPRuntime.SendEvent(new SupportBean_A("E3")); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E3", 5, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E4", 5, 0L }, new object[] { "E1", 10, 0L } }); epService.EPRuntime.SendEvent(new SupportBean_A("E4")); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E4", 5, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 10, 0L } }); epService.EPRuntime.SendEvent(new SupportBean_A("E1")); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E1", 10, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[0][]); epService.EPRuntime.SendEvent(MakeEvent("E3", 100, 0L)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E3", 100, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E3", 100, 0L } }); epService.EPRuntime.SendEvent(MakeEvent("E3", 101, 1L)); EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E3", 101, 1L }, new object[] { "E3", 100, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E3", 101, 1L } }); epService.EPRuntime.SendEvent(new SupportBean_A("E3")); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E3", 101, 1L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[0][]); epService.EPAdministrator.DestroyAllStatements(); }
private void RunAssertionTimeWindow(EPServiceProvider epService) { SendTimer(epService, 0); EPStatement stmtCreateWin = epService.EPAdministrator.CreateEPL("create window RevQuote#time(10 sec) as select * from RevisableQuote"); epService.EPAdministrator.CreateEPL("insert into RevQuote select * from FullEvent"); epService.EPAdministrator.CreateEPL("insert into RevQuote select * from D1"); epService.EPAdministrator.CreateEPL("insert into RevQuote select * from D5"); EPStatement consumerOne = epService.EPAdministrator.CreateEPL("select irstream * from RevQuote"); var listenerOne = new SupportUpdateListener(); consumerOne.Events += listenerOne.Update; epService.EPRuntime.SendEvent(new SupportRevisionFull("a", "a10", "a50")); EPAssertionUtil.AssertProps(listenerOne.AssertOneGetNewAndReset(), fields, new object[] { "a", "a10", "a50" }); EPAssertionUtil.AssertProps(stmtCreateWin.First(), fields, new object[] { "a", "a10", "a50" }); SendTimer(epService, 1000); epService.EPRuntime.SendEvent(new SupportDeltaFive("a", "a11", "a51")); EPAssertionUtil.AssertProps(listenerOne.LastNewData[0], fields, new object[] { "a", "a11", "a51" }); EPAssertionUtil.AssertProps(listenerOne.LastOldData[0], fields, new object[] { "a", "a10", "a50" }); EPAssertionUtil.AssertProps(stmtCreateWin.First(), fields, new object[] { "a", "a11", "a51" }); SendTimer(epService, 2000); epService.EPRuntime.SendEvent(new SupportRevisionFull("b", "b10", "b50")); epService.EPRuntime.SendEvent(new SupportRevisionFull("c", "c10", "c50")); SendTimer(epService, 3000); epService.EPRuntime.SendEvent(new SupportDeltaOne("c", "c11", "c51")); SendTimer(epService, 8000); epService.EPRuntime.SendEvent(new SupportDeltaOne("c", "c12", "c52")); listenerOne.Reset(); SendTimer(epService, 10000); Assert.IsFalse(listenerOne.IsInvoked); SendTimer(epService, 11000); EPAssertionUtil.AssertProps(listenerOne.AssertOneGetOldAndReset(), fields, new object[] { "a", "a11", "a51" }); SendTimer(epService, 12000); EPAssertionUtil.AssertProps(listenerOne.AssertOneGetOldAndReset(), fields, new object[] { "b", "b10", "b50" }); SendTimer(epService, 13000); Assert.IsFalse(listenerOne.IsInvoked); SendTimer(epService, 18000); EPAssertionUtil.AssertProps(listenerOne.AssertOneGetOldAndReset(), fields, new object[] { "c", "c12", "c52" }); }
public void TestRemoveStream() { String[] fields = "TheString,IntPrimitive,LongPrimitive".Split(','); EPStatement stmtCreate = _epService.EPAdministrator.CreateEPL("create window MyWindow.ext:rank(TheString, 3, IntPrimitive asc) as SupportBean"); _epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean"); EPStatement stmtListen = _epService.EPAdministrator.CreateEPL("select irstream * from MyWindow"); stmtListen.Events += _listener.Update; _epService.EPAdministrator.CreateEPL("on SupportBean_A delete from MyWindow mw where TheString = id"); _epService.EPRuntime.SendEvent(MakeEvent("E1", 10, 0L)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1", 10, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 10, 0L } }); _epService.EPRuntime.SendEvent(MakeEvent("E2", 50, 0L)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E2", 50, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 10, 0L }, new Object[] { "E2", 50, 0L } }); _epService.EPRuntime.SendEvent(MakeEvent("E3", 5, 0L)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E3", 5, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[][] { new Object[] { "E3", 5, 0L }, new Object[] { "E1", 10, 0L }, new Object[] { "E2", 50, 0L } }); _epService.EPRuntime.SendEvent(MakeEvent("E4", 5, 0L)); EPAssertionUtil.AssertProps(_listener.AssertPairGetIRAndReset(), fields, new Object[] { "E4", 5, 0L }, new Object[] { "E2", 50, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[][] { new Object[] { "E3", 5, 0L }, new Object[] { "E4", 5, 0L }, new Object[] { "E1", 10, 0L } }); _epService.EPRuntime.SendEvent(new SupportBean_A("E3")); EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), fields, new Object[] { "E3", 5, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[][] { new Object[] { "E4", 5, 0L }, new Object[] { "E1", 10, 0L } }); _epService.EPRuntime.SendEvent(new SupportBean_A("E4")); EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), fields, new Object[] { "E4", 5, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 10, 0L } }); _epService.EPRuntime.SendEvent(new SupportBean_A("E1")); EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), fields, new Object[] { "E1", 10, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[0][]); _epService.EPRuntime.SendEvent(MakeEvent("E3", 100, 0L)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E3", 100, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[][] { new Object[] { "E3", 100, 0L } }); _epService.EPRuntime.SendEvent(MakeEvent("E3", 101, 1L)); EPAssertionUtil.AssertProps(_listener.AssertPairGetIRAndReset(), fields, new Object[] { "E3", 101, 1L }, new Object[] { "E3", 100, 0L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[][] { new Object[] { "E3", 101, 1L } }); _epService.EPRuntime.SendEvent(new SupportBean_A("E3")); EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), fields, new Object[] { "E3", 101, 1L }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[0][]); }
private void TryAssertionTimeWinUnique(EPServiceProvider epService, SupportUpdateListener listener, EPStatement stmt) { var fields = new string[] { "TheString" }; SendTimer(epService, 1000); SendEvent(epService, "E1", 1); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E1")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1" }); SendTimer(epService, 2000); SendEvent(epService, "E2", 2); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E1", "E2")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2" }); SendTimer(epService, 3000); SendEvent(epService, "E3", 1); EPAssertionUtil.AssertProps(listener.AssertOneGetOld(), fields, new object[] { "E1" }); EPAssertionUtil.AssertProps(listener.AssertOneGetNew(), fields, new object[] { "E3" }); listener.Reset(); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E2", "E3")); SendTimer(epService, 4000); SendEvent(epService, "E4", 3); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E4" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E2", "E3", "E4")); SendEvent(epService, "E5", 3); EPAssertionUtil.AssertProps(listener.AssertOneGetOld(), fields, new object[] { "E4" }); EPAssertionUtil.AssertProps(listener.AssertOneGetNew(), fields, new object[] { "E5" }); listener.Reset(); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E2", "E3", "E5")); SendTimer(epService, 11999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, 12000); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E2" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E3", "E5")); SendTimer(epService, 12999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, 13000); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E3" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E5")); SendTimer(epService, 13999); Assert.IsFalse(listener.IsInvoked); SendTimer(epService, 14000); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E5" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr()); }
public void TestCountHaving() { var theEvent = typeof(SupportBean).FullName; var statementText = "select irstream sum(intPrimitive) as mysum from " + theEvent + " having sum(intPrimitive) = 2"; _selectTestView = _epService.EPAdministrator.CreateEPL(statementText); _selectTestView.AddListener(_listener); SendEvent(); Assert.IsFalse(_listener.GetAndClearIsInvoked()); SendEvent(); Assert.AreEqual(2, _listener.AssertOneGetNewAndReset().Get("mysum")); SendEvent(); Assert.AreEqual(2, _listener.AssertOneGetOldAndReset().Get("mysum")); }
private void RunAssertionNamedWindowDelete(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType("SupportBean_A", typeof(SupportBean_A)); var fields = new[] { "TheString" }; EPStatement stmt = epService.EPAdministrator.CreateEPL("create window NW#expr(true) as SupportBean"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPAdministrator.CreateEPL("insert into NW select * from SupportBean"); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); epService.EPRuntime.SendEvent(new SupportBean("E2", 2)); epService.EPRuntime.SendEvent(new SupportBean("E3", 3)); listener.Reset(); EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E1" }, new object[] { "E2" }, new object[] { "E3" } }); epService.EPAdministrator.CreateEPL("on SupportBean_A delete from NW where TheString = id"); epService.EPRuntime.SendEvent(new SupportBean_A("E2")); EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E1" }, new object[] { "E3" } }); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E2" }); epService.EPAdministrator.DestroyAllStatements(); }
public void TestFirstUniqueAndLengthOnDelete() { Init(false); var nwstmt = _epService.EPAdministrator.CreateEPL("create window MyWindow.std:firstunique(TheString).win:firstlength(3) as SupportBean"); _epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean"); _epService.EPAdministrator.CreateEPL("on SupportBean_S0 delete from MyWindow where TheString = p00"); var stmt = _epService.EPAdministrator.CreateEPL("select irstream * from MyWindow"); stmt.Events += _listener.Update; var fields = new String[] { "TheString", "IntPrimitive" }; SendEvent("E1", 1); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 1 } }); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1", 1 }); SendEvent("E1", 99); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 1 } }); Assert.IsFalse(_listener.IsInvoked); SendEvent("E2", 2); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 1 }, new Object[] { "E2", 2 } }); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E2", 2 }); _epService.EPRuntime.SendEvent(new SupportBean_S0(1, "E1")); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E2", 2 } }); EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), fields, new Object[] { "E1", 1 }); SendEvent("E1", 3); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 3 }, new Object[] { "E2", 2 } }); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1", 3 }); SendEvent("E1", 99); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 3 }, new Object[] { "E2", 2 } }); Assert.IsFalse(_listener.IsInvoked); SendEvent("E3", 3); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 3 }, new Object[] { "E2", 2 }, new Object[] { "E3", 3 } }); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E3", 3 }); SendEvent("E3", 98); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", 3 }, new Object[] { "E2", 2 }, new Object[] { "E3", 3 } }); Assert.IsFalse(_listener.IsInvoked); }
private void RunAssertionFirstUniqueAndLengthOnDelete(EPServiceProvider epService) { EPStatement nwstmt = epService.EPAdministrator.CreateEPL("create window MyWindowOne#firstunique(TheString)#firstlength(3) as SupportBean"); epService.EPAdministrator.CreateEPL("insert into MyWindowOne select * from SupportBean"); epService.EPAdministrator.CreateEPL("on SupportBean_S0 delete from MyWindowOne where TheString = p00"); EPStatement stmt = epService.EPAdministrator.CreateEPL("select irstream * from MyWindowOne"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var fields = new string[] { "TheString", "IntPrimitive" }; SendEvent(epService, "E1", 1); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 } }); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1 }); SendEvent(epService, "E1", 99); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 } }); Assert.IsFalse(listener.IsInvoked); SendEvent(epService, "E2", 2); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } }); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2", 2 }); epService.EPRuntime.SendEvent(new SupportBean_S0(1, "E1")); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 2 } }); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E1", 1 }); SendEvent(epService, "E1", 3); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 3 }, new object[] { "E2", 2 } }); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 3 }); SendEvent(epService, "E1", 99); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 3 }, new object[] { "E2", 2 } }); Assert.IsFalse(listener.IsInvoked); SendEvent(epService, "E3", 3); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 3 }, new object[] { "E2", 2 }, new object[] { "E3", 3 } }); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E3", 3 }); SendEvent(epService, "E3", 98); EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 3 }, new object[] { "E2", 2 }, new object[] { "E3", 3 } }); Assert.IsFalse(listener.IsInvoked); epService.EPAdministrator.DestroyAllStatements(); }
public void TestHavingSum() { var stmt = "select irstream sum(myEvent.IntPrimitive) as mysum from pattern [every myEvent=" + typeof(SupportBean).FullName + "] having sum(myEvent.IntPrimitive) = 2"; var selectTestView = _epService.EPAdministrator.CreateEPL(stmt); selectTestView.AddListener(_listener); SendEvent(1); Assert.IsFalse(_listener.IsInvoked); SendEvent(1); Assert.AreEqual(2, _listener.AssertOneGetNewAndReset().Get("mysum")); SendEvent(1); Assert.AreEqual(2, _listener.AssertOneGetOldAndReset().Get("mysum")); }
private void RunAssertionCountHaving(EPServiceProvider epService) { string theEvent = typeof(SupportBean).FullName; string statementText = "select irstream sum(IntPrimitive) as mysum from " + theEvent + " having sum(IntPrimitive) = 2"; EPStatement stmt = epService.EPAdministrator.CreateEPL(statementText); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendEvent(epService); Assert.IsFalse(listener.GetAndClearIsInvoked()); SendEvent(epService); Assert.AreEqual(2, listener.AssertOneGetNewAndReset().Get("mysum")); SendEvent(epService); Assert.AreEqual(2, listener.AssertOneGetOldAndReset().Get("mysum")); stmt.Dispose(); }
private void RunAssertionHavingSum(EPServiceProvider epService) { string epl = "select irstream sum(myEvent.IntPrimitive) as mysum from pattern [every myEvent=" + typeof(SupportBean).FullName + "] having sum(myEvent.IntPrimitive) = 2"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendEvent(epService, 1); Assert.IsFalse(listener.IsInvoked); SendEvent(epService, 1); Assert.AreEqual(2, listener.AssertOneGetNewAndReset().Get("mysum")); SendEvent(epService, 1); Assert.AreEqual(2, listener.AssertOneGetOldAndReset().Get("mysum")); }
private void RunAssertionStartEagerForceUpdate(EPServiceProvider epService) { SendTimer(epService, 1000); EPStatement stmt = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#time_batch(1, \"START_EAGER,FORCE_UPDATE\")"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendTimer(epService, 1999); Assert.IsFalse(listener.GetAndClearIsInvoked()); SendTimer(epService, 2000); Assert.IsTrue(listener.GetAndClearIsInvoked()); SendTimer(epService, 2999); Assert.IsFalse(listener.GetAndClearIsInvoked()); SendTimer(epService, 3000); Assert.IsTrue(listener.GetAndClearIsInvoked()); listener.Reset(); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); Assert.IsFalse(listener.GetAndClearIsInvoked()); SendTimer(epService, 4000); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "TheString".Split(','), new object[] { "E1" }); SendTimer(epService, 5000); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), "TheString".Split(','), new object[] { "E1" }); SendTimer(epService, 5999); Assert.IsFalse(listener.GetAndClearIsInvoked()); SendTimer(epService, 6000); Assert.IsTrue(listener.GetAndClearIsInvoked()); SendTimer(epService, 7000); Assert.IsTrue(listener.GetAndClearIsInvoked()); stmt.Dispose(); }
private void RunAssertionJoinBetweenSameNamed(EPServiceProvider epService) { var fields = new string[] { "a0", "b0", "a1", "b1" }; // create window string stmtTextCreateOne = "create window MyWindowJSN#keepall as select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName; EPStatement stmtCreateOne = epService.EPAdministrator.CreateEPL(stmtTextCreateOne); var listenerWindow = new SupportUpdateListener(); stmtCreateOne.Events += listenerWindow.Update; // create delete stmt string stmtTextDelete = "on " + typeof(SupportMarketDataBean).FullName + " delete from MyWindowJSN where symbol = a"; epService.EPAdministrator.CreateEPL(stmtTextDelete); // create insert into string stmtTextInsert = "insert into MyWindowJSN select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName; epService.EPAdministrator.CreateEPL(stmtTextInsert); // create consumers string stmtTextSelectOne = "select irstream s0.a as a0, s0.b as b0, s1.a as a1, s1.b as b1 " + " from MyWindowJSN as s0," + "MyWindowJSN as s1 where s0.a = s1.a"; EPStatement stmtSelectOne = epService.EPAdministrator.CreateEPL(stmtTextSelectOne); var listenerStmtOne = new SupportUpdateListener(); stmtSelectOne.Events += listenerStmtOne.Update; SendSupportBean(epService, "E1", 1); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1, "E1", 1 }); SendSupportBean(epService, "E2", 2); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E2", 2, "E2", 2 }); SendMarketBean(epService, "E1", 1); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetOldAndReset(), fields, new object[] { "E1", 1, "E1", 1 }); SendMarketBean(epService, "E0", 0); Assert.IsFalse(listenerStmtOne.IsInvoked); }
public void TestStartEagerForceUpdate() { SendTimer(1000); EPStatement stmt = _epService.EPAdministrator.CreateEPL("select irstream * from SupportBean.win:time_batch(1, \"START_EAGER,FORCE_UPDATE\")"); stmt.Events += _listener.Update; SendTimer(1999); Assert.IsFalse(_listener.GetAndClearIsInvoked()); SendTimer(2000); Assert.IsTrue(_listener.GetAndClearIsInvoked()); SendTimer(2999); Assert.IsFalse(_listener.GetAndClearIsInvoked()); SendTimer(3000); Assert.IsTrue(_listener.GetAndClearIsInvoked()); _listener.Reset(); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); Assert.IsFalse(_listener.GetAndClearIsInvoked()); SendTimer(4000); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "TheString".Split(','), new Object[] { "E1" }); SendTimer(5000); EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), "TheString".Split(','), new Object[] { "E1" }); SendTimer(5999); Assert.IsFalse(_listener.GetAndClearIsInvoked()); SendTimer(6000); Assert.IsTrue(_listener.GetAndClearIsInvoked()); SendTimer(7000); Assert.IsTrue(_listener.GetAndClearIsInvoked()); }
private void TryAssertionSum(EPServiceProvider epService, SupportUpdateListener listener, EPStatement stmt) { // assert select result type Assert.AreEqual(typeof(string), stmt.EventType.GetPropertyType("symbol")); Assert.AreEqual(typeof(long?), stmt.EventType.GetPropertyType("volume").GetBoxedType()); Assert.AreEqual(typeof(double?), stmt.EventType.GetPropertyType("mySum").GetBoxedType()); string[] fields = "symbol,volume,mySum".Split(','); SendEvent(epService, SYMBOL_DELL, 10000, 49); Assert.IsFalse(listener.IsInvoked); SendEvent(epService, SYMBOL_DELL, 20000, 54); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { SYMBOL_DELL, 20000L, 103d }); SendEvent(epService, SYMBOL_IBM, 1000, 10); Assert.IsFalse(listener.IsInvoked); SendEvent(epService, SYMBOL_IBM, 5000, 20); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { SYMBOL_DELL, 10000L, 54d }); SendEvent(epService, SYMBOL_IBM, 6000, 5); Assert.IsFalse(listener.IsInvoked); }
private void RunAssertion(EPStatement selectTestView) { // assert select result type Assert.AreEqual(typeof(string), selectTestView.EventType.GetPropertyType("Symbol")); Assert.AreEqual(typeof(long?), selectTestView.EventType.GetPropertyType("Volume")); Assert.AreEqual(typeof(double?), selectTestView.EventType.GetPropertyType("mySum")); string[] fields = "Symbol,Volume,mySum".Split(','); SendEvent(SYMBOL_DELL, 10000, 49); Assert.IsFalse(_testListener.IsInvoked); SendEvent(SYMBOL_DELL, 20000, 54); EPAssertionUtil.AssertProps(_testListener.AssertOneGetNewAndReset(), fields, new object[] { SYMBOL_DELL, 20000L, 103d }); SendEvent(SYMBOL_IBM, 1000, 10); Assert.IsFalse(_testListener.IsInvoked); SendEvent(SYMBOL_IBM, 5000, 20); EPAssertionUtil.AssertProps(_testListener.AssertOneGetOldAndReset(), fields, new object[] { SYMBOL_DELL, 10000L, 54d }); SendEvent(SYMBOL_IBM, 6000, 5); Assert.IsFalse(_testListener.IsInvoked); }
private void RunAssertionVariable(EPServiceProvider epService) { epService.EPRuntime.SendEvent(new CurrentTimeEvent(0)); epService.EPAdministrator.CreateEPL("create variable bool KEEP = true"); var fields = new[] { "TheString" }; EPStatement stmt = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#expr(KEEP)"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000)); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E1" } }); epService.EPRuntime.SetVariableValue("KEEP", false); EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E1" } }); listener.Reset(); epService.EPRuntime.SendEvent(new CurrentTimeEvent(1001)); EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E1" }); Assert.IsFalse(stmt.HasFirst()); epService.EPRuntime.SendEvent(new SupportBean("E2", 2)); EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { "E2" }); EPAssertionUtil.AssertProps(listener.LastOldData[0], fields, new object[] { "E2" }); listener.Reset(); Assert.IsFalse(stmt.HasFirst()); epService.EPRuntime.SetVariableValue("KEEP", true); epService.EPRuntime.SendEvent(new SupportBean("E3", 3)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E3" }); EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E3" } }); stmt.Stop(); }
public void TestRightOuterJoin() { var outerJoinView = SetupStatement("right"); // Send S0 events, no events expected SendEvent(_eventsS0[0]); SendEvent(_eventsS0[1]); Assert.IsFalse(_listener.IsInvoked); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, null); // Send S1[2] SendEvent(_eventsS1[2]); var theEvent = _listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, null, null, 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new object[][] { new object[] { null, null, 202, "2" } }); // Send S0[2] events, joined event expected SendEvent(_eventsS0[2]); theEvent = _listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 102, "2", 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new object[][] { new object[] { 102, "2", 202, "2" } }); // Send S1[3] SendEvent(_eventsS1[3]); theEvent = _listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, null, null, 203, "3"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new object[][] { new object[] { 102, "2", 202, "2" }, new object[] { null, null, 203, "3" } }); // Send some more S0 events SendEvent(_eventsS0[3]); theEvent = _listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 103, "3", 203, "3"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new object[][] { new object[] { 102, "2", 202, "2" }, new object[] { 103, "3", 203, "3" } }); // Send some more S0 events SendEvent(_eventsS0[4]); Assert.IsFalse(_listener.IsInvoked); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new object[][] { new object[] { 102, "2", 202, "2" }, new object[] { 103, "3", 203, "3" } }); // Push S0[2] out of the window SendEvent(_eventsS0[5]); theEvent = _listener.AssertOneGetOldAndReset(); CompareEvent(theEvent, 102, "2", 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new object[][] { new object[] { null, null, 202, "2" }, new object[] { 103, "3", 203, "3" } }); // Some more S1 events SendEvent(_eventsS1[6]); CompareEvent(_listener.AssertOneGetNewAndReset(), null, null, 206, "6"); SendEvent(_eventsS1[7]); CompareEvent(_listener.AssertOneGetNewAndReset(), null, null, 207, "7"); SendEvent(_eventsS1[8]); CompareEvent(_listener.AssertOneGetNewAndReset(), null, null, 208, "8"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new object[][] { new object[] { null, null, 202, "2" }, new object[] { 103, "3", 203, "3" }, new object[] { null, null, 206, "6" }, new object[] { null, null, 207, "7" }, new object[] { null, null, 208, "8" } }); // Push S1[2] out of the window SendEvent(_eventsS1[9]); var oldEvent = _listener.LastOldData[0]; var newEvent = _listener.LastNewData[0]; CompareEvent(oldEvent, null, null, 202, "2"); CompareEvent(newEvent, null, null, 209, "9"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new object[][] { new object[] { 103, "3", 203, "3" }, new object[] { null, null, 206, "6" }, new object[] { null, null, 207, "7" }, new object[] { null, null, 208, "8" }, new object[] { null, null, 209, "9" } }); }
public void TestOnDelete() { EPStatement consumerOne = _epService.EPAdministrator.CreateEPL("select irstream * from RevQuote"); consumerOne.Events += _listenerOne.Update; _epService.EPAdministrator.CreateEPL("on SupportBean(IntPrimitive=2) as sb delete from RevQuote where TheString = P2"); Log.Debug("a00"); _epService.EPRuntime.SendEvent(new SupportRevisionFull("a", "a00", "a10", "a20", "a30", "a40", "a50")); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), _fields, new Object[] { "a", "a00", "a10", "a20", "a30", "a40", "a50" }); _epService.EPRuntime.SendEvent(new SupportDeltaThree("x", "03", "41")); Assert.IsFalse(_listenerOne.IsInvoked); _epService.EPAdministrator.CreateEPL("on SupportBean(IntPrimitive=3) as sb delete from RevQuote where TheString = P3"); Log.Debug("b00"); _epService.EPRuntime.SendEvent(new SupportRevisionFull("b", "b00", "b10", "b20", "b30", "b40", "b50")); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), _fields, new Object[] { "b", "b00", "b10", "b20", "b30", "b40", "b50" }); Log.Debug("a01"); _epService.EPRuntime.SendEvent(new SupportDeltaThree("a", "a01", "a41")); EPAssertionUtil.AssertProps(_listenerOne.LastNewData[0], _fields, new Object[] { "a", "a01", "a10", "a20", "a30", "a41", "a50" }); EPAssertionUtil.AssertProps(_listenerOne.LastOldData[0], _fields, new Object[] { "a", "a00", "a10", "a20", "a30", "a40", "a50" }); _listenerOne.Reset(); Log.Debug("c00"); _epService.EPRuntime.SendEvent(new SupportRevisionFull("c", "c00", "c10", "c20", "c30", "c40", "c50")); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), _fields, new Object[] { "c", "c00", "c10", "c20", "c30", "c40", "c50" }); _epService.EPAdministrator.CreateEPL("on SupportBean(IntPrimitive=0) as sb delete from RevQuote where TheString = P0"); Log.Debug("c11"); _epService.EPRuntime.SendEvent(new SupportDeltaFive("c", "c11", "c51")); EPAssertionUtil.AssertProps(_listenerOne.LastNewData[0], _fields, new Object[] { "c", "c00", "c11", "c20", "c30", "c40", "c51" }); EPAssertionUtil.AssertProps(_listenerOne.LastOldData[0], _fields, new Object[] { "c", "c00", "c10", "c20", "c30", "c40", "c50" }); _listenerOne.Reset(); _epService.EPAdministrator.CreateEPL("on SupportBean(IntPrimitive=1) as sb delete from RevQuote where TheString = P1"); Log.Debug("d00"); _epService.EPRuntime.SendEvent(new SupportRevisionFull("d", "d00", "d10", "d20", "d30", "d40", "d50")); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), _fields, new Object[] { "d", "d00", "d10", "d20", "d30", "d40", "d50" }); Log.Debug("d01"); _epService.EPRuntime.SendEvent(new SupportDeltaFour("d", "d01", "d21", "d51")); EPAssertionUtil.AssertProps(_listenerOne.LastNewData[0], _fields, new Object[] { "d", "d01", "d10", "d21", "d30", "d40", "d51" }); EPAssertionUtil.AssertProps(_listenerOne.LastOldData[0], _fields, new Object[] { "d", "d00", "d10", "d20", "d30", "d40", "d50" }); _listenerOne.Reset(); EPAssertionUtil.AssertPropsPerRow(_stmtCreateWin.GetEnumerator(), _fields, new Object[][] { new Object[] { "b", "b00", "b10", "b20", "b30", "b40", "b50" }, new Object[] { "a", "a01", "a10", "a20", "a30", "a41", "a50" }, new Object[] { "c", "c00", "c11", "c20", "c30", "c40", "c51" }, new Object[] { "d", "d01", "d10", "d21", "d30", "d40", "d51" } }); _epService.EPAdministrator.CreateEPL("on SupportBean(IntPrimitive=4) as sb delete from RevQuote where TheString = P4"); _epService.EPRuntime.SendEvent(new SupportBean("abc", 1)); Assert.IsFalse(_listenerOne.IsInvoked); Log.Debug("delete b"); _epService.EPRuntime.SendEvent(new SupportBean("b40", 4)); // delete b EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetOldAndReset(), _fields, new Object[] { "b", "b00", "b10", "b20", "b30", "b40", "b50" }); EPAssertionUtil.AssertPropsPerRow(_stmtCreateWin.GetEnumerator(), _fields, new Object[][] { new Object[] { "a", "a01", "a10", "a20", "a30", "a41", "a50" }, new Object[] { "c", "c00", "c11", "c20", "c30", "c40", "c51" }, new Object[] { "d", "d01", "d10", "d21", "d30", "d40", "d51" } }); Log.Debug("delete d"); _epService.EPRuntime.SendEvent(new SupportBean("d21", 2)); // delete d EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetOldAndReset(), _fields, new Object[] { "d", "d01", "d10", "d21", "d30", "d40", "d51" }); EPAssertionUtil.AssertPropsPerRow(_stmtCreateWin.GetEnumerator(), _fields, new Object[][] { new Object[] { "a", "a01", "a10", "a20", "a30", "a41", "a50" }, new Object[] { "c", "c00", "c11", "c20", "c30", "c40", "c51" } }); Log.Debug("delete a"); _epService.EPRuntime.SendEvent(new SupportBean("a30", 3)); // delete a EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetOldAndReset(), _fields, new Object[] { "a", "a01", "a10", "a20", "a30", "a41", "a50" }); EPAssertionUtil.AssertPropsPerRow(_stmtCreateWin.GetEnumerator(), _fields, new Object[][] { new Object[] { "c", "c00", "c11", "c20", "c30", "c40", "c51" } }); Log.Debug("delete c"); _epService.EPRuntime.SendEvent(new SupportBean("c11", 1)); // delete c EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetOldAndReset(), _fields, new Object[] { "c", "c00", "c11", "c20", "c30", "c40", "c51" }); EPAssertionUtil.AssertPropsPerRow(_stmtCreateWin.GetEnumerator(), _fields, null); _epService.EPRuntime.SendEvent(new SupportBean("c11", 1)); Assert.IsFalse(_listenerOne.IsInvoked); }
public void TestLeftOuterJoin() { EPStatement outerJoinView = SetupStatement("left"); // Send S1 events, no events expected SendEvent(_eventsS1[0]); SendEvent(_eventsS1[1]); SendEvent(_eventsS1[3]); Assert.IsNull(_listener.LastNewData); // No events expected EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, null); // Send S0 event, expect event back from outer join SendEvent(_eventsS0[2]); EventBean theEvent = _listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 102, "2", null, null); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new[] { new Object[] { 102, "2", null, null } }); // Send S1 event matching S0, expect event back SendEvent(_eventsS1[2]); theEvent = _listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 102, "2", 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new[] { new Object[] { 102, "2", 202, "2" } }); // Send some more unmatched events SendEvent(_eventsS1[4]); SendEvent(_eventsS1[5]); SendEvent(_eventsS1[6]); Assert.IsNull(_listener.LastNewData); // No events expected EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new[] { new Object[] { 102, "2", 202, "2" } }); // Send event, expect a join result SendEvent(_eventsS0[5]); theEvent = _listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 105, "5", 205, "5"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new[] { new Object[] { 102, "2", 202, "2" }, new Object[] { 105, "5", 205, "5" } }); // Let S1[2] go out of the window (lenght 5), expected old join event SendEvent(_eventsS1[7]); SendEvent(_eventsS1[8]); theEvent = _listener.AssertOneGetOldAndReset(); CompareEvent(theEvent, 102, "2", 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new[] { new Object[] { 102, "2", null, null }, new Object[] { 105, "5", 205, "5" } }); // S0[9] should generate an outer join event SendEvent(_eventsS0[9]); theEvent = _listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 109, "9", null, null); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new[] { new Object[] { 102, "2", null, null }, new Object[] { 109, "9", null, null }, new Object[] { 105, "5", 205, "5" } }); // S0[2] Should leave the window (length 3), should get OLD and NEW event SendEvent(_eventsS0[10]); EventBean oldEvent = _listener.LastOldData[0]; EventBean newEvent = _listener.LastNewData[0]; CompareEvent(oldEvent, 102, "2", null, null); // S1[2] has left the window already CompareEvent(newEvent, 110, "10", null, null); EPAssertionUtil.AssertPropsPerRowAnyOrder(outerJoinView.GetEnumerator(), Fields, new[] { new Object[] { 110, "10", null, null }, new Object[] { 109, "9", null, null }, new Object[] { 105, "5", 205, "5" } }); }
private void RunAssertionLeftOuterJoin(EPServiceProvider epService) { var listener = new SupportUpdateListener(); EPStatement stmt = SetupStatement(epService, listener, "left"); // Send S1 events, no events expected SendEvent(EVENTS_S1[0], epService); SendEvent(EVENTS_S1[1], epService); SendEvent(EVENTS_S1[3], epService); Assert.IsNull(listener.LastNewData); // No events expected EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, null); // Send S0 event, expect event back from outer join SendEvent(EVENTS_S0[2], epService); EventBean theEvent = listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 102, "2", null, null); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", null, null } }); // Send S1 event matching S0, expect event back SendEvent(EVENTS_S1[2], epService); theEvent = listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 102, "2", 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", 202, "2" } }); // Send some more unmatched events SendEvent(EVENTS_S1[4], epService); SendEvent(EVENTS_S1[5], epService); SendEvent(EVENTS_S1[6], epService); Assert.IsNull(listener.LastNewData); // No events expected EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", 202, "2" } }); // Send event, expect a join result SendEvent(EVENTS_S0[5], epService); theEvent = listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 105, "5", 205, "5"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", 202, "2" }, new object[] { 105, "5", 205, "5" } }); // Let S1[2] go out of the window (lenght 5), expected old join event SendEvent(EVENTS_S1[7], epService); SendEvent(EVENTS_S1[8], epService); theEvent = listener.AssertOneGetOldAndReset(); CompareEvent(theEvent, 102, "2", 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", null, null }, new object[] { 105, "5", 205, "5" } }); // S0[9] should generate an outer join event SendEvent(EVENTS_S0[9], epService); theEvent = listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 109, "9", null, null); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", null, null }, new object[] { 109, "9", null, null }, new object[] { 105, "5", 205, "5" } }); // S0[2] Should leave the window (length 3), should get OLD and NEW event SendEvent(EVENTS_S0[10], epService); EventBean oldEvent = listener.LastOldData[0]; EventBean newEvent = listener.LastNewData[0]; CompareEvent(oldEvent, 102, "2", null, null); // S1[2] has left the window already CompareEvent(newEvent, 110, "10", null, null); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 110, "10", null, null }, new object[] { 109, "9", null, null }, new object[] { 105, "5", 205, "5" } }); }
private void RunAssertionRightOuterJoin(EPServiceProvider epService) { var listener = new SupportUpdateListener(); EPStatement stmt = SetupStatement(epService, listener, "right"); // Send S0 events, no events expected SendEvent(EVENTS_S0[0], epService); SendEvent(EVENTS_S0[1], epService); Assert.IsFalse(listener.IsInvoked); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, null); // Send S1[2] SendEvent(EVENTS_S1[2], epService); EventBean theEvent = listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, null, null, 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { null, null, 202, "2" } }); // Send S0[2] events, joined event expected SendEvent(EVENTS_S0[2], epService); theEvent = listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 102, "2", 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", 202, "2" } }); // Send S1[3] SendEvent(EVENTS_S1[3], epService); theEvent = listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, null, null, 203, "3"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", 202, "2" }, new object[] { null, null, 203, "3" } }); // Send some more S0 events SendEvent(EVENTS_S0[3], epService); theEvent = listener.AssertOneGetNewAndReset(); CompareEvent(theEvent, 103, "3", 203, "3"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", 202, "2" }, new object[] { 103, "3", 203, "3" } }); // Send some more S0 events SendEvent(EVENTS_S0[4], epService); Assert.IsFalse(listener.IsInvoked); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 102, "2", 202, "2" }, new object[] { 103, "3", 203, "3" } }); // Push S0[2] out of the window SendEvent(EVENTS_S0[5], epService); theEvent = listener.AssertOneGetOldAndReset(); CompareEvent(theEvent, 102, "2", 202, "2"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { null, null, 202, "2" }, new object[] { 103, "3", 203, "3" } }); // Some more S1 events SendEvent(EVENTS_S1[6], epService); CompareEvent(listener.AssertOneGetNewAndReset(), null, null, 206, "6"); SendEvent(EVENTS_S1[7], epService); CompareEvent(listener.AssertOneGetNewAndReset(), null, null, 207, "7"); SendEvent(EVENTS_S1[8], epService); CompareEvent(listener.AssertOneGetNewAndReset(), null, null, 208, "8"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { null, null, 202, "2" }, new object[] { 103, "3", 203, "3" }, new object[] { null, null, 206, "6" }, new object[] { null, null, 207, "7" }, new object[] { null, null, 208, "8" } }); // Push S1[2] out of the window SendEvent(EVENTS_S1[9], epService); EventBean oldEvent = listener.LastOldData[0]; EventBean newEvent = listener.LastNewData[0]; CompareEvent(oldEvent, null, null, 202, "2"); CompareEvent(newEvent, null, null, 209, "9"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), FIELDS, new object[][] { new object[] { 103, "3", 203, "3" }, new object[] { null, null, 206, "6" }, new object[] { null, null, 207, "7" }, new object[] { null, null, 208, "8" }, new object[] { null, null, 209, "9" } }); stmt.Dispose(); }
public void TestJoinNamedAndStream() { // create window var stmtTextCreate = "create window MyWindow.win:keepall() as select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName; var stmtCreate = _epService.EPAdministrator.CreateEPL(stmtTextCreate); stmtCreate.AddListener(_listenerWindow); // create delete stmt var stmtTextDelete = "on " + typeof(SupportBean_A).FullName + " delete from MyWindow where id = a"; _epService.EPAdministrator.CreateEPL(stmtTextDelete); // create insert into var stmtTextInsertOne = "insert into MyWindow select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName; _epService.EPAdministrator.CreateEPL(stmtTextInsertOne); // create consumer var fields = new string[] { "symbol", "a", "b" }; var stmtTextSelectOne = "select irstream symbol, a, b " + " from " + typeof(SupportMarketDataBean).FullName + ".win:length(10) as s0," + "MyWindow as s1 where s1.a = symbol"; var stmtSelectOne = _epService.EPAdministrator.CreateEPL(stmtTextSelectOne); stmtSelectOne.AddListener(_listenerStmtOne); EPAssertionUtil.AssertEqualsAnyOrder(stmtSelectOne.EventType.PropertyNames, new string[] { "symbol", "a", "b" }); Assert.AreEqual(typeof(string), stmtSelectOne.EventType.GetPropertyType("symbol")); Assert.AreEqual(typeof(string), stmtSelectOne.EventType.GetPropertyType("a")); Assert.AreEqual(typeof(int?), stmtSelectOne.EventType.GetPropertyType("b")); SendMarketBean("S1"); Assert.IsFalse(_listenerStmtOne.IsInvoked); SendSupportBean("S1", 1); EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "S1", "S1", 1 }); SendSupportBean_A("S1"); // deletes from window EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetOldAndReset(), fields, new object[] { "S1", "S1", 1 }); SendMarketBean("S1"); Assert.IsFalse(_listenerStmtOne.IsInvoked); SendSupportBean("S2", 2); Assert.IsFalse(_listenerStmtOne.IsInvoked); SendMarketBean("S2"); EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "S2", "S2", 2 }); SendSupportBean("S3", 3); SendSupportBean("S3", 4); Assert.IsFalse(_listenerStmtOne.IsInvoked); SendMarketBean("S3"); Assert.AreEqual(2, _listenerStmtOne.LastNewData.Length); _listenerStmtOne.Reset(); SendSupportBean_A("S3"); // deletes from window Assert.AreEqual(2, _listenerStmtOne.LastOldData.Length); _listenerStmtOne.Reset(); SendMarketBean("S3"); Assert.IsFalse(_listenerStmtOne.IsInvoked); }
private void RunAssertionStartStopDeleter(bool namedWindow) { SupportNamedWindowObserver observer = new SupportNamedWindowObserver(); NamedWindowLifecycleEvent theEvent; if (namedWindow) { _epService.NamedWindowMgmtService.AddObserver(observer); } // create window string stmtTextCreate = namedWindow ? "create window MyInfra.win:keepall() as select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName : "create table MyInfra(a string primary key, b int primary key)"; EPStatement stmtCreate = _epService.EPAdministrator.CreateEPL(stmtTextCreate); Assert.AreEqual(namedWindow ? StatementType.CREATE_WINDOW : StatementType.CREATE_TABLE, ((EPStatementSPI)stmtCreate).StatementMetadata.StatementType); stmtCreate.AddListener(_listenerWindow); if (namedWindow) { theEvent = observer.GetFirstAndReset(); Assert.AreEqual(NamedWindowLifecycleEvent.LifecycleEventType.CREATE, theEvent.EventType); Assert.AreEqual("MyInfra", theEvent.Name); } // stop and start, no consumers or deleters stmtCreate.Stop(); if (namedWindow) { theEvent = observer.GetFirstAndReset(); Assert.AreEqual(NamedWindowLifecycleEvent.LifecycleEventType.DESTROY, theEvent.EventType); Assert.AreEqual("MyInfra", theEvent.Name); } stmtCreate.Start(); if (namedWindow) { Assert.AreEqual(NamedWindowLifecycleEvent.LifecycleEventType.CREATE, observer.GetFirstAndReset().EventType); } // create delete stmt string stmtTextDelete = "on " + typeof(SupportBean_A).FullName + " delete from MyInfra"; EPStatement stmtDelete = _epService.EPAdministrator.CreateEPL(stmtTextDelete); // create insert into string stmtTextInsertOne = "insert into MyInfra select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName; _epService.EPAdministrator.CreateEPL(stmtTextInsertOne); // create consumer string[] fields = new string[] { "a", "b" }; string stmtTextSelect = "select irstream a, b from MyInfra as s1"; EPStatement stmtSelect = _epService.EPAdministrator.CreateEPL(stmtTextSelect); stmtSelect.AddListener(_listenerSelect); // send 1 event SendSupportBean("E1", 1); if (namedWindow) { EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1 }); EPAssertionUtil.AssertProps(_listenerSelect.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1 }); } else { Assert.IsFalse(_listenerWindow.IsInvoked); Assert.IsFalse(_listenerSelect.IsInvoked); } EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 } }); // Delete all events, 1 row expected SendSupportBean_A("A2"); if (namedWindow) { EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetOldAndReset(), fields, new object[] { "E1", 1 }); EPAssertionUtil.AssertProps(_listenerSelect.AssertOneGetOldAndReset(), fields, new object[] { "E1", 1 }); } EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, null); SendSupportBean("E2", 2); if (namedWindow) { EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E2", 2 }); EPAssertionUtil.AssertProps(_listenerSelect.AssertOneGetNewAndReset(), fields, new object[] { "E2", 2 }); } EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E2", 2 } }); // Stop the deleting statement stmtDelete.Stop(); SendSupportBean_A("A2"); Assert.IsFalse(_listenerWindow.IsInvoked); // Start the deleting statement stmtDelete.Start(); SendSupportBean_A("A3"); if (namedWindow) { EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetOldAndReset(), fields, new object[] { "E2", 2 }); EPAssertionUtil.AssertProps(_listenerSelect.AssertOneGetOldAndReset(), fields, new object[] { "E2", 2 }); } EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, null); SendSupportBean("E3", 3); if (namedWindow) { EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E3", 3 }); EPAssertionUtil.AssertProps(_listenerSelect.AssertOneGetNewAndReset(), fields, new object[] { "E3", 3 }); } EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E3", 3 } }); stmtDelete.Dispose(); SendSupportBean_A("A3"); Assert.IsFalse(_listenerWindow.IsInvoked); _epService.EPAdministrator.DestroyAllStatements(); _epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false); }
private void RunAssertionJoinNamedAndStream(EPServiceProvider epService) { // create window string stmtTextCreate = "create window MyWindowJNS#keepall as select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName; EPStatement stmtCreate = epService.EPAdministrator.CreateEPL(stmtTextCreate); var listenerWindow = new SupportUpdateListener(); stmtCreate.Events += listenerWindow.Update; // create delete stmt string stmtTextDelete = "on " + typeof(SupportBean_A).FullName + " delete from MyWindowJNS where id = a"; epService.EPAdministrator.CreateEPL(stmtTextDelete); // create insert into string stmtTextInsertOne = "insert into MyWindowJNS select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName; epService.EPAdministrator.CreateEPL(stmtTextInsertOne); // create consumer var fields = new string[] { "symbol", "a", "b" }; string stmtTextSelectOne = "select irstream symbol, a, b " + " from " + typeof(SupportMarketDataBean).FullName + "#length(10) as s0," + "MyWindowJNS as s1 where s1.a = symbol"; EPStatement stmtSelectOne = epService.EPAdministrator.CreateEPL(stmtTextSelectOne); var listener = new SupportUpdateListener(); stmtSelectOne.Events += listener.Update; EPAssertionUtil.AssertEqualsAnyOrder(stmtSelectOne.EventType.PropertyNames, new string[] { "symbol", "a", "b" }); Assert.AreEqual(typeof(string), stmtSelectOne.EventType.GetPropertyType("symbol")); Assert.AreEqual(typeof(string), stmtSelectOne.EventType.GetPropertyType("a")); Assert.AreEqual(typeof(int), stmtSelectOne.EventType.GetPropertyType("b")); SendMarketBean(epService, "S1"); Assert.IsFalse(listener.IsInvoked); SendSupportBean(epService, "S1", 1); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "S1", "S1", 1 }); SendSupportBean_A(epService, "S1"); // deletes from window EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "S1", "S1", 1 }); SendMarketBean(epService, "S1"); Assert.IsFalse(listener.IsInvoked); SendSupportBean(epService, "S2", 2); Assert.IsFalse(listener.IsInvoked); SendMarketBean(epService, "S2"); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "S2", "S2", 2 }); SendSupportBean(epService, "S3", 3); SendSupportBean(epService, "S3", 4); Assert.IsFalse(listener.IsInvoked); SendMarketBean(epService, "S3"); Assert.AreEqual(2, listener.LastNewData.Length); listener.Reset(); SendSupportBean_A(epService, "S3"); // deletes from window Assert.AreEqual(2, listener.LastOldData.Length); listener.Reset(); SendMarketBean(epService, "S3"); Assert.IsFalse(listener.IsInvoked); }
private void RunAssertionSubquerySelfCheck(bool namedWindow) { string[] fields = new string[] { "key", "value" }; // create window string stmtTextCreate = namedWindow ? "create window MyInfra.win:keepall() as select TheString as key, IntBoxed as value from " + typeof(SupportBean).FullName : "create table MyInfra (key string primary key, value int)"; EPStatement stmtCreate = epService.EPAdministrator.CreateEPL(stmtTextCreate); stmtCreate.AddListener(listenerWindow); // create insert into (not does insert if key already exists) string stmtTextInsertOne = "insert into MyInfra select TheString as key, IntBoxed as value from " + typeof(SupportBean).FullName + " as s0" + " where not exists (select * from MyInfra as win where win.key = s0.TheString)"; epService.EPAdministrator.CreateEPL(stmtTextInsertOne); SendSupportBean("E1", 1); if (namedWindow) { EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1 }); } else { Assert.IsFalse(listenerWindow.IsInvoked); } EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 } }); SendSupportBean("E2", 2); if (namedWindow) { EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E2", 2 }); } EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } }); SendSupportBean("E1", 3); Assert.IsFalse(listenerWindow.IsInvoked); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } }); SendSupportBean("E3", 4); if (namedWindow) { EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E3", 4 }); EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 }, new object[] { "E3", 4 } }); } else { EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 }, new object[] { "E3", 4 } }); } // Add delete string stmtTextDelete = "on " + typeof(SupportBean_A).FullName + " delete from MyInfra where key = id"; EPStatement stmtDelete = epService.EPAdministrator.CreateEPL(stmtTextDelete); stmtDelete.AddListener(listenerStmtDelete); // delete E2 epService.EPRuntime.SendEvent(new SupportBean_A("E2")); if (namedWindow) { EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetOldAndReset(), fields, new object[] { "E2", 2 }); } EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E3", 4 } }); SendSupportBean("E2", 5); if (namedWindow) { EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E2", 5 }); } EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E3", 4 }, new object[] { "E2", 5 } }); epService.EPAdministrator.DestroyAllStatements(); epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false); }
public void RunAssertionOnDeleteAndUpdate(bool namedWindow) { epService.EPAdministrator.CreateEPL("@Name('context') create context SegmentedByString " + "partition by TheString from SupportBean, p00 from SupportBean_S0, p10 from SupportBean_S1"); string[] fieldsNW = new string[] { "TheString", "IntPrimitive" }; string eplCreate = namedWindow ? "@Name('named window') context SegmentedByString create window MyInfra.win:keepall() as SupportBean" : "@Name('named window') context SegmentedByString create table MyInfra(TheString string primary key, IntPrimitive int primary key)"; epService.EPAdministrator.CreateEPL(eplCreate); string eplInsert = namedWindow ? "@Name('insert') insert into MyInfra select TheString, IntPrimitive from SupportBean" : "@Name('insert') context SegmentedByString insert into MyInfra select TheString, IntPrimitive from SupportBean"; epService.EPAdministrator.CreateEPL(eplInsert); epService.EPAdministrator.CreateEPL("@Name('selectit') context SegmentedByString select irstream * from MyInfra").AddListener(listenerSelect); // Delete testing EPStatement stmtDelete = epService.EPAdministrator.CreateEPL("@Name('on-delete') context SegmentedByString on SupportBean_S0 delete from MyInfra"); epService.EPRuntime.SendEvent(new SupportBean("G1", 1)); if (namedWindow) { EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fieldsNW, new object[] { "G1", 1 }); } else { Assert.IsFalse(listenerSelect.IsInvoked); } epService.EPRuntime.SendEvent(new SupportBean_S0(0, "G0")); epService.EPRuntime.SendEvent(new SupportBean_S0(0, "G2")); Assert.IsFalse(listenerSelect.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean_S0(0, "G1")); if (namedWindow) { EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetOldAndReset(), fieldsNW, new object[] { "G1", 1 }); } epService.EPRuntime.SendEvent(new SupportBean("G2", 20)); if (namedWindow) { EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fieldsNW, new object[] { "G2", 20 }); } epService.EPRuntime.SendEvent(new SupportBean("G3", 3)); if (namedWindow) { EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fieldsNW, new object[] { "G3", 3 }); } epService.EPRuntime.SendEvent(new SupportBean("G2", 21)); if (namedWindow) { EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fieldsNW, new object[] { "G2", 21 }); } epService.EPRuntime.SendEvent(new SupportBean_S0(0, "G2")); if (namedWindow) { EPAssertionUtil.AssertPropsPerRow(listenerSelect.LastOldData, fieldsNW, new object[][] { new object[] { "G2", 20 }, new object[] { "G2", 21 } }); } listenerSelect.Reset(); stmtDelete.Dispose(); // update testing EPStatement stmtUpdate = epService.EPAdministrator.CreateEPL("@Name('on-merge') context SegmentedByString on SupportBean_S0 update MyInfra set IntPrimitive = IntPrimitive + 1"); epService.EPRuntime.SendEvent(new SupportBean("G4", 4)); if (namedWindow) { EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fieldsNW, new object[] { "G4", 4 }); } epService.EPRuntime.SendEvent(new SupportBean_S0(0, "G0")); epService.EPRuntime.SendEvent(new SupportBean_S0(0, "G1")); epService.EPRuntime.SendEvent(new SupportBean_S0(0, "G2")); Assert.IsFalse(listenerSelect.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean_S0(0, "G4")); if (namedWindow) { EPAssertionUtil.AssertProps(listenerSelect.LastNewData[0], fieldsNW, new object[] { "G4", 5 }); EPAssertionUtil.AssertProps(listenerSelect.LastOldData[0], fieldsNW, new object[] { "G4", 4 }); listenerSelect.Reset(); } epService.EPRuntime.SendEvent(new SupportBean("G5", 5)); if (namedWindow) { EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fieldsNW, new object[] { "G5", 5 }); } epService.EPRuntime.SendEvent(new SupportBean_S0(0, "G5")); if (namedWindow) { EPAssertionUtil.AssertProps(listenerSelect.LastNewData[0], fieldsNW, new object[] { "G5", 6 }); EPAssertionUtil.AssertProps(listenerSelect.LastOldData[0], fieldsNW, new object[] { "G5", 5 }); listenerSelect.Reset(); } stmtUpdate.Dispose(); epService.EPAdministrator.DestroyAllStatements(); epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false); }
private void RunAssertionJoinSingleInsertOneWindow(EPServiceProvider epService) { var fields = new string[] { "a1", "b1", "a2", "b2" }; // create window string stmtTextCreateOne = "create window MyWindowJSIOne#keepall as select TheString as a1, IntPrimitive as b1 from " + typeof(SupportBean).FullName; EPStatement stmtCreateOne = epService.EPAdministrator.CreateEPL(stmtTextCreateOne); var listenerWindow = new SupportUpdateListener(); stmtCreateOne.Events += listenerWindow.Update; // create window string stmtTextCreateTwo = "create window MyWindowJSITwo#keepall as select TheString as a2, IntPrimitive as b2 from " + typeof(SupportBean).FullName; EPStatement stmtCreateTwo = epService.EPAdministrator.CreateEPL(stmtTextCreateTwo); var listenerWindowTwo = new SupportUpdateListener(); stmtCreateTwo.Events += listenerWindowTwo.Update; // create delete stmt string stmtTextDelete = "on " + typeof(SupportMarketDataBean).FullName + "(volume=1) delete from MyWindowJSIOne where symbol = a1"; epService.EPAdministrator.CreateEPL(stmtTextDelete); stmtTextDelete = "on " + typeof(SupportMarketDataBean).FullName + "(volume=0) delete from MyWindowJSITwo where symbol = a2"; epService.EPAdministrator.CreateEPL(stmtTextDelete); // create insert into string stmtTextInsert = "insert into MyWindowJSIOne select TheString as a1, IntPrimitive as b1 from " + typeof(SupportBean).FullName + "(BoolPrimitive = true)"; epService.EPAdministrator.CreateEPL(stmtTextInsert); stmtTextInsert = "insert into MyWindowJSITwo select TheString as a2, IntPrimitive as b2 from " + typeof(SupportBean).FullName + "(BoolPrimitive = false)"; epService.EPAdministrator.CreateEPL(stmtTextInsert); // create consumers string stmtTextSelectOne = "select irstream a1, b1, a2, b2 " + " from MyWindowJSIOne as s0," + "MyWindowJSITwo as s1 where s0.a1 = s1.a2"; EPStatement stmtSelectOne = epService.EPAdministrator.CreateEPL(stmtTextSelectOne); var listenerStmtOne = new SupportUpdateListener(); stmtSelectOne.Events += listenerStmtOne.Update; SendSupportBean(epService, true, "S0", 1); Assert.IsFalse(listenerStmtOne.IsInvoked); SendSupportBean(epService, false, "S0", 2); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "S0", 1, "S0", 2 }); SendSupportBean(epService, false, "S1", 3); Assert.IsFalse(listenerStmtOne.IsInvoked); SendSupportBean(epService, true, "S1", 4); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "S1", 4, "S1", 3 }); SendSupportBean(epService, true, "S1", 5); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "S1", 5, "S1", 3 }); SendSupportBean(epService, false, "S1", 6); Assert.AreEqual(2, listenerStmtOne.LastNewData.Length); listenerStmtOne.Reset(); // delete and insert back in SendMarketBean(epService, "S0", 0); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetOldAndReset(), fields, new object[] { "S0", 1, "S0", 2 }); SendSupportBean(epService, false, "S0", 7); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "S0", 1, "S0", 7 }); // delete and insert back in SendMarketBean(epService, "S0", 1); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetOldAndReset(), fields, new object[] { "S0", 1, "S0", 7 }); SendSupportBean(epService, true, "S0", 8); EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "S0", 8, "S0", 7 }); }