private void SendABEvents(EPServiceProvider epService, string id) { var beanOne = new SupportBean_A(id); var beanTwo = new SupportBean_B(id); epService.EPRuntime.SendEvent(beanOne); epService.EPRuntime.SendEvent(beanTwo); }
private void SendABEvents(String id) { SupportBean_A beanOne = new SupportBean_A(id); SupportBean_B beanTwo = new SupportBean_B(id); _epService.EPRuntime.SendEvent(beanOne); _epService.EPRuntime.SendEvent(beanTwo); }
private void AssertEventsReceived(SupportBean_A event_A, SupportBean_B event_B, SupportBean_C event_C) { Assert.AreEqual(1, _updateListener.LastNewData.Length); Assert.AreSame(event_A, _updateListener.LastNewData[0].Get("streamA")); Assert.AreSame(event_B, _updateListener.LastNewData[0].Get("streamB")); Assert.AreSame(event_C, _updateListener.LastNewData[0].Get("streamC")); _updateListener.Reset(); }
private static void SendABEvents( RegressionEnvironment env, string id) { var beanOne = new SupportBean_A(id); var beanTwo = new SupportBean_B(id); env.SendEventBean(beanOne); env.SendEventBean(beanTwo); }
public static EventBean[] MakeEvents_B(String[] ids) { EventBean[] events = new EventBean[ids.Length]; for (int i = 0; i < events.Length; i++) { SupportBean_B bean = new SupportBean_B(ids[i]); events[i] = CreateObject(bean); } return(events); }
private void RunAssertionSelectArray(EPServiceProvider epService) { string stmt = "select a, b, a[0] as a0, a[0].id as a0Id, a[1] as a1, a[1].id as a1Id, a[2] as a2, a[2].id as a2Id from pattern [a=A until b=B]"; var listener = new SupportUpdateListener(); EPStatement statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; var eventA1 = new SupportBean_A("A1"); epService.EPRuntime.SendEvent(eventA1); var eventA2 = new SupportBean_A("A2"); epService.EPRuntime.SendEvent(eventA2); Assert.IsFalse(listener.IsInvoked); var eventB1 = new SupportBean_B("B1"); epService.EPRuntime.SendEvent(eventB1); EventBean theEvent = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertEqualsExactOrder((object[])theEvent.Get("a"), new object[] { eventA1, eventA2 }); Assert.AreSame(eventA1, theEvent.Get("a0")); Assert.AreSame(eventA2, theEvent.Get("a1")); Assert.IsNull(theEvent.Get("a2")); Assert.AreEqual("A1", theEvent.Get("a0Id")); Assert.AreEqual("A2", theEvent.Get("a1Id")); Assert.IsNull(theEvent.Get("a2Id")); Assert.AreSame(eventB1, theEvent.Get("b")); // try wildcard stmt = "select * from pattern [a=A until b=B]"; statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(eventA1); epService.EPRuntime.SendEvent(eventA2); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(eventB1); theEvent = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertEqualsExactOrder((object[])theEvent.Get("a"), new object[] { eventA1, eventA2 }); Assert.AreSame(eventA1, theEvent.Get("a[0]")); Assert.AreSame(eventA2, theEvent.Get("a[1]")); Assert.IsNull(theEvent.Get("a[2]")); Assert.AreEqual("A1", theEvent.Get("a[0].id")); Assert.AreEqual("A2", theEvent.Get("a[1].id")); Assert.IsNull(theEvent.Get("a[2].id")); Assert.AreSame(eventB1, theEvent.Get("b")); statement.Dispose(); }
public void TestFollowedEveryMultiple() { String expression = "select * from pattern [every a=" + typeof(SupportBean_A).FullName + " -> b=" + typeof(SupportBean_B).FullName + " -> c=" + typeof(SupportBean_C).FullName + " -> d=" + typeof(SupportBean_D).FullName + "]"; Configuration config = SupportConfigFactory.GetConfiguration(); EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(config); epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, GetType(), GetType().FullName); } EPStatement statement = epService.EPAdministrator.CreateEPL(expression); var listener = new SupportUpdateListener(); statement.Events += listener.Update; var events = new Object[10]; events[0] = new SupportBean_A("A1"); epService.EPRuntime.SendEvent(events[0]); events[1] = new SupportBean_A("A2"); epService.EPRuntime.SendEvent(events[1]); events[2] = new SupportBean_B("B1"); epService.EPRuntime.SendEvent(events[2]); events[3] = new SupportBean_C("C1"); epService.EPRuntime.SendEvent(events[3]); Assert.IsFalse(listener.IsInvoked); events[4] = new SupportBean_D("D1"); epService.EPRuntime.SendEvent(events[4]); Assert.AreEqual(2, listener.LastNewData.Length); var fields = new[] { "a", "b", "c", "d" }; EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new[] { events[0], events[2], events[3], events[4] }); EPAssertionUtil.AssertProps(listener.LastNewData[1], fields, new[] { events[1], events[2], events[3], events[4] }); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
private static void AssertEventsReceived( RegressionEnvironment env, SupportBean_A eventA, SupportBean_B eventB, SupportBean_C eventC) { var updateListener = env.Listener("s0"); Assert.AreEqual(1, updateListener.LastNewData.Length); Assert.AreSame(eventA, updateListener.LastNewData[0].Get("streamA")); Assert.AreSame(eventB, updateListener.LastNewData[0].Get("streamB")); Assert.AreSame(eventC, updateListener.LastNewData[0].Get("streamC")); updateListener.Reset(); }
private static LinkedHashMap <String, Object> MakeMixedSet() { LinkedHashMap <String, Object> testData = new LinkedHashMap <String, Object>(); testData["A1"] = new SupportBean_A("A1"); testData["B1"] = new SupportBean_B("B1"); testData["C1"] = new SupportBean_C("C1"); testData["B2"] = new SupportBean_B("B2"); testData["A2"] = new SupportBean_A("A2"); testData["D1"] = new SupportBean_D("D1"); testData["E1"] = new SupportBean_E("E1"); testData["F1"] = new SupportBean_F("F1"); testData["D2"] = new SupportBean_D("D2"); testData["B3"] = new SupportBean_B("B3"); testData["G1"] = new SupportBean_G("G1"); testData["D3"] = new SupportBean_D("D3"); return(testData); }
public void SetUp() { _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration()); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _updateListener = new SupportUpdateListener(); _eventsA = new SupportBean_A[10]; _eventsB = new SupportBean_B[10]; _eventsC = new SupportBean_C[10]; for (int i = 0; i < _eventsA.Length; i++) { _eventsA[i] = new SupportBean_A(Convert.ToString(i)); _eventsB[i] = new SupportBean_B(Convert.ToString(i)); _eventsC[i] = new SupportBean_C(Convert.ToString(i)); } }
private static void TryOrAndNot( RegressionEnvironment env, string pattern) { var expression = "@Name('s0') select * " + "from pattern [" + pattern + "]"; env.CompileDeploy(expression); env.AddListener("s0"); var eventA1 = new SupportBean_A("A1"); env.SendEventBean(eventA1); var theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual(eventA1, theEvent.Get("a")); Assert.IsNull(theEvent.Get("b")); var eventB1 = new SupportBean_B("B1"); env.SendEventBean(eventB1); theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual(eventA1, theEvent.Get("a")); Assert.AreEqual(eventB1, theEvent.Get("b")); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var expression = "@Name('s0') select * from pattern [every a=SupportBean_A -> b=SupportBean_B -> c=SupportBean_C -> d=SupportBean_D]"; env.CompileDeploy(expression); env.AddListener("s0"); var events = new object[10]; events[0] = new SupportBean_A("A1"); env.SendEventBean(events[0]); events[1] = new SupportBean_A("A2"); env.SendEventBean(events[1]); events[2] = new SupportBean_B("B1"); env.SendEventBean(events[2]); events[3] = new SupportBean_C("C1"); env.SendEventBean(events[3]); Assert.IsFalse(env.Listener("s0").IsInvoked); events[4] = new SupportBean_D("D1"); env.SendEventBean(events[4]); Assert.AreEqual(2, env.Listener("s0").LastNewData.Length); string[] fields = {"a", "b", "c", "d"}; EPAssertionUtil.AssertProps( env.Listener("s0").LastNewData[0], fields, new[] {events[0], events[2], events[3], events[4]}); EPAssertionUtil.AssertProps( env.Listener("s0").LastNewData[1], fields, new[] {events[1], events[2], events[3], events[4]}); env.UndeployAll(); }
private void RunAssertionFollowedEveryMultiple(EPServiceProvider epService) { string expression = "select * from pattern [every a=" + typeof(SupportBean_A).FullName + " -> b=" + typeof(SupportBean_B).FullName + " -> c=" + typeof(SupportBean_C).FullName + " -> d=" + typeof(SupportBean_D).FullName + "]"; EPStatement statement = epService.EPAdministrator.CreateEPL(expression); var listener = new SupportUpdateListener(); statement.Events += listener.Update; var events = new Object[10]; events[0] = new SupportBean_A("A1"); epService.EPRuntime.SendEvent(events[0]); events[1] = new SupportBean_A("A2"); epService.EPRuntime.SendEvent(events[1]); events[2] = new SupportBean_B("B1"); epService.EPRuntime.SendEvent(events[2]); events[3] = new SupportBean_C("C1"); epService.EPRuntime.SendEvent(events[3]); Assert.IsFalse(listener.IsInvoked); events[4] = new SupportBean_D("D1"); epService.EPRuntime.SendEvent(events[4]); Assert.AreEqual(2, listener.LastNewData.Length); var fields = new string[] { "a", "b", "c", "d" }; EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { events[0], events[2], events[3], events[4] }); EPAssertionUtil.AssertProps(listener.LastNewData[1], fields, new object[] { events[1], events[2], events[3], events[4] }); statement.Dispose(); }
private void AssertEventsReceived(SupportUpdateListener updateListener, SupportBean_A eventA, SupportBean_B eventB, SupportBean_C eventC) { Assert.AreEqual(1, updateListener.LastNewData.Length); Assert.AreSame(eventA, updateListener.LastNewData[0].Get("streamA")); Assert.AreSame(eventB, updateListener.LastNewData[0].Get("streamB")); Assert.AreSame(eventC, updateListener.LastNewData[0].Get("streamC")); updateListener.Reset(); }
public void TestUseFilter() { EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(_config); epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, GetType(), GetType().FullName); } String stmt; SupportUpdateListener listener; EPStatement statement; EventBean theEvent; stmt = "select * from pattern [a=A until b=B -> c=C(id = ('C' || a[0].id || a[1].id || b.id))]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; Object eventA1 = new SupportBean_A("A1"); epService.EPRuntime.SendEvent(eventA1); Object eventA2 = new SupportBean_A("A2"); epService.EPRuntime.SendEvent(eventA2); Object eventB1 = new SupportBean_B("B1"); epService.EPRuntime.SendEvent(eventB1); epService.EPRuntime.SendEvent(new SupportBean_C("C1")); Assert.IsFalse(listener.IsInvoked); Object eventC1 = new SupportBean_C("CA1A2B1"); epService.EPRuntime.SendEvent(eventC1); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreSame(eventA1, theEvent.Get("a[0]")); Assert.AreSame(eventA2, theEvent.Get("a[1]")); Assert.IsNull(theEvent.Get("a[2]")); Assert.AreSame(eventB1, theEvent.Get("b")); Assert.AreSame(eventC1, theEvent.Get("c")); statement.Dispose(); // Test equals-optimization with array event stmt = "select * from pattern [a=A until b=B -> c=SupportBean(TheString = a[1].id)]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean_A("A1")); epService.EPRuntime.SendEvent(new SupportBean_A("A2")); epService.EPRuntime.SendEvent(new SupportBean_B("B1")); epService.EPRuntime.SendEvent(new SupportBean("A3", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("A2", 10)); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual(10, theEvent.Get("c.IntPrimitive")); statement.Dispose(); // Test in-optimization stmt = "select * from pattern [a=A until b=B -> c=SupportBean(TheString in(a[2].id))]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean_A("A1")); epService.EPRuntime.SendEvent(new SupportBean_A("A2")); epService.EPRuntime.SendEvent(new SupportBean_A("A3")); epService.EPRuntime.SendEvent(new SupportBean_B("B1")); epService.EPRuntime.SendEvent(new SupportBean("A2", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("A3", 5)); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual(5, theEvent.Get("c.IntPrimitive")); statement.Dispose(); // Test not-in-optimization stmt = "select * from pattern [a=A until b=B -> c=SupportBean(TheString!=a[0].id and TheString!=a[1].id and TheString!=a[2].id)]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean_A("A1")); epService.EPRuntime.SendEvent(new SupportBean_A("A2")); epService.EPRuntime.SendEvent(new SupportBean_A("A3")); epService.EPRuntime.SendEvent(new SupportBean_B("B1")); epService.EPRuntime.SendEvent(new SupportBean("A2", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("A1", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("A6", 5)); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual(5, theEvent.Get("c.IntPrimitive")); statement.Dispose(); // Test range-optimization stmt = "select * from pattern [a=SupportBean(TheString like 'A%') until b=SupportBean(TheString like 'B%') -> c=SupportBean(IntPrimitive between a[0].IntPrimitive and a[1].IntPrimitive)]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("A1", 5)); epService.EPRuntime.SendEvent(new SupportBean("A2", 8)); epService.EPRuntime.SendEvent(new SupportBean("B1", -1)); epService.EPRuntime.SendEvent(new SupportBean("E1", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("E2", 3)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("E3", 5)); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual(5, theEvent.Get("c.IntPrimitive")); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestSelectArray() { EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(_config); epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, GetType(), GetType().FullName); } String stmt = "select a, b, a[0] as a0, a[0].id as a0Id, a[1] as a1, a[1].id as a1Id, a[2] as a2, a[2].id as a2Id from pattern [a=A until b=B]"; SupportUpdateListener listener = new SupportUpdateListener(); EPStatement statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; Object eventA1 = new SupportBean_A("A1"); epService.EPRuntime.SendEvent(eventA1); Object eventA2 = new SupportBean_A("A2"); epService.EPRuntime.SendEvent(eventA2); Assert.IsFalse(listener.IsInvoked); Object eventB1 = new SupportBean_B("B1"); epService.EPRuntime.SendEvent(eventB1); EventBean theEvent = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertEqualsExactOrder((Object[])theEvent.Get("a"), new Object[] { eventA1, eventA2 }); Assert.AreSame(eventA1, theEvent.Get("a0")); Assert.AreSame(eventA2, theEvent.Get("a1")); Assert.IsNull(theEvent.Get("a2")); Assert.AreEqual("A1", theEvent.Get("a0Id")); Assert.AreEqual("A2", theEvent.Get("a1Id")); Assert.IsNull(theEvent.Get("a2Id")); Assert.AreSame(eventB1, theEvent.Get("b")); // try wildcard stmt = "select * from pattern [a=A until b=B]"; statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(eventA1); epService.EPRuntime.SendEvent(eventA2); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(eventB1); theEvent = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertEqualsExactOrder((Object[])theEvent.Get("a"), new Object[] { eventA1, eventA2 }); Assert.AreSame(eventA1, theEvent.Get("a[0]")); Assert.AreSame(eventA2, theEvent.Get("a[1]")); Assert.IsNull(theEvent.Get("a[2]")); Assert.AreEqual("A1", theEvent.Get("a[0].id")); Assert.AreEqual("A2", theEvent.Get("a[1].id")); Assert.IsNull(theEvent.Get("a[2].id")); Assert.AreSame(eventB1, theEvent.Get("b")); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void OnInput(SupportBean_B b) { }
public void Run(RegressionEnvironment env) { string stmt; EventBean theEvent; stmt = "@Name('s0') select * from pattern [a=SupportBean_A until b=SupportBean_B -> c=SupportBean_C(Id = ('C' || a[0].Id || a[1].Id || b.Id))]"; env.CompileDeploy(stmt).AddListener("s0"); object eventA1 = new SupportBean_A("A1"); env.SendEventBean(eventA1); env.Milestone(0); object eventA2 = new SupportBean_A("A2"); env.SendEventBean(eventA2); env.Milestone(1); object eventB1 = new SupportBean_B("B1"); env.SendEventBean(eventB1); env.Milestone(2); env.SendEventBean(new SupportBean_C("C1")); Assert.IsFalse(env.Listener("s0").IsInvoked); env.Milestone(3); object eventC1 = new SupportBean_C("CA1A2B1"); env.SendEventBean(eventC1); theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual(eventA1, theEvent.Get("a[0]")); Assert.AreEqual(eventA2, theEvent.Get("a[1]")); Assert.IsNull(theEvent.Get("a[2]")); Assert.AreEqual(eventB1, theEvent.Get("b")); Assert.AreEqual(eventC1, theEvent.Get("c")); env.UndeployAll(); // Test equals-optimization with array event stmt = "@Name('s0') select * from pattern [a=SupportBean_A until b=SupportBean_B -> c=SupportBean(TheString = a[1].Id)]"; env.CompileDeploy(stmt).AddListener("s0"); env.SendEventBean(new SupportBean_A("A1")); env.SendEventBean(new SupportBean_A("A2")); env.SendEventBean(new SupportBean_B("B1")); env.SendEventBean(new SupportBean("A3", 20)); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(new SupportBean("A2", 10)); theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual(10, theEvent.Get("c.IntPrimitive")); env.UndeployAll(); // Test in-optimization stmt = "@Name('s0') select * from pattern [a=SupportBean_A until b=SupportBean_B -> c=SupportBean(TheString in(a[2].Id))]"; env.CompileDeploy(stmt).AddListener("s0"); env.SendEventBean(new SupportBean_A("A1")); env.SendEventBean(new SupportBean_A("A2")); env.SendEventBean(new SupportBean_A("A3")); env.SendEventBean(new SupportBean_B("B1")); env.SendEventBean(new SupportBean("A2", 20)); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(new SupportBean("A3", 5)); theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual(5, theEvent.Get("c.IntPrimitive")); env.UndeployAll(); // Test not-in-optimization stmt = "@Name('s0') select * from pattern [a=SupportBean_A until b=SupportBean_B -> c=SupportBean(TheString!=a[0].Id and TheString!=a[1].Id and TheString!=a[2].Id)]"; env.CompileDeploy(stmt).AddListener("s0"); env.SendEventBean(new SupportBean_A("A1")); env.SendEventBean(new SupportBean_A("A2")); env.SendEventBean(new SupportBean_A("A3")); env.SendEventBean(new SupportBean_B("B1")); env.SendEventBean(new SupportBean("A2", 20)); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(new SupportBean("A1", 20)); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(new SupportBean("A6", 5)); theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual(5, theEvent.Get("c.IntPrimitive")); env.UndeployAll(); // Test range-optimization stmt = "@Name('s0') select * from pattern [" + " a=SupportBean(TheString like 'A%') until " + " b=SupportBean(TheString like 'B%') -> " + " c=SupportBean(IntPrimitive between a[0].IntPrimitive and a[1].IntPrimitive)" + "]"; env.CompileDeploy(stmt).AddListener("s0"); env.SendEventBean(new SupportBean("A1", 5)); env.SendEventBean(new SupportBean("A2", 8)); env.SendEventBean(new SupportBean("B1", -1)); env.SendEventBean(new SupportBean("E1", 20)); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(new SupportBean("E2", 3)); Assert.IsFalse(env.Listener("s0").IsInvoked); env.SendEventBean(new SupportBean("E3", 5)); theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual(5, theEvent.Get("c.IntPrimitive")); env.UndeployAll(); }
private static void SendB(String id, EPServiceProvider epService) { var b = new SupportBean_B(id); epService.EPRuntime.SendEvent(b); }
private SupportBean_B SendSupportBean_B(string id) { SupportBean_B bean = new SupportBean_B(id); epService.EPRuntime.SendEvent(bean); return bean; }
private void RunAssertionUseFilter(EPServiceProvider epService) { string stmt; SupportUpdateListener listener; EPStatement statement; EventBean theEvent; stmt = "select * from pattern [a=A until b=B -> c=C(id = ('C' || a[0].id || a[1].id || b.id))]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; var eventA1 = new SupportBean_A("A1"); epService.EPRuntime.SendEvent(eventA1); var eventA2 = new SupportBean_A("A2"); epService.EPRuntime.SendEvent(eventA2); var eventB1 = new SupportBean_B("B1"); epService.EPRuntime.SendEvent(eventB1); epService.EPRuntime.SendEvent(new SupportBean_C("C1")); Assert.IsFalse(listener.IsInvoked); var eventC1 = new SupportBean_C("CA1A2B1"); epService.EPRuntime.SendEvent(eventC1); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreSame(eventA1, theEvent.Get("a[0]")); Assert.AreSame(eventA2, theEvent.Get("a[1]")); Assert.IsNull(theEvent.Get("a[2]")); Assert.AreSame(eventB1, theEvent.Get("b")); Assert.AreSame(eventC1, theEvent.Get("c")); statement.Dispose(); // Test equals-optimization with array event stmt = "select * from pattern [a=A until b=B -> c=SupportBean(TheString = a[1].id)]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean_A("A1")); epService.EPRuntime.SendEvent(new SupportBean_A("A2")); epService.EPRuntime.SendEvent(new SupportBean_B("B1")); epService.EPRuntime.SendEvent(new SupportBean("A3", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("A2", 10)); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual(10, theEvent.Get("c.IntPrimitive")); statement.Dispose(); // Test in-optimization stmt = "select * from pattern [a=A until b=B -> c=SupportBean(TheString In(a[2].id))]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean_A("A1")); epService.EPRuntime.SendEvent(new SupportBean_A("A2")); epService.EPRuntime.SendEvent(new SupportBean_A("A3")); epService.EPRuntime.SendEvent(new SupportBean_B("B1")); epService.EPRuntime.SendEvent(new SupportBean("A2", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("A3", 5)); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual(5, theEvent.Get("c.IntPrimitive")); statement.Dispose(); // Test not-in-optimization stmt = "select * from pattern [a=A until b=B -> c=SupportBean(TheString!=a[0].id and TheString!=a[1].id and TheString!=a[2].id)]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean_A("A1")); epService.EPRuntime.SendEvent(new SupportBean_A("A2")); epService.EPRuntime.SendEvent(new SupportBean_A("A3")); epService.EPRuntime.SendEvent(new SupportBean_B("B1")); epService.EPRuntime.SendEvent(new SupportBean("A2", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("A1", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("A6", 5)); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual(5, theEvent.Get("c.IntPrimitive")); statement.Dispose(); // Test range-optimization stmt = "select * from pattern [a=SupportBean(TheString like 'A%') until b=SupportBean(TheString like 'B%') -> c=SupportBean(IntPrimitive between a[0].IntPrimitive and a[1].IntPrimitive)]"; listener = new SupportUpdateListener(); statement = epService.EPAdministrator.CreateEPL(stmt); statement.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("A1", 5)); epService.EPRuntime.SendEvent(new SupportBean("A2", 8)); epService.EPRuntime.SendEvent(new SupportBean("B1", -1)); epService.EPRuntime.SendEvent(new SupportBean("E1", 20)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("E2", 3)); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("E3", 5)); theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual(5, theEvent.Get("c.IntPrimitive")); statement.Dispose(); }
private void SendSupportBean_B(EPServiceProvider epService, string id) { var bean = new SupportBean_B(id); epService.EPRuntime.SendEvent(bean); }