private void RunAssertionStmtNameDynamic(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " + "create map schema SingleProp (id string), " + "EPStatementSource -> thedata<SingleProp> {" + " statementName : 'MyStatement'," + "} " + "DefaultSupportCaptureOp(thedata) {}"); var captureOp = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager()); var options = new EPDataFlowInstantiationOptions() .OperatorProvider(new DefaultSupportGraphOpProvider(captureOp)); EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options); Assert.IsNull(df.UserObject); Assert.IsNull(df.InstanceId); df.Start(); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); Assert.AreEqual(0, captureOp.Current.Length); EPStatement stmt = epService.EPAdministrator.CreateEPL("@Name('MyStatement') select TheString as id from SupportBean"); epService.EPRuntime.SendEvent(new SupportBean("E2", 2)); captureOp.WaitForInvocation(100, 1); EPAssertionUtil.AssertProps( epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "E2" }); stmt.Stop(); epService.EPRuntime.SendEvent(new SupportBean("E3", 3)); Assert.AreEqual(0, captureOp.Current.Length); stmt.Start(); epService.EPRuntime.SendEvent(new SupportBean("E4", 4)); captureOp.WaitForInvocation(100, 1); EPAssertionUtil.AssertProps( epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "E4" }); stmt.Dispose(); epService.EPRuntime.SendEvent(new SupportBean("E5", 5)); Assert.AreEqual(0, captureOp.Current.Length); epService.EPAdministrator.CreateEPL("@Name('MyStatement') select 'X'||TheString||'X' as id from SupportBean"); epService.EPRuntime.SendEvent(new SupportBean("E6", 6)); captureOp.WaitForInvocation(100, 1); EPAssertionUtil.AssertProps( epService.Container, captureOp.GetCurrentAndReset()[0], "id".Split(','), new object[] { "XE6X" }); df.Cancel(); epService.EPAdministrator.DestroyAllStatements(); }
private void RunAssertionSchemaObjectArray(EPServiceProvider epService) { epService.EPAdministrator.CreateEPL("create objectarray schema MyEventOA(p0 string, p1 long)"); RunAssertionOA(epService, false); RunAssertionOA(epService, true); // test collector epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " + "EventBusSource -> ReceivedStream<MyEventOA> {filter: p0 like 'A%'} " + "DefaultSupportCaptureOp(ReceivedStream) {}"); var collector = new MyCollector(); var future = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager()); var options = new EPDataFlowInstantiationOptions() .OperatorProvider(new DefaultSupportGraphOpProvider(future)) .ParameterProvider(new DefaultSupportGraphParamProvider( Collections.SingletonDataMap("collector", collector))); EPDataFlowInstance instance = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options); instance.Start(); epService.EPRuntime.SendEvent(new object[] { "B", 100L }, "MyEventOA"); Thread.Sleep(50); Assert.IsNull(collector.Last); epService.EPRuntime.SendEvent(new object[] { "A", 101L }, "MyEventOA"); future.WaitForInvocation(100, 1); Assert.IsNotNull(collector.Last.Emitter); Assert.AreEqual("MyEventOA", collector.Last.Event.EventType.Name); Assert.AreEqual(false, collector.Last.IsSubmitEventBean); epService.EPAdministrator.DestroyAllStatements(); }
public void TestSchemaObjectArray() { _epService.EPAdministrator.CreateEPL("create objectarray schema MyEvent(p0 string, p1 long)"); RunAssertionOA(false); RunAssertionOA(true); // test collector _epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " + "EventBusSource -> ReceivedStream<MyEvent> {filter: p0 like 'A%'} " + "DefaultSupportCaptureOp(ReceivedStream) {}"); MyCollector collector = new MyCollector(); DefaultSupportCaptureOp future = new DefaultSupportCaptureOp(); EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions() .OperatorProvider(new DefaultSupportGraphOpProvider(future)) .ParameterProvider(new DefaultSupportGraphParamProvider(Collections.SingletonDataMap("collector", collector))); EPDataFlowInstance instance = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options); instance.Start(); _epService.EPRuntime.SendEvent(new Object[] { "B", 100L }, "MyEvent"); Thread.Sleep(50); Assert.IsNull(collector.GetLast()); _epService.EPRuntime.SendEvent(new Object[] { "A", 101L }, "MyEvent"); future.WaitForInvocation(100, 1); Assert.NotNull(collector.GetLast().Emitter); Assert.AreEqual("MyEvent", collector.GetLast().Event.EventType.Name); Assert.AreEqual(false, collector.GetLast().IsSubmitEventBean); }
private static void RunAssertionAllTypes( RegressionEnvironment env, string typeName, SendableEvent[] events) { env.CompileDeploy( "@Name('flow') create dataflow MyDataFlowOne " + "EventBusSource -> ReceivedStream<" + typeName + "> {} " + "DefaultSupportCaptureOp(ReceivedStream) {}"); var future = new DefaultSupportCaptureOp(); var options = new EPDataFlowInstantiationOptions() .WithOperatorProvider(new DefaultSupportGraphOpProvider(future)); var eventService = (EventServiceSendEventCommon) env.EventService; events[0].Send(eventService); Assert.AreEqual(0, future.Current.Length); var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options); events[0].Send(eventService); Assert.AreEqual(0, future.Current.Length); df.Start(); // send events for (var i = 0; i < events.Length; i++) { events[i].Send(eventService); } // assert future.WaitForInvocation(200, events.Length); var rows = future.GetCurrentAndReset(); Assert.AreEqual(events.Length, rows.Length); for (var i = 0; i < events.Length; i++) { Assert.AreSame(events[i].Underlying, rows[i]); } df.Cancel(); events[0].Send(eventService); Sleep(50); Assert.AreEqual(0, future.Current.Length); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var compiled = env.CompileWBusPublicType("create objectarray schema MyEventOA(p0 string, p1 long)"); env.Deploy(compiled); path.Add(compiled); RunAssertionOA(env, path, false); RunAssertionOA(env, path, true); // test collector env.CompileDeploy( "@Name('flow') create dataflow MyDataFlowOne " + "EventBusSource -> ReceivedStream<MyEventOA> {filter: p0 like 'A%'} " + "DefaultSupportCaptureOp(ReceivedStream) {}", path); var collector = new MyCollector(); var future = new DefaultSupportCaptureOp(); var options = new EPDataFlowInstantiationOptions() .WithOperatorProvider(new DefaultSupportGraphOpProvider(future)) .WithParameterProvider( new DefaultSupportGraphParamProvider( Collections.SingletonDataMap("collector", collector))); var instance = env.Runtime.DataFlowService.Instantiate( env.DeploymentId("flow"), "MyDataFlowOne", options); instance.Start(); env.SendEventObjectArray(new object[] {"B", 100L}, "MyEventOA"); Sleep(50); Assert.IsNull(collector.Last); env.SendEventObjectArray(new object[] {"A", 101L}, "MyEventOA"); future.WaitForInvocation(100, 1); Assert.IsNotNull(collector.Last.Emitter); Assert.AreEqual("MyEventOA", collector.Last.Event.EventType.Name); Assert.AreEqual(false, collector.Last.IsSubmitEventBean); instance.Cancel(); env.UndeployAll(); }
private void RunAssertionAllTypes(EPServiceProvider epService, string typeName, SendableEvent[] events) { EPStatement stmtGraph = epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " + "EventBusSource -> ReceivedStream<" + typeName + "> {} " + "DefaultSupportCaptureOp(ReceivedStream) {}"); var future = new DefaultSupportCaptureOp(SupportContainer.Instance.LockManager()); var options = new EPDataFlowInstantiationOptions() .OperatorProvider(new DefaultSupportGraphOpProvider(future)); events[0].Send(epService.EPRuntime); Assert.AreEqual(0, future.Current.Length); EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options); events[0].Send(epService.EPRuntime); Assert.AreEqual(0, future.Current.Length); df.Start(); // send events for (int i = 0; i < events.Length; i++) { events[i].Send(epService.EPRuntime); } // assert future.WaitForInvocation(200, events.Length); object[] rows = future.GetCurrentAndReset(); Assert.AreEqual(events.Length, rows.Length); for (int i = 0; i < events.Length; i++) { Assert.AreSame(events[i].Underlying, rows[i]); } df.Cancel(); events[0].Send(epService.EPRuntime); Thread.Sleep(50); Assert.AreEqual(0, future.Current.Length); stmtGraph.Dispose(); }
public void TestStatementFilter() { _epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_A)); _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_B)); // one statement exists before the data flow var stmt = _epService.EPAdministrator.CreateEPL("select id from SupportBean_B"); _epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " + "create schema AllObjects Object," + "EPStatementSource -> thedata<AllObjects> {} " + "DefaultSupportCaptureOp(thedata) {}"); var captureOp = new DefaultSupportCaptureOp(); var options = new EPDataFlowInstantiationOptions(); var myFilter = new MyFilter(); options.ParameterProvider(new DefaultSupportGraphParamProvider(Collections.SingletonDataMap("statementFilter", myFilter))); options.OperatorProvider(new DefaultSupportGraphOpProvider(captureOp)); var df = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options); df.Start(); _epService.EPRuntime.SendEvent(new SupportBean_B("B1")); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps(captureOp.GetCurrentAndReset()[0], "id".Split(','), new Object[] { "B1" }); _epService.EPAdministrator.CreateEPL("select TheString, IntPrimitive from SupportBean"); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps(captureOp.GetCurrentAndReset()[0], "TheString,IntPrimitive".Split(','), new Object[] { "E1", 1 }); var stmtTwo = _epService.EPAdministrator.CreateEPL("select id from SupportBean_A"); _epService.EPRuntime.SendEvent(new SupportBean_A("A1")); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps(captureOp.GetCurrentAndReset()[0], "id".Split(','), new Object[] { "A1" }); stmtTwo.Stop(); _epService.EPRuntime.SendEvent(new SupportBean_A("A2")); Thread.Sleep(50); Assert.AreEqual(0, captureOp.GetCurrent().Length); stmtTwo.Start(); _epService.EPRuntime.SendEvent(new SupportBean_A("A3")); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps(captureOp.GetCurrentAndReset()[0], "id".Split(','), new Object[] { "A3" }); _epService.EPRuntime.SendEvent(new SupportBean_B("B2")); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps(captureOp.GetCurrentAndReset()[0], "id".Split(','), new Object[] { "B2" }); df.Cancel(); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); _epService.EPRuntime.SendEvent(new SupportBean_A("A1")); _epService.EPRuntime.SendEvent(new SupportBean_B("B3")); Assert.AreEqual(0, captureOp.GetCurrent().Length); }
public void Run(RegressionEnvironment env) { // one statement exists before the data flow env.CompileDeploy("select Id from SupportBean_B"); env.CompileDeploy( "@Name('flow') create dataflow MyDataFlowOne " + "create schema AllObjects as System.Object," + "EPStatementSource -> thedata<AllObjects> {} " + "DefaultSupportCaptureOp(thedata) {}"); var captureOp = new DefaultSupportCaptureOp(env.Container.LockManager()); var options = new EPDataFlowInstantiationOptions(); var myFilter = new MyFilter(); options.WithParameterProvider( new DefaultSupportGraphParamProvider( Collections.SingletonMap<string, object>("statementFilter", myFilter))); options.WithOperatorProvider(new DefaultSupportGraphOpProvider(captureOp)); var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options); df.Start(); env.SendEventBean(new SupportBean_B("B1")); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps( env.Container, captureOp.GetCurrentAndReset()[0], new [] { "Id" }, new object[] {"B1"}); env.CompileDeploy("select TheString, IntPrimitive from SupportBean"); env.SendEventBean(new SupportBean("E1", 1)); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps( env.Container, captureOp.GetCurrentAndReset()[0], new [] { "TheString","IntPrimitive" }, new object[] {"E1", 1}); env.CompileDeploy("@Name('s2') select Id from SupportBean_A"); env.SendEventBean(new SupportBean_A("A1")); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps( env.Container, captureOp.GetCurrentAndReset()[0], new [] { "Id" }, new object[] {"A1"}); env.UndeployModuleContaining("s2"); env.SendEventBean(new SupportBean_A("A2")); Sleep(50); Assert.AreEqual(0, captureOp.Current.Length); env.CompileDeploy("@Name('s2') select Id from SupportBean_A"); env.SendEventBean(new SupportBean_A("A3")); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps( env.Container, captureOp.GetCurrentAndReset()[0], new [] { "Id" }, new object[] {"A3"}); env.SendEventBean(new SupportBean_B("B2")); captureOp.WaitForInvocation(200, 1); EPAssertionUtil.AssertProps( env.Container, captureOp.GetCurrentAndReset()[0], new [] { "Id" }, new object[] {"B2"}); df.Cancel(); env.SendEventBean(new SupportBean("E1", 1)); env.SendEventBean(new SupportBean_A("A1")); env.SendEventBean(new SupportBean_B("B3")); Assert.AreEqual(0, captureOp.Current.Length); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { env.CompileDeploy( "@Name('flow') create dataflow MyDataFlowOne " + "create map schema SingleProp (Id string), " + "EPStatementSource -> thedata<SingleProp> {" + " statementDeploymentId : 'MyDeploymentId'," + " statementName : 'MyStatement'," + "} " + "DefaultSupportCaptureOp(thedata) {}"); var captureOp = new DefaultSupportCaptureOp(); var options = new EPDataFlowInstantiationOptions() .WithOperatorProvider(new DefaultSupportGraphOpProvider(captureOp)); var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options); Assert.IsNull(df.UserObject); Assert.IsNull(df.InstanceId); df.Start(); env.SendEventBean(new SupportBean("E1", 1)); Assert.AreEqual(0, captureOp.Current.Length); var epl = "@Name('MyStatement') select TheString as Id from SupportBean"; var compiled = env.Compile(epl); try { env.Deployment.Deploy(compiled, new DeploymentOptions().WithDeploymentId("MyDeploymentId")); } catch (EPDeployException e) { Assert.Fail(e.Message); } env.SendEventBean(new SupportBean("E2", 2)); captureOp.WaitForInvocation(100, 1); EPAssertionUtil.AssertProps( env.Container, captureOp.GetCurrentAndReset()[0], new [] { "Id" }, new object[] {"E2"}); env.UndeployModuleContaining("MyStatement"); env.SendEventBean(new SupportBean("E3", 3)); Assert.AreEqual(0, captureOp.Current.Length); try { env.Deployment.Deploy(compiled, new DeploymentOptions().WithDeploymentId("MyDeploymentId")); } catch (EPDeployException e) { Assert.Fail(e.Message); } env.SendEventBean(new SupportBean("E4", 4)); captureOp.WaitForInvocation(100, 1); EPAssertionUtil.AssertProps( env.Container, captureOp.GetCurrentAndReset()[0], new [] { "Id" }, new object[] {"E4"}); env.UndeployModuleContaining("MyStatement"); env.SendEventBean(new SupportBean("E5", 5)); Assert.AreEqual(0, captureOp.Current.Length); compiled = env.Compile("@Name('MyStatement') select 'X'||TheString||'X' as Id from SupportBean"); try { env.Deployment.Deploy(compiled, new DeploymentOptions().WithDeploymentId("MyDeploymentId")); } catch (EPDeployException e) { Assert.Fail(e.Message); } env.SendEventBean(new SupportBean("E6", 6)); captureOp.WaitForInvocation(100, 1); EPAssertionUtil.AssertProps( env.Container, captureOp.GetCurrentAndReset()[0], new [] { "Id" }, new object[] {"XE6X"}); df.Cancel(); env.UndeployAll(); }