public void TearDown() { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } _listener = null; _subscriber = null; }
public void SetUp() { var configuration = SupportConfigFactory.GetConfiguration(); var legacy = new ConfigurationEventTypeLegacy(); legacy.FactoryMethod = "GetInstance"; configuration.AddEventType("SupportBeanString", typeof(SupportBeanString).FullName, legacy); configuration.AddImport(typeof(TestInsertIntoPopulateUnderlying).Namespace); legacy = new ConfigurationEventTypeLegacy(); legacy.FactoryMethod = typeof(SupportSensorEventFactory).FullName + ".GetInstance"; configuration.AddEventType("SupportSensorEvent", typeof(SupportSensorEvent).FullName, legacy); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _listener = new SupportUpdateListener(); _subscriber = new SupportSubscriber(); _epService.EPAdministrator.Configuration.AddImport(typeof(SupportStaticMethodLib)); _epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); _epService.EPAdministrator.Configuration.AddEventType("SupportTemperatureBean", typeof(SupportTemperatureBean)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanComplexProps", typeof(SupportBeanComplexProps)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanInterfaceProps", typeof(SupportBeanInterfaceProps)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanErrorTestingOne", typeof(SupportBeanErrorTestingOne)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanErrorTestingTwo", typeof(SupportBeanErrorTestingTwo)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanReadOnly", typeof(SupportBeanReadOnly)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanArrayCollMap", typeof(SupportBeanArrayCollMap)); _epService.EPAdministrator.Configuration.AddEventType <SupportBean_N>(); _epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>(); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanObject", typeof(SupportBeanObject)); _epService.EPAdministrator.Configuration.AddImport(typeof(SupportEnum)); IDictionary <String, Object> mymapDef = new Dictionary <string, object>(); mymapDef.Put("AnInt", typeof(int)); mymapDef.Put("IntBoxed", typeof(int)); mymapDef.Put("FloatBoxed", typeof(float)); mymapDef.Put("IntArr", typeof(int[])); mymapDef.Put("MapProp", typeof(IDictionary <string, string>)); mymapDef.Put("IsAImpl", typeof(ISupportAImpl)); mymapDef.Put("IsBImpl", typeof(ISupportBImpl)); mymapDef.Put("IsGImpl", typeof(ISupportAImplSuperGImpl)); mymapDef.Put("IsABImpl", typeof(ISupportBaseABImpl)); mymapDef.Put("Nested", typeof(SupportBeanComplexProps.SupportBeanSpecialGetterNested)); _epService.EPAdministrator.Configuration.AddEventType("MyMap", mymapDef); var xml = new ConfigurationEventTypeXMLDOM(); xml.RootElementName = "abc"; _epService.EPAdministrator.Configuration.AddEventType("xmltype", xml); }
private static void TryAssertionInsertOA(RegressionEnvironment env) { var path = new RegressionPath(); env.CompileDeploy("create objectarray schema EmptyOASchema()", path); env.CompileDeploy("insert into EmptyOASchema select null from SupportBean", path); var supportSubscriber = new SupportSubscriber(); env.CompileDeploy("@Name('s0') select * from EmptyOASchema", path).AddListener("s0"); env.Statement("s0").Subscriber = supportSubscriber; env.SendEventBean(new SupportBean()); Assert.AreEqual(0, ((object[]) env.Listener("s0").AssertOneGetNewAndReset().Underlying).Length); var lastNewSubscriberData = supportSubscriber.LastNewData; Assert.AreEqual(1, lastNewSubscriberData.Length); Assert.AreEqual(0, ((object[]) lastNewSubscriberData[0]).Length); env.UndeployAll(); }
private void RunAssertionInsertOA() { _epService.EPAdministrator.CreateEPL("create objectarray schema EmptyOASchema()"); _epService.EPAdministrator.CreateEPL("insert into EmptyOASchema select null from SupportBean"); var supportSubscriber = new SupportSubscriber(); var stmt = _epService.EPAdministrator.CreateEPL("select * from EmptyOASchema"); stmt.AddListener(_listener); stmt.Subscriber = supportSubscriber; _epService.EPRuntime.SendEvent(new SupportBean()); Assert.AreEqual(0, ((object[])_listener.AssertOneGetNewAndReset().Underlying).Length); var lastNewSubscriberData = supportSubscriber.GetLastNewData(); Assert.AreEqual(1, lastNewSubscriberData.Length); Assert.AreEqual(0, ((object[])lastNewSubscriberData[0]).Length); _epService.EPAdministrator.DestroyAllStatements(); }
private void TryAssertionInsertOA(EPServiceProvider epService) { epService.EPAdministrator.CreateEPL("create objectarray schema EmptyOASchema()"); epService.EPAdministrator.CreateEPL("insert into EmptyOASchema select null from SupportBean"); var supportSubscriber = new SupportSubscriber(); EPStatement stmt = epService.EPAdministrator.CreateEPL("select * from EmptyOASchema"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; stmt.Subscriber = supportSubscriber; epService.EPRuntime.SendEvent(new SupportBean()); Assert.AreEqual(0, ((object[])listener.AssertOneGetNewAndReset().Underlying).Length); object[] lastNewSubscriberData = supportSubscriber.LastNewData; Assert.AreEqual(1, lastNewSubscriberData.Length); Assert.AreEqual(0, ((object[])lastNewSubscriberData[0]).Length); epService.EPAdministrator.DestroyAllStatements(); }
public void Run(RegressionEnvironment env) { SendTimeEvent(env, 1, 8, 0, 0, 0); env.CompileDeploy("on SupportBean set myint = IntPrimitive, mystring = TheString"); var expression = "@Name('s0') select Symbol from SupportMarketDataBean#length(2) output when myint = 1 and mystring like 'F%'"; env.CompileDeploy(expression); var stmt = env.Statement("s0"); var subscriber = new SupportSubscriber(); stmt.Subscriber = subscriber; SendEvent(env, "S1", 0); env.SendEventBean(new SupportBean("E1", 1)); Assert.AreEqual(1, env.Runtime.VariableService.GetVariableValue(null, "myint")); Assert.AreEqual("E1", env.Runtime.VariableService.GetVariableValue(null, "mystring")); SendEvent(env, "S2", 0); SendTimeEvent(env, 1, 8, 0, 1, 0); Assert.IsFalse(subscriber.IsInvoked); env.SendEventBean(new SupportBean("F1", 0)); Assert.AreEqual(0, env.Runtime.VariableService.GetVariableValue(null, "myint")); Assert.AreEqual("F1", env.Runtime.VariableService.GetVariableValue(null, "mystring")); SendTimeEvent(env, 1, 8, 0, 2, 0); SendEvent(env, "S3", 0); Assert.IsFalse(subscriber.IsInvoked); env.SendEventBean(new SupportBean("F2", 1)); Assert.AreEqual(1, env.Runtime.VariableService.GetVariableValue(null, "myint")); Assert.AreEqual("F2", env.Runtime.VariableService.GetVariableValue(null, "mystring")); SendEvent(env, "S4", 0); EPAssertionUtil.AssertEqualsExactOrder( new object[] {"S1", "S2", "S3", "S4"}, subscriber.GetAndResetLastNewData()); env.UndeployAll(); }
private void RunAssertionOutputWhenExpression(EPServiceProvider epService) { SendTimeEvent(epService, 1, 8, 0, 0, 0); epService.EPAdministrator.Configuration.AddVariable("myint", typeof(int), 0); epService.EPAdministrator.Configuration.AddVariable("mystring", typeof(string), ""); epService.EPAdministrator.CreateEPL("on SupportBean set myint = IntPrimitive, mystring = TheString"); string expression = "select symbol from MarketData#length(2) output when myint = 1 and mystring like 'F%'"; EPStatement stmt = epService.EPAdministrator.CreateEPL(expression); var subscriber = new SupportSubscriber(); stmt.Subscriber = subscriber; SendEvent(epService, "S1", 0); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); Assert.AreEqual(1, epService.EPRuntime.GetVariableValue("myint")); Assert.AreEqual("E1", epService.EPRuntime.GetVariableValue("mystring")); SendEvent(epService, "S2", 0); SendTimeEvent(epService, 1, 8, 0, 1, 0); Assert.IsFalse(subscriber.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("F1", 0)); Assert.AreEqual(0, epService.EPRuntime.GetVariableValue("myint")); Assert.AreEqual("F1", epService.EPRuntime.GetVariableValue("mystring")); SendTimeEvent(epService, 1, 8, 0, 2, 0); SendEvent(epService, "S3", 0); Assert.IsFalse(subscriber.IsInvoked); epService.EPRuntime.SendEvent(new SupportBean("F2", 1)); Assert.AreEqual(1, epService.EPRuntime.GetVariableValue("myint")); Assert.AreEqual("F2", epService.EPRuntime.GetVariableValue("mystring")); SendEvent(epService, "S4", 0); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "S1", "S2", "S3", "S4" }, subscriber.GetAndResetLastNewData()); stmt.Dispose(); }
private static void TryAssertion( RegressionEnvironment env, int days) { var subscriber = new SupportSubscriber(); env.Statement("s0").Subscriber = subscriber; SendEvent(env, "S1", 0); // now scheduled for output env.SendEventBean(new SupportBean("E1", 1)); Assert.AreEqual(0, env.Runtime.VariableService.GetVariableValue(null, "myvar")); Assert.IsFalse(subscriber.IsInvoked); SendTimeEvent(env, days, 8, 0, 1, 0); EPAssertionUtil.AssertEqualsExactOrder(new object[] {"S1"}, subscriber.GetAndResetLastNewData()); Assert.AreEqual(0, env.Runtime.VariableService.GetVariableValue(null, "myvar")); Assert.AreEqual(1, env.Runtime.VariableService.GetVariableValue(null, "count_insert_var")); SendEvent(env, "S2", 0); SendEvent(env, "S3", 0); SendTimeEvent(env, days, 8, 0, 2, 0); SendTimeEvent(env, days, 8, 0, 3, 0); env.SendEventBean(new SupportBean("E2", 1)); Assert.AreEqual(0, env.Runtime.VariableService.GetVariableValue(null, "myvar")); Assert.AreEqual(2, env.Runtime.VariableService.GetVariableValue(null, "count_insert_var")); Assert.IsFalse(subscriber.IsInvoked); SendTimeEvent(env, days, 8, 0, 4, 0); EPAssertionUtil.AssertEqualsExactOrder(new object[] {"S2", "S3"}, subscriber.GetAndResetLastNewData()); Assert.AreEqual(0, env.Runtime.VariableService.GetVariableValue(null, "myvar")); SendTimeEvent(env, days, 8, 0, 5, 0); Assert.IsFalse(subscriber.IsInvoked); env.SendEventBean(new SupportBean("E1", 1)); Assert.AreEqual(0, env.Runtime.VariableService.GetVariableValue(null, "myvar")); Assert.IsFalse(subscriber.IsInvoked); env.UndeployAll(); }
private void RunAssertion(int days, EPStatement stmt) { var subscriber = new SupportSubscriber(); stmt.Subscriber = subscriber; SendEvent("S1", 0); // now scheduled for output _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); Assert.AreEqual(0, _epService.EPRuntime.GetVariableValue("myvar")); Assert.IsFalse(subscriber.IsInvoked()); SendTimeEvent(days, 8, 0, 1, 0); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "S1" }, subscriber.GetAndResetLastNewData()); Assert.AreEqual(0, _epService.EPRuntime.GetVariableValue("myvar")); Assert.AreEqual(1, _epService.EPRuntime.GetVariableValue("count_insert_var")); SendEvent("S2", 0); SendEvent("S3", 0); SendTimeEvent(days, 8, 0, 2, 0); SendTimeEvent(days, 8, 0, 3, 0); _epService.EPRuntime.SendEvent(new SupportBean("E2", 1)); Assert.AreEqual(0, _epService.EPRuntime.GetVariableValue("myvar")); Assert.AreEqual(2, _epService.EPRuntime.GetVariableValue("count_insert_var")); Assert.IsFalse(subscriber.IsInvoked()); SendTimeEvent(days, 8, 0, 4, 0); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "S2", "S3" }, subscriber.GetAndResetLastNewData()); Assert.AreEqual(0, _epService.EPRuntime.GetVariableValue("myvar")); SendTimeEvent(days, 8, 0, 5, 0); Assert.IsFalse(subscriber.IsInvoked()); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); Assert.AreEqual(0, _epService.EPRuntime.GetVariableValue("myvar")); Assert.IsFalse(subscriber.IsInvoked()); stmt.Dispose(); }
public void Run(RegressionEnvironment env) { SendTimeEvent(env, 1, 8, 0, 0, 0); var expression = "@Name('s0') select Symbol from SupportMarketDataBean#length(2) output when current_timestamp - last_output_timestamp >= 2000"; var stmt = env.CompileDeploy(expression).Statement("s0"); var subscriber = new SupportSubscriber(); stmt.Subscriber = subscriber; SendEvent(env, "S1", 0); SendTimeEvent(env, 1, 8, 0, 1, 900); SendEvent(env, "S2", 0); SendTimeEvent(env, 1, 8, 0, 2, 0); Assert.IsFalse(subscriber.IsInvoked); SendEvent(env, "S3", 0); EPAssertionUtil.AssertEqualsExactOrder( new object[] {"S1", "S2", "S3"}, subscriber.GetAndResetLastNewData()); SendTimeEvent(env, 1, 8, 0, 3, 0); SendEvent(env, "S4", 0); SendTimeEvent(env, 1, 8, 0, 3, 500); SendEvent(env, "S5", 0); Assert.IsFalse(subscriber.IsInvoked); SendTimeEvent(env, 1, 8, 0, 4, 0); SendEvent(env, "S6", 0); EPAssertionUtil.AssertEqualsExactOrder( new object[] {"S4", "S5", "S6"}, subscriber.GetAndResetLastNewData()); env.UndeployAll(); }
public void TestSubscriberNamedWindowConsumerIterate() { _epService.EPAdministrator.CreateEPL( "create window MyWindow.win:keepall() as select * from SupportBean"); _epService.EPAdministrator.CreateEPL( "insert into MyWindow select * from SupportBean"); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); EPServiceProviderIsolated isolatedService = _epService.GetEPServiceIsolated( "isolatedStmts"); isolatedService.EPRuntime.SendEvent( new CurrentTimeEvent(Environment.TickCount)); var subscriber = new SupportSubscriber(); EPStatement stmtOne = _epService.EPAdministrator.CreateEPL( "select * from SupportBean"); stmtOne.Subscriber = subscriber; EPStatement stmtTwo = isolatedService.EPAdministrator.CreateEPL( "select * from MyWindow", null, null); isolatedService.EPAdministrator.AddStatement(stmtOne); IEnumerator <EventBean> iter = stmtTwo.GetEnumerator(); while (iter.MoveNext()) { EventBean theEvent = iter.Current; isolatedService.EPRuntime.SendEvent(theEvent.Underlying); } Assert.IsTrue(subscriber.IsInvoked()); }
private void RunAssertionSubscriberNamedWindowConsumerIterate(EPServiceProvider epService) { if (SupportConfigFactory.SkipTest(typeof(ExecClientIsolationUnit))) { return; } epService.EPAdministrator.CreateEPL("create window MyWindow#keepall as select * from SupportBean"); epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean"); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); EPServiceProviderIsolated isolatedService = epService.GetEPServiceIsolated("isolatedStmts"); isolatedService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeHelper.CurrentTimeMillis)); var subscriber = new SupportSubscriber(); EPStatement stmtOne = epService.EPAdministrator.CreateEPL("select * from SupportBean"); stmtOne.Subscriber = subscriber; EPStatement stmtTwo = isolatedService.EPAdministrator.CreateEPL("select * from MyWindow", null, null); isolatedService.EPAdministrator.AddStatement(stmtOne); IEnumerator <EventBean> iter = stmtTwo.GetEnumerator(); while (iter.MoveNext()) { EventBean theEvent = iter.Current; isolatedService.EPRuntime.SendEvent(theEvent.Underlying); } Assert.IsTrue(subscriber.IsInvoked); epService.EPAdministrator.DestroyAllStatements(); }
public void Run(RegressionEnvironment env) { var milestone = new AtomicLong(); var fieldsOne = new [] { "col1" }; var path = new RegressionPath(); var eplCtx = "@Name('context') create context SegmentedByString partition by TheString from SupportBean"; env.CompileDeploy(eplCtx, path); var epl = "@Name('s0') context SegmentedByString select sum(IntPrimitive) as col1 from SupportBean;\n"; env.CompileDeploy(epl, path).AddListener("s0"); env.MilestoneInc(milestone); env.SendEventBean(new SupportBean("G1", 3)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsOne, new object[] {3}); env.MilestoneInc(milestone); env.SendEventBean(new SupportBean("G2", 2)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsOne, new object[] {2}); env.MilestoneInc(milestone); env.SendEventBean(new SupportBean("G1", 4)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsOne, new object[] {7}); env.MilestoneInc(milestone); env.SendEventBean(new SupportBean("G2", 1)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsOne, new object[] {3}); env.MilestoneInc(milestone); env.SendEventBean(new SupportBean("G3", -1)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsOne, new object[] {-1}); env.MilestoneInc(milestone); env.UndeployModuleContaining("s0"); // test mixed with access var fieldsTwo = new [] { "col1","col2" }; env.CompileDeploy( "@Name('s0') context SegmentedByString " + "select sum(IntPrimitive) as col1, toArray(window(*).selectFrom(v->v.IntPrimitive)) as col2 " + "from SupportBean#keepall", path); env.AddListener("s0"); env.SendEventBean(new SupportBean("G1", 8)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsTwo, new object[] { 8, new object[] {8} }); env.SendEventBean(new SupportBean("G2", 5)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsTwo, new object[] { 5, new object[] {5} }); env.SendEventBean(new SupportBean("G1", 1)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsTwo, new object[] { 9, new object[] {8, 1} }); env.SendEventBean(new SupportBean("G2", 2)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsTwo, new object[] { 7, new object[] {5, 2} }); env.UndeployModuleContaining("s0"); // test only access var fieldsThree = new [] { "col1" }; env.CompileDeploy( "@Name('s0') context SegmentedByString " + "select toArray(window(*).selectFrom(v->v.IntPrimitive)) as col1 " + "from SupportBean#keepall", path); env.AddListener("s0"); env.SendEventBean(new SupportBean("G1", 8)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsThree, new object[] {new object[] {8}}); env.SendEventBean(new SupportBean("G2", 5)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsThree, new object[] {new object[] {5}}); env.SendEventBean(new SupportBean("G1", 1)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsThree, new object[] {new object[] {8, 1}}); env.SendEventBean(new SupportBean("G2", 2)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fieldsThree, new object[] {new object[] {5, 2}}); env.UndeployModuleContaining("s0"); // test subscriber var stmtFour = env.CompileDeploy( "@Name('s0') context SegmentedByString " + "select count(*) as col1 " + "from SupportBean", path) .Statement("s0"); var subs = new SupportSubscriber(); stmtFour.Subscriber = subs; env.SendEventBean(new SupportBean("G1", 1)); Assert.AreEqual(1L, subs.AssertOneGetNewAndReset()); env.SendEventBean(new SupportBean("G1", 1)); Assert.AreEqual(2L, subs.AssertOneGetNewAndReset()); env.SendEventBean(new SupportBean("G2", 2)); Assert.AreEqual(1L, subs.AssertOneGetNewAndReset()); env.UndeployAll(); }
public void TestGroupByEventForAll() { _epService.EPAdministrator.CreateEPL("@Name('context') create context SegmentedByString partition by TheString from SupportBean"); // test aggregation-only (no access) var fieldsOne = "col1".Split(','); var stmtOne = _epService.EPAdministrator.CreateEPL("@Name('A') context SegmentedByString " + "select Sum(IntPrimitive) as col1 " + "from SupportBean"); stmtOne.Events += _listener.Update; _epService.EPRuntime.SendEvent(new SupportBean("G1", 3)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { 3 }); _epService.EPRuntime.SendEvent(new SupportBean("G2", 2)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { 2 }); _epService.EPRuntime.SendEvent(new SupportBean("G1", 4)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { 7 }); _epService.EPRuntime.SendEvent(new SupportBean("G2", 1)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { 3 }); _epService.EPRuntime.SendEvent(new SupportBean("G3", -1)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { -1 }); stmtOne.Dispose(); // test mixed with access var fieldsTwo = "col1,col2".Split(','); var stmtTwo = _epService.EPAdministrator.CreateEPL("@Name('A') context SegmentedByString " + "select Sum(IntPrimitive) as col1, ToArray(window(*).SelectFrom(v=>v.IntPrimitive)) as col2 " + "from SupportBean.win:keepall()"); stmtTwo.Events += _listener.Update; _epService.EPRuntime.SendEvent(new SupportBean("G1", 8)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsTwo, new Object[] { 8, new Object[] { 8 } }); _epService.EPRuntime.SendEvent(new SupportBean("G2", 5)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsTwo, new Object[] { 5, new Object[] { 5 } }); _epService.EPRuntime.SendEvent(new SupportBean("G1", 1)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsTwo, new Object[] { 9, new Object[] { 8, 1 } }); _epService.EPRuntime.SendEvent(new SupportBean("G2", 2)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsTwo, new Object[] { 7, new Object[] { 5, 2 } }); stmtTwo.Dispose(); // test only access var fieldsThree = "col1".Split(','); var stmtThree = _epService.EPAdministrator.CreateEPL("@Name('A') context SegmentedByString " + "select ToArray(window(*).SelectFrom(v=>v.IntPrimitive)) as col1 " + "from SupportBean.win:keepall()"); stmtThree.Events += _listener.Update; _epService.EPRuntime.SendEvent(new SupportBean("G1", 8)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsThree, new Object[] { new Object[] { 8 } }); _epService.EPRuntime.SendEvent(new SupportBean("G2", 5)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsThree, new Object[] { new Object[] { 5 } }); _epService.EPRuntime.SendEvent(new SupportBean("G1", 1)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsThree, new Object[] { new Object[] { 8, 1 } }); _epService.EPRuntime.SendEvent(new SupportBean("G2", 2)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsThree, new Object[] { new Object[] { 5, 2 } }); stmtThree.Dispose(); // test subscriber var stmtFour = _epService.EPAdministrator.CreateEPL("@Name('A') context SegmentedByString " + "select Count(*) as col1 " + "from SupportBean"); var subs = new SupportSubscriber(); stmtFour.Subscriber = subs; _epService.EPRuntime.SendEvent(new SupportBean("G1", 1)); Assert.AreEqual(1L, subs.AssertOneGetNewAndReset()); _epService.EPRuntime.SendEvent(new SupportBean("G1", 1)); Assert.AreEqual(2L, subs.AssertOneGetNewAndReset()); _epService.EPRuntime.SendEvent(new SupportBean("G2", 2)); Assert.AreEqual(1L, subs.AssertOneGetNewAndReset()); }
private void RunAssertionGroupByEventForAll(EPServiceProvider epService) { epService.EPAdministrator.CreateEPL( "@Name('context') create context SegmentedByString partition by TheString from SupportBean"); // test aggregation-only (no access) string[] fieldsOne = "col1".Split(','); EPStatement stmtOne = epService.EPAdministrator.CreateEPL( "@Name('A') context SegmentedByString " + "select sum(IntPrimitive) as col1 " + "from SupportBean"); var listener = new SupportUpdateListener(); stmtOne.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("G1", 3)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsOne, new object[] { 3 }); epService.EPRuntime.SendEvent(new SupportBean("G2", 2)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsOne, new object[] { 2 }); epService.EPRuntime.SendEvent(new SupportBean("G1", 4)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsOne, new object[] { 7 }); epService.EPRuntime.SendEvent(new SupportBean("G2", 1)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsOne, new object[] { 3 }); epService.EPRuntime.SendEvent(new SupportBean("G3", -1)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsOne, new object[] { -1 }); stmtOne.Dispose(); // test mixed with access string[] fieldsTwo = "col1,col2".Split(','); EPStatement stmtTwo = epService.EPAdministrator.CreateEPL( "@Name('A') context SegmentedByString " + "select sum(IntPrimitive) as col1, toArray(window(*).selectFrom(v=>v.IntPrimitive)) as col2 " + "from SupportBean#keepall"); stmtTwo.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("G1", 8)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), fieldsTwo, new object[] { 8, new object[] { 8 } }); epService.EPRuntime.SendEvent(new SupportBean("G2", 5)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), fieldsTwo, new object[] { 5, new object[] { 5 } }); epService.EPRuntime.SendEvent(new SupportBean("G1", 1)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), fieldsTwo, new object[] { 9, new object[] { 8, 1 } }); epService.EPRuntime.SendEvent(new SupportBean("G2", 2)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), fieldsTwo, new object[] { 7, new object[] { 5, 2 } }); stmtTwo.Dispose(); // test only access string[] fieldsThree = "col1".Split(','); EPStatement stmtThree = epService.EPAdministrator.CreateEPL( "@Name('A') context SegmentedByString " + "select toArray(window(*).selectFrom(v=>v.IntPrimitive)) as col1 " + "from SupportBean#keepall"); stmtThree.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("G1", 8)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), fieldsThree, new object[] { new object[] { 8 } }); epService.EPRuntime.SendEvent(new SupportBean("G2", 5)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), fieldsThree, new object[] { new object[] { 5 } }); epService.EPRuntime.SendEvent(new SupportBean("G1", 1)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), fieldsThree, new object[] { new object[] { 8, 1 } }); epService.EPRuntime.SendEvent(new SupportBean("G2", 2)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), fieldsThree, new object[] { new object[] { 5, 2 } }); stmtThree.Dispose(); // test subscriber EPStatement stmtFour = epService.EPAdministrator.CreateEPL( "@Name('A') context SegmentedByString " + "select count(*) as col1 " + "from SupportBean"); var subs = new SupportSubscriber(); stmtFour.Subscriber = subs; epService.EPRuntime.SendEvent(new SupportBean("G1", 1)); Assert.AreEqual(1L, subs.AssertOneGetNewAndReset()); epService.EPRuntime.SendEvent(new SupportBean("G1", 1)); Assert.AreEqual(2L, subs.AssertOneGetNewAndReset()); epService.EPRuntime.SendEvent(new SupportBean("G2", 2)); Assert.AreEqual(1L, subs.AssertOneGetNewAndReset()); epService.EPAdministrator.DestroyAllStatements(); }