public void TestInvocationTargetEx() { // smoke test, need to consider log file; test for ESPER-331 EPStatement stmt = _epAdmin.CreateEPL("select * from SupportMarketDataBean"); stmt.Subscriber = new DummySubscriberException(); stmt.Events += (sender, args) => { throw new ApplicationException("test exception 1"); }; stmt.Events += (sender, args) => { throw new ApplicationException("test exception 2"); }; stmt.AddEventHandlerWithReplay( (sender, args) => { throw new ApplicationException("test exception 3"); }); // no exception expected _epService.EPRuntime.SendEvent(new SupportMarketDataBean("IBM", 0, 0L, "")); }
private void RunAssertionSingleColumnConversion(EPServiceProvider epService) { var variant = new ConfigurationVariantStream(); variant.AddEventTypeName("SupportBean"); variant.AddEventTypeName("SupportBeanVariantStream"); epService.EPAdministrator.Configuration.AddVariantStream("AllEvents", variant); epService.EPAdministrator.CreateEPL("insert into AllEvents select * from SupportBean"); epService.EPAdministrator.CreateEPL("create window MainEventWindow#length(10000) as AllEvents"); epService.EPAdministrator.CreateEPL("insert into MainEventWindow select " + GetType().Name + ".PreProcessEvent(event) from AllEvents as event"); EPStatement statement = epService.EPAdministrator.CreateEPL("select * from MainEventWindow where TheString = 'E'"); statement.AddEventHandlerWithReplay((new SupportUpdateListener()).Update); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); epService.EPAdministrator.DestroyAllStatements(); }
public void TestSingleColumnConversion() { _epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanVariantStream", typeof(SupportBeanVariantStream)); _epService.EPAdministrator.Configuration.AddImport(GetType().FullName); ConfigurationVariantStream variant = new ConfigurationVariantStream(); variant.AddEventTypeName("SupportBean"); variant.AddEventTypeName("SupportBeanVariantStream"); _epService.EPAdministrator.Configuration.AddVariantStream("AllEvents", variant); _epService.EPAdministrator.CreateEPL("insert into AllEvents select * from SupportBean"); _epService.EPAdministrator.CreateEPL("create window MainEventWindow.win:length(10000) as AllEvents"); _epService.EPAdministrator.CreateEPL("insert into MainEventWindow select " + GetType().Name + ".PreProcessEvent(event) from AllEvents as event"); EPStatement statement = _epService.EPAdministrator.CreateEPL("select * from MainEventWindow where TheString = 'E'"); statement.AddEventHandlerWithReplay(new SupportUpdateListener().Update); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); }
private void RunAssertionListenerWithReplay(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); EPStatementSPI stmt = (EPStatementSPI)epService.EPAdministrator.CreateEPL("select * from SupportBean#length(2)"); Assert.IsFalse(stmt.StatementContext.IsStatelessSelect); var listener = new SupportUpdateListener(); // test empty statement stmt.AddEventHandlerWithReplay(listener.Update); Assert.IsTrue(listener.IsInvoked); Assert.AreEqual(1, listener.NewDataList.Count); Assert.IsNull(listener.NewDataList[0]); listener.Reset(); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); Assert.AreEqual("E1", listener.AssertOneGetNewAndReset().Get("TheString")); stmt.Dispose(); listener.Reset(); // test 1 event stmt = (EPStatementSPI)epService.EPAdministrator.CreateEPL("select * from SupportBean#length(2)"); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); stmt.AddEventHandlerWithReplay(listener.Update); Assert.AreEqual("E1", listener.AssertOneGetNewAndReset().Get("TheString")); stmt.Dispose(); listener.Reset(); // test 2 events stmt = (EPStatementSPI)epService.EPAdministrator.CreateEPL("select * from SupportBean#length(2)"); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); epService.EPRuntime.SendEvent(new SupportBean("E2", 1)); stmt.AddEventHandlerWithReplay(listener.Update); EPAssertionUtil.AssertPropsPerRow(listener.LastNewData, new string[] { "TheString" }, new object[][] { new object[] { "E1" }, new object[] { "E2" } }); // test stopped statement and destroyed statement listener.Reset(); stmt.Stop(); stmt.RemoveAllEventHandlers(); stmt.AddEventHandlerWithReplay(listener.Update); Assert.IsTrue(listener.IsInvoked); Assert.AreEqual(1, listener.NewDataList.Count); Assert.IsNull(listener.NewDataList[0]); listener.Reset(); // test destroyed listener.Reset(); stmt.Dispose(); try { stmt.AddEventHandlerWithReplay(listener.Update); Assert.Fail(); } catch (IllegalStateException) { // } stmt.RemoveAllEventHandlers(); stmt.Events -= listener.Update; stmt.Events -= (new SupportStmtAwareUpdateListener()).Update; stmt.Subscriber = new SupportSubscriber(); Assert.NotNull(stmt.Annotations); Assert.NotNull(stmt.State); Assert.NotNull(stmt.Subscriber); try { stmt.Events += listener.Update; Assert.Fail(); } catch (IllegalStateException) { // } try { stmt.Events += (new SupportStmtAwareUpdateListener()).Update; Assert.Fail(); } catch (IllegalStateException) { // } // test named window and having-clause epService.EPAdministrator.DeploymentAdmin.ParseDeploy( "create window SupportBeanWindow#keepall as SupportBean;\n" + "insert into SupportBeanWindow select * from SupportBean;\n"); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); EPStatement stmtWHaving = epService.EPAdministrator.CreateEPL("select TheString, IntPrimitive from SupportBeanWindow having IntPrimitive > 4000"); stmtWHaving.AddEventHandlerWithReplay(listener.Update); epService.EPAdministrator.DestroyAllStatements(); }