private void RunAssertionTimeBatchRowPerGroupNoJoin(EPServiceProvider epService) { SendTimer(epService, 0); string stmtText = "select irstream symbol, sum(price) as sumPrice from MarketData#time_batch(1 sec) group by symbol order by symbol asc"; EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtText); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; // send first batch SendMDEvent(epService, "DELL", 10, 0L); SendMDEvent(epService, "IBM", 15, 0L); SendMDEvent(epService, "DELL", 20, 0L); SendTimer(epService, 1000); EventBean[] newEvents = listener.LastNewData; Assert.AreEqual(2, newEvents.Length); AssertEvent(newEvents[0], "DELL", 30d); AssertEvent(newEvents[1], "IBM", 15d); // send second batch SendMDEvent(epService, "IBM", 20, 600L); SendTimer(epService, 2000); newEvents = listener.LastNewData; Assert.AreEqual(2, newEvents.Length); AssertEvent(newEvents[0], "DELL", null); AssertEvent(newEvents[1], "IBM", 20d); EventBean[] oldEvents = listener.LastOldData; Assert.AreEqual(2, oldEvents.Length); AssertEvent(oldEvents[0], "DELL", 30d); AssertEvent(oldEvents[1], "IBM", 15d); stmt.Dispose(); }
public void TestAndWithEveryAndTerminationOptimization() { // When all other sub-expressions to an AND are gone, // then there is no need to retain events of the subexpression still active EPServiceProvider engine = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration()); engine.EPAdministrator.Configuration.AddEventType <SupportBean_A>(); engine.EPAdministrator.Configuration.AddEventType <SupportBean_B>(); String epl = "select * from pattern [a=SupportBean_A and every b=SupportBean_B]"; EPStatement stmt = engine.EPAdministrator.CreateEPL(epl); engine.EPRuntime.SendEvent(new SupportBean_A("A1")); for (int i = 0; i < 10; i++) { engine.EPRuntime.SendEvent(new SupportBean_B("B" + i)); } SupportUpdateListener listener = new SupportUpdateListener(); stmt.AddListener(listener); engine.EPRuntime.SendEvent(new SupportBean_B("B_last")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a.id,b.id".Split(','), new Object[] { "A1", "B_last" }); }
private void RunAssertionLateInitialize(EPServiceProvider epService) { epService.EPAdministrator.CreateEPL("create window MyWindowTwo#keepall as select * from SupportBean"); epService.EPAdministrator.CreateEPL("insert into MyWindowTwo select * from SupportBean"); epService.EPRuntime.SendEvent(new SupportBean("E1", 10)); epService.EPRuntime.SendEvent(new SupportBean("E2", 20)); string[] fields = "firststring,windowstring,laststring".Split(','); string epl = "select " + "first(TheString) as firststring, " + "window(TheString) as windowstring, " + "last(TheString) as laststring " + "from MyWindowTwo"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("E3", 30)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new[] { "E1", Split("E1,E2,E3"), "E3" }); epService.EPAdministrator.DestroyAllStatements(); }
public void TestStaggeredWithWildcard() { var statementOne = "insert into streamA select * from " + typeof(SupportBeanSimple).FullName + ".win:length(5)"; var statementTwo = "insert into streamB select *, MyInt+MyInt as summed, myString||myString as concat from streamA.win:length(5)"; var statementThree = "insert into streamC select * from streamB.win:length(5)"; var listenerOne = new SupportUpdateListener(); var listenerTwo = new SupportUpdateListener(); var listenerThree = new SupportUpdateListener(); _epService.EPAdministrator.CreateEPL(statementOne).Events += listenerOne.Update; _epService.EPAdministrator.CreateEPL(statementTwo).Events += listenerTwo.Update; _epService.EPAdministrator.CreateEPL(statementThree).Events += listenerThree.Update; SendSimpleEvent("one", 1); AssertSimple(listenerOne, "one", 1, null, 0); AssertSimple(listenerTwo, "one", 1, "oneone", 2); AssertSimple(listenerThree, "one", 1, "oneone", 2); SendSimpleEvent("two", 2); AssertSimple(listenerOne, "two", 2, null, 0); AssertSimple(listenerTwo, "two", 2, "twotwo", 4); AssertSimple(listenerThree, "two", 2, "twotwo", 4); }
private void RunAssertionCoalesceLong_OM(EPServiceProvider epService) { string epl = "select coalesce(LongBoxed,IntBoxed,ShortBoxed) as result" + " from " + typeof(SupportBean).FullName + "#length(1000)"; var model = new EPStatementObjectModel(); model.SelectClause = SelectClause.Create().Add(Expressions.Coalesce( "LongBoxed", "IntBoxed", "ShortBoxed"), "result"); model.FromClause = FromClause.Create(FilterStream.Create(typeof(SupportBean).FullName) .AddView("length", Expressions.Constant(1000))); model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model); Assert.AreEqual(epl, model.ToEPL()); EPStatement stmt = epService.EPAdministrator.Create(model); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; Assert.AreEqual(typeof(long?), stmt.EventType.GetPropertyType("result")); TryCoalesceLong(epService, listener); stmt.Dispose(); }
private void Try100Events(EPServiceProvider engine) { var stmtText = "select myint from " + typeof(SupportBean_S0).FullName + " as s0," + " sql:MyDB ['select myint from mytesttable where ${id} = mytesttable.mybigint'] as s1"; var statement = engine.EPAdministrator.CreateEPL(stmtText); var listener = new SupportUpdateListener(); statement.Events += listener.Update; for (var i = 0; i < 100; i++) { var id = i % 10 + 1; var bean = new SupportBean_S0(id); engine.EPRuntime.SendEvent(bean); var received = listener.AssertOneGetNewAndReset(); Assert.AreEqual(id * 10, received.Get("myint")); } statement.Dispose(); }
private void RunIndexedValueProp(EPServiceProvider epService, EPStatement stmt) { var testListener = new SupportUpdateListener(); stmt.Events += testListener.Update; var eventOne = new SupportBeanComplexProps(new int[] { 3 }); epService.EPRuntime.SendEvent(eventOne); Assert.IsFalse(testListener.IsInvoked); var theEvent = new SupportBeanComplexProps(new int[] { 6 }); epService.EPRuntime.SendEvent(theEvent); Assert.IsFalse(testListener.IsInvoked); var eventTwo = new SupportBeanComplexProps(new int[] { 3 }); epService.EPRuntime.SendEvent(eventTwo); EventBean eventBean = testListener.AssertOneGetNewAndReset(); Assert.AreSame(eventOne, eventBean.Get("a")); Assert.AreSame(eventTwo, eventBean.Get("b")); }
private void TryJoinPassive2Stream(EPServiceProvider epService, string stmtText) { EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtText); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; TryUnsupportedIterator(stmt); // send event, expect result SendEventMD(epService, "E1", 1L); string[] fields = "symbol,volume,TheString,IntPrimitive".Split(','); Assert.IsFalse(listener.IsInvoked); SendEvent(epService, "E1", 10); Assert.IsFalse(listener.IsInvoked); SendEventMD(epService, "E1", 2L); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 2L, "E1", 10 }); SendEvent(epService, "E1", 20); Assert.IsFalse(listener.IsInvoked); stmt.Dispose(); }
public void SetUp() { _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration()); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _updateListener = new SupportUpdateListener(); int count = 100; _eventsS0 = new SupportBean_S0[15]; _eventsS1 = new SupportBean_S1[15]; for (int i = 0; i < _eventsS0.Length; i++) { _eventsS0[i] = new SupportBean_S0(count++, Convert.ToString(i)); } count = 200; for (int i = 0; i < _eventsS1.Length; i++) { _eventsS1[i] = new SupportBean_S1(count++, Convert.ToString(i)); } }
public override void Run(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType(typeof(MySimpleScheduleEvent)); epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>(); epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec("2002-05-01T09:00:00.000"))); epService.EPAdministrator.CreateEPL("create context MyCtx start MySimpleScheduleEvent as sse"); EPStatement stmt = epService.EPAdministrator.CreateEPL("context MyCtx\n" + "select count(*) as c \n" + "from SupportBean_S0\n" + "output last At(context.sse.atminute, context.sse.athour, *, *, *, *) and when terminated\n"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new MySimpleScheduleEvent(10, 15)); epService.EPRuntime.SendEvent(new SupportBean_S0(0)); epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec("2002-05-01T10:14:59.000"))); Assert.IsFalse(listener.GetAndClearIsInvoked()); epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec("2002-05-01T10:15:00.000"))); Assert.IsTrue(listener.GetAndClearIsInvoked()); }
private void Try3TableOuterJoin(EPServiceProvider epService, EPStatement statement) { var listener = new SupportUpdateListener(); statement.Events += listener.Update; string[] fields = "s0.id,s1.id,s2.id".Split(','); epService.EPRuntime.SendEvent(new SupportBean_S0(1, "E1")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 1, null, null }); epService.EPRuntime.SendEvent(new SupportBean_S1(2, "E1")); epService.EPRuntime.SendEvent(new SupportBean_S2(3, "E1")); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean_S1(20, "E2")); epService.EPRuntime.SendEvent(new SupportBean_S0(10, "E2")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 10, 20, null }); epService.EPRuntime.SendEvent(new SupportBean_S2(30, "E2")); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean_S2(300, "E3")); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean_S0(100, "E3")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 100, null, null }); epService.EPRuntime.SendEvent(new SupportBean_S1(200, "E3")); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean_S2(31, "E4")); epService.EPRuntime.SendEvent(new SupportBean_S1(21, "E4")); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean_S0(11, "E4")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 11, 21, 31 }); epService.EPRuntime.SendEvent(new SupportBean_S2(32, "E4")); epService.EPRuntime.SendEvent(new SupportBean_S1(22, "E4")); Assert.IsFalse(listener.IsInvoked); }
private void TryGrouped(string text, EPStatementObjectModel model) { EPStatement statement; if (model != null) { statement = _epService.EPAdministrator.Create(model); } else { statement = _epService.EPAdministrator.CreateEPL(text); } var listener = new SupportUpdateListener(); statement.AddListener(listener); _epService.EPRuntime.SendEvent(new SupportBean("a", 1)); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { "a" }, new object[] { "" }); _epService.EPRuntime.SendEvent(new SupportBean("b", 2)); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { "b" }, new object[] { "" }); _epService.EPRuntime.SendEvent(new SupportBean("c", 1)); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { "a c" }, new object[] { "a" }); _epService.EPRuntime.SendEvent(new SupportBean("d", 2)); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { "b d" }, new object[] { "b" }); _epService.EPRuntime.SendEvent(new SupportBean("e", 1)); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { "a c e" }, new object[] { "a c" }); _epService.EPRuntime.SendEvent(new SupportBean("f", 2)); EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { "b d f" }, new object[] { "b d" }); listener.Reset(); }
public void TryPermute(EPServiceProvider epService, bool soda, string pattern) { string epl = "select * from SupportBean " + "match_recognize (" + " partition by IntPrimitive" + " measures A as a, B as b, C as c" + " pattern (" + pattern + ")" + " define" + " A as A.TheString like \"A%\"," + " B as B.TheString like \"B%\"," + " C as C.TheString like \"C%\"" + ")"; EPStatement stmt = SupportModelHelper.CreateByCompileOrParse(epService, soda, epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; string[] prefixes = "A,B,C".Split(','); string[] fields = "a,b,c".Split(','); var e = PermutationEnumerator.Create(3); int count = 0; foreach (var indexes in e) { var expected = new Object[3]; for (int i = 0; i < 3; i++) { expected[indexes[i]] = SendEvent(epService, prefixes[indexes[i]] + Convert.ToString(count), count); } count++; EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, expected); } stmt.Dispose(); }
private void RunAssertionTimeBatchRowForAllJoin(EPServiceProvider epService) { SendTimer(epService, 0); string stmtText = "select irstream sum(price) as sumPrice from MarketData#time_batch(1 sec) as S0, SupportBean#keepall as S1 where S0.symbol = S1.TheString"; EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtText); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendSupportEvent(epService, "DELL"); SendSupportEvent(epService, "IBM"); // send first batch SendMDEvent(epService, "DELL", 10, 0L); SendMDEvent(epService, "IBM", 15, 0L); SendMDEvent(epService, "DELL", 20, 0L); SendTimer(epService, 1000); EventBean[] newEvents = listener.LastNewData; Assert.AreEqual(1, newEvents.Length); AssertEvent(newEvents[0], 45d); // send second batch SendMDEvent(epService, "IBM", 20, 600L); SendTimer(epService, 2000); newEvents = listener.LastNewData; Assert.AreEqual(1, newEvents.Length); AssertEvent(newEvents[0], 20d); EventBean[] oldEvents = listener.LastOldData; Assert.AreEqual(1, oldEvents.Length); AssertEvent(oldEvents[0], 45d); stmt.Dispose(); }
public override void Run(EPServiceProvider epService) { foreach (var clazz in new Type[] { typeof(SupportBean), typeof(SupportBean_S0), typeof(SupportBean_S1), typeof(SupportBean_S2) }) { epService.EPAdministrator.Configuration.AddEventType(clazz); } var currentTime = new AtomicLong(0); epService.EPRuntime.SendEvent(new CurrentTimeEvent(currentTime.Get())); epService.EPAdministrator.CreateEPL("@Name('create') create table MyTable as (\n" + "key string primary key, thesum sum(int))"); epService.EPAdministrator.CreateEPL("@Name('select') into table MyTable " + "select sum(IntPrimitive) as thesum from SupportBean group by TheString"); epService.EPRuntime.SendEvent(new SupportBean("E1", 10)); epService.EPRuntime.SendEvent(new SupportBean("E2", 20)); epService.EPRuntime.SendEvent(new SupportBean("E1", 30)); epService.EPAdministrator.GetStatement("create").Dispose(); EPStatement stmt = epService.EPAdministrator.CreateEPL("select key, thesum from MyTable output snapshot every 1 seconds"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; currentTime.Set(currentTime.Get() + 1000L); epService.EPRuntime.SendEvent(new CurrentTimeEvent(currentTime.Get())); EPAssertionUtil.AssertPropsPerRowAnyOrder(listener.GetAndResetLastNewData(), "key,thesum".Split(','), new object[][] { new object[] { "E1", 40 }, new object[] { "E2", 20 } }); currentTime.Set(currentTime.Get() + 1000L); epService.EPRuntime.SendEvent(new CurrentTimeEvent(currentTime.Get())); Assert.IsTrue(listener.IsInvoked); stmt.Dispose(); }
public override void Run(EPServiceProvider epService) { var listener = new SupportUpdateListener(); epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); string epl = "select * from SupportBean(IntPrimitive<10) where IntPrimitive not in (select IntPrimitive from SupportBean#unique(IntPrimitive))"; EPStatement stmtOne = epService.EPAdministrator.CreateEPL(epl); stmtOne.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("E1", 5)); Assert.IsTrue(listener.GetAndClearIsInvoked()); stmtOne.Dispose(); string eplTwo = "select * from SupportBean where IntPrimitive not in (select IntPrimitive from SupportBean(IntPrimitive<10)#unique(IntPrimitive))"; EPStatement stmtTwo = epService.EPAdministrator.CreateEPL(eplTwo); stmtTwo.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("E1", 5)); Assert.IsTrue(listener.GetAndClearIsInvoked()); }
private void RunAssertionNonConstantVariable(bool soda) { var modifyEPL = "on SupportBean_S0 set MyNonConstantServiceVariable.Postfix=p00"; SupportModelHelper.CreateByCompileOrParse(_epService, soda, modifyEPL); var epl = "select id as c0 from SupportBean as sb, " + "method:MyNonConstantServiceVariable.FetchABean(IntPrimitive) as h0"; var stmt = SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl); _listener = new SupportUpdateListener(); stmt.AddListener(_listener); SendEventAssert("E1", 10, "_10_postfix"); _epService.EPRuntime.SendEvent(new SupportBean_S0(1, "newpostfix")); SendEventAssert("E1", 20, "_20_newpostfix"); // return to original value _epService.EPRuntime.SendEvent(new SupportBean_S0(2, "postfix")); SendEventAssert("E1", 30, "_30_postfix"); _epService.EPAdministrator.DestroyAllStatements(); }
private void RunAssertionOne(String expression) { EPStatement stmt = _epService.EPAdministrator.CreateEPL(expression); _listener = new SupportUpdateListener(); stmt.Events += _listener.Update; String[] fields = "id,valh0,valh1".Split(','); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null); SendBeanInt("E1", 20, 20, 3); EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, new Object[][] { new Object[] { "E1", "H03", "H13" } }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", "H03", "H13" } }); SendBeanInt("E2", 20, 20, 21); EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, null); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", "H03", "H13" } }); SendBeanInt("E3", 4, 4, 2); EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, new Object[][] { new Object[] { "E3", "H02", "H12" } }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1", "H03", "H13" }, new Object[] { "E3", "H02", "H12" } }); stmt.Dispose(); }
private void RunAssertionRelOp(EPServiceProvider epService) { // relational op tests handled by relational op unit test EPStatement stmt = epService.EPAdministrator.CreateEPL("select * from SupportBeanNumeric where DecimalOne < 10 and BigInt > 10"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; SendBigNumEvent(epService, 10, 10); Assert.IsFalse(listener.GetAndClearIsInvoked()); SendBigNumEvent(epService, 11, 9); Assert.IsTrue(listener.GetAndClearIsInvoked()); stmt.Dispose(); stmt = epService.EPAdministrator.CreateEPL("select * from SupportBeanNumeric where DecimalOne < 10.0"); stmt.Events += listener.Update; SendBigNumEvent(epService, 0, 11); Assert.IsFalse(listener.GetAndClearIsInvoked()); epService.EPRuntime.SendEvent(new SupportBeanNumeric(null, new decimal(9.999))); Assert.IsTrue(listener.GetAndClearIsInvoked()); stmt.Dispose(); // test float stmt = epService.EPAdministrator.CreateEPL("select * from SupportBeanNumeric where floatOne < 10f and floatTwo > 10f"); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBeanNumeric(true, 1f, 20f)); Assert.IsTrue(listener.GetAndClearIsInvoked()); epService.EPRuntime.SendEvent(new SupportBeanNumeric(true, 20f, 1f)); Assert.IsFalse(listener.GetAndClearIsInvoked()); stmt.Dispose(); }
public void Test2Stream2HistStarSubordinate() { String expression; expression = "select s0.Id as ids0, s1.Id as ids1, h0.val as valh0, h1.val as valh1 " + "from SupportBeanInt(id like 'S0%')#keepall as s0, " + "SupportBeanInt(id like 'S1%')#lastevent as s1, " + "method:SupportJoinMethods.FetchVal(s0.Id||'H1', s0.P00) as h0, " + "method:SupportJoinMethods.FetchVal(s1.Id||'H2', s1.P00) as h1 " + "order by s0.Id asc"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(expression); _listener = new SupportUpdateListener(); stmt.Events += _listener.Update; String[] fields = "ids0,ids1,valh0,valh1".Split(','); SendBeanInt("S00", 1); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null); Assert.IsFalse(_listener.IsInvoked); SendBeanInt("S10", 1); Object[][] resultOne = new Object[][] { new Object[] { "S00", "S10", "S00H11", "S10H21" } }; EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, resultOne); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, resultOne); SendBeanInt("S01", 1); Object[][] resultTwo = new Object[][] { new Object[] { "S01", "S10", "S01H11", "S10H21" } }; EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, resultTwo); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultOne, resultTwo)); SendBeanInt("S11", 1); Object[][] resultThree = new Object[][] { new Object[] { "S00", "S11", "S00H11", "S11H21" }, new Object[] { "S01", "S11", "S01H11", "S11H21" } }; EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, resultThree); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultThree)); }
private void RunAssertionInput(EPServiceProvider epService) { string[] fields = "val0,val1".Split(','); string eplFragment = "select " + "utildate.WithMax('month') as val0," + "longdate.WithMax('month') as val1" + " from SupportDateTime"; EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment); var listener = new SupportUpdateListener(); stmtFragment.Events += listener.Update; LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(long?) }); string startTime = "2002-05-30T09:00:00.000"; string expectedTime = "2002-12-30T09:00:00.000"; epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expectedTime, "util", "long")); stmtFragment.Dispose(); }
private void RunAssertionSeven(String expression) { EPStatement stmt = _epService.EPAdministrator.CreateEPL(expression); _listener = new SupportUpdateListener(); stmt.Events += _listener.Update; String[] fields = "valh0,valh1,valh2".Split(','); SendBeanInt("S00", 1, 1, 1); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new Object[][] { new Object[] { "H01", "H01-H11", "H01-H11-H21" } }); SendBeanInt("S01", 0, 1, 1); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null); SendBeanInt("S02", 1, 1, 0); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null); SendBeanInt("S03", 1, 1, 2); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new Object[][] { new Object[] { "H01", "H01-H11", "H01-H11-H21" }, new Object[] { "H01", "H01-H11", "H01-H11-H22" } }); SendBeanInt("S04", 2, 2, 1); Object[][] result = new Object[][] { new Object[] { "H01", "H01-H11", "H01-H11-H21" }, new Object[] { "H02", "H02-H11", "H02-H11-H21" }, new Object[] { "H01", "H01-H12", "H01-H12-H21" }, new Object[] { "H02", "H02-H12", "H02-H12-H21" } }; EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, result); }
private void RunAssertionFilterGreaterThen(EPServiceProvider epService) { // ESPER-411 epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); EPStatement statement = epService.EPAdministrator.CreatePattern("every a=SupportBean -> b=SupportBean(b.IntPrimitive <= a.IntPrimitive)"); var listener = new SupportUpdateListener(); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("E1", 10)); epService.EPRuntime.SendEvent(new SupportBean("E2", 11)); Assert.IsFalse(listener.IsInvoked); statement.Dispose(); statement = epService.EPAdministrator.CreatePattern("every a=SupportBean -> b=SupportBean(a.IntPrimitive >= b.IntPrimitive)"); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("E1", 10)); epService.EPRuntime.SendEvent(new SupportBean("E2", 11)); Assert.IsFalse(listener.IsInvoked); statement.Dispose(); }
private void RunAssertionFollowedByDynamicallyComputed(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("computeISO8601String", GetType(), "ComputeISO8601String"); EPServiceProviderIsolated iso = epService.GetEPServiceIsolated("E1"); SendCurrentTime(iso, "2012-10-01T05:51:07.000GMT-0:00"); string epl = "select * from pattern[every sb=SupportBean -> timer:schedule(iso: computeISO8601String(sb))]"; var listener = new SupportUpdateListener(); iso.EPAdministrator.CreateEPL(epl, null, null).Events += listener.Update; SupportBean b1 = MakeSendEvent(iso, "E1", 5); SendCurrentTime(iso, "2012-10-01T05:51:9.999GMT-0:00"); Assert.IsFalse(listener.IsInvokedAndReset()); SendCurrentTime(iso, "2012-10-01T05:51:10.000GMT-0:00"); Assert.AreEqual(b1, listener.AssertOneGetNewAndReset().Get("sb")); epService.EPAdministrator.DestroyAllStatements(); iso.Dispose(); }
private void RunAssertionSumJoin(EPServiceProvider epService) { string epl = "select irstream symbol," + "sum(price) as mySum," + "avg(price) as myAvg " + "from " + typeof(SupportBeanString).FullName + "#length(100) as one, " + typeof(SupportMarketDataBean).FullName + "#length(3) as two " + "where (symbol='DELL' or symbol='IBM' or symbol='GE') " + " and one.TheString = two.symbol " + "group by symbol"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBeanString(SYMBOL_DELL)); epService.EPRuntime.SendEvent(new SupportBeanString(SYMBOL_IBM)); epService.EPRuntime.SendEvent(new SupportBeanString("AAA")); TryAssertionSum(epService, stmt, listener); stmt.Dispose(); }
private void RunAssertionTwoParameters(EPServiceProvider epService) { var listener = new SupportUpdateListener(); var statementText = "select Math.Max(2,3) " + STREAM_MDB_LEN5; var stmt = epService.EPAdministrator.CreateEPL(statementText); stmt.Events += listener.Update; Assert.AreEqual(3, AssertStatementAndGetProperty(epService, listener, true, "Math.Max(2,3)")[0]); stmt.Dispose(); statementText = "select System.Math.Max(2,3d) " + STREAM_MDB_LEN5; stmt = epService.EPAdministrator.CreateEPL(statementText); stmt.Events += listener.Update; Assert.AreEqual(3d, AssertStatementAndGetProperty(epService, listener, true, "System.Math.Max(2,3.0d)")[0]); stmt.Dispose(); statementText = "select Convert.ToInt64(\"123\")" + STREAM_MDB_LEN5; stmt = epService.EPAdministrator.CreateEPL(statementText); stmt.Events += listener.Update; Object expected = long.Parse("123"); Assert.AreEqual(expected, AssertStatementAndGetProperty(epService, listener, true, "Convert.ToInt64(\"123\")")[0]); stmt.Dispose(); }
public void TestRestartStatement() { String stmtText = "select mychar from " + typeof(SupportBean_S0).FullName + " as s0," + " sql:MyDB ['select mychar from mytesttable where ${id} = mytesttable.mybigint'] as s1"; EPStatement statement = _epService.EPAdministrator.CreateEPL(stmtText); _listener = new SupportUpdateListener(); statement.Events += _listener.Update; // Too many connections unless the stop actually relieves them for (int i = 0; i < 100; i++) { statement.Stop(); SendEventS0(1); Assert.IsFalse(_listener.IsInvoked); statement.Start(); SendEventS0(1); Assert.AreEqual("Z", _listener.AssertOneGetNewAndReset().Get("mychar")); } }
private void RunAssertion_A_B(EPServiceProvider epService) { EPServiceProviderIsolated isolated = epService.GetEPServiceIsolated("I1"); SendTimer(isolated, 0); // the interval is not effective string[] fields = "a,b".Split(','); string text = "select * from MyEvent#keepall " + "match_recognize (" + " measures A.TheString as a, B.TheString as b" + " pattern (A B)" + " interval 10 seconds or terminated" + " define" + " A as A.TheString like 'A%'," + " B as B.TheString like 'B%'" + ")"; EPStatement stmt = isolated.EPAdministrator.CreateEPL(text, "stmt1", null); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; isolated.EPRuntime.SendEvent(new SupportRecogBean("A1")); isolated.EPRuntime.SendEvent(new SupportRecogBean("B1")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "A1", "B1" }); isolated.EPRuntime.SendEvent(new SupportRecogBean("A2")); isolated.EPRuntime.SendEvent(new SupportRecogBean("A3")); isolated.EPRuntime.SendEvent(new SupportRecogBean("B2")); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "A3", "B2" }); // destroy stmt.Dispose(); isolated.Dispose(); }
private void RunAssertionWindowedUnGrouped(EPServiceProvider epService) { string epl = "select " + "first(TheString) as firststring, " + "last(TheString) as laststring, " + "first(IntPrimitive) as firstint, " + "last(IntPrimitive) as lastint, " + "window(IntPrimitive) as allint " + "from SupportBean#length(2)"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; TryAssertionUngrouped(epService, listener); stmt.Dispose(); EPStatementObjectModel model = epService.EPAdministrator.CompileEPL(epl); stmt = epService.EPAdministrator.Create(model); stmt.Events += listener.Update; Assert.AreEqual(epl, model.ToEPL()); TryAssertionUngrouped(epService, listener); stmt.Dispose(); // test null-value provided EPStatement stmtWNull = epService.EPAdministrator.CreateEPL("select window(IntBoxed).take(10) from SupportBean#length(2)"); stmtWNull.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); stmtWNull.Dispose(); }
private void RunAssertion(EPServiceProvider epService, SupportUpdateListener listener, string ctx, EPStatementSPI statement) { statement.Events += listener.Update; var fields = "c0,c1,c2".Split(','); epService.EPRuntime.SendEvent(new SupportBean("E1", 5)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { ctx, "cat1", null }); epService.EPRuntime.SendEvent(new SupportBean("E2", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("E1", 4)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { ctx, "cat1", 5 }); epService.EPAdministrator.GetStatement("context").Dispose(); var spi = (EPServiceProviderSPI)epService; Assert.AreEqual(1, spi.ContextManagementService.ContextCount); epService.EPAdministrator.DestroyAllStatements(); AgentInstanceAssertionUtil.AssertInstanceCounts(statement.StatementContext, 0, 0, 0, 0); Assert.AreEqual(0, spi.ContextManagementService.ContextCount); }