public void TestCreateTableArray() { _epService.EPAdministrator.CreateEPL("create schema SecurityData (name String, roles String[])"); _epService.EPAdministrator.CreateEPL("create window SecurityEvent.win:time(30 sec) (ipAddress string, userId String, secData SecurityData, historySecData SecurityData[])"); // create window var stmtTextCreate = "create window MyWindow.win:keepall() (myvalue string[])"; var stmtCreate = _epService.EPAdministrator.CreateEPL(stmtTextCreate); stmtCreate.AddListener(_listenerWindow); // create insert into var stmtTextInsertOne = "insert into MyWindow select {'a','b'} as myvalue from " + typeof(SupportBean).FullName; _epService.EPAdministrator.CreateEPL(stmtTextInsertOne); SendSupportBean("E1", 1L, 10L); var values = (string[])_listenerWindow.AssertOneGetNewAndReset().Get("myvalue"); EPAssertionUtil.AssertEqualsExactOrder(values, new string[] { "a", "b" }); }
public void TestTwoByTwoEntryElement() { var list1 = new List <EventBean>(); list1.Add(events.Get("a")); list1.Add(events.Get("b")); var keyB = new HashableMultiKey(new object[] { "keyB" }); testMap.Put(keyB, list1); var list2 = new List <EventBean>(); list2.Add(events.Get("c")); list2.Add(events.Get("d")); var keyC = new HashableMultiKey(new object[] { "keyC" }); testMap.Put(keyC, list2); IEnumerator <EventBean> enumerator = testMap.GetMultiLevelEnumerator(); EPAssertionUtil.AssertEqualsExactOrder(new[] { events.Get("a"), events.Get("b"), events.Get("c"), events.Get("d") }, enumerator); }
public void TestTypes() { object[] expected = { 2, 3L, 4f, 5.0d, "abc", new byte[] { 10, 20 }, (byte)20, (short)21, true, new MyBean("E1") }; var classes = new Type[expected.Length]; for (var i = 0; i < expected.Length; i++) { classes[i] = expected.GetType(); } var serializers = SerializerFactory.GetSerializers(classes); var bytes = SerializerFactory.Serialize(serializers, expected); var result = SerializerFactory.Deserialize(expected.Length, bytes, serializers); EPAssertionUtil.AssertEqualsExactOrder(expected, result); // null values are simply not serialized bytes = SerializerFactory.Serialize(new[] { SerializerFactory.GetSerializer(typeof(int?)) }, new object[] { null }); Assert.AreEqual(0, bytes.Length); }
public void TestAcyclicTopDownOrder() { IDictionary<string, ICollection<string>> graph = new LinkedHashMap<string, ICollection<string>>(); Add(graph, "1_1", "R2"); Add(graph, "A", "R1"); Add(graph, "A", "R2"); EPAssertionUtil.AssertEqualsExactOrder(new [] { "R1","R2","1_1","A" }, GraphUtil.GetTopDownOrder(graph).ToArray()); Add(graph, "R1", "R2"); EPAssertionUtil.AssertEqualsExactOrder(new [] { "R2","1_1","R1","A" }, GraphUtil.GetTopDownOrder(graph).ToArray()); Add(graph, "1_1", "A"); EPAssertionUtil.AssertEqualsExactOrder(new [] { "R2","R1","A","1_1" }, GraphUtil.GetTopDownOrder(graph).ToArray()); Add(graph, "0", "1_1"); EPAssertionUtil.AssertEqualsExactOrder(new [] { "R2","R1","A","1_1","0" }, GraphUtil.GetTopDownOrder(graph).ToArray()); Add(graph, "R1", "0"); TryInvalid(graph, "Circular dependency detected between [\"0\", \"R1\", \"A\", \"1_1\"]"); }
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 void RunAssertionFireAndForget(EPServiceProvider epService) { SupportVirtualDW window = RegisterTypeSetMapData(epService); // test no-criteria FAF EPOnDemandQueryResult result = epService.EPRuntime.ExecuteQuery("select col1 from MyVDW vdw"); AssertIndexSpec(window.LastRequestedIndex, "", ""); Assert.AreEqual("MyVDW", window.LastRequestedIndex.NamedWindowName); Assert.AreEqual(-1, window.LastRequestedIndex.StatementId); Assert.IsNull(window.LastRequestedIndex.StatementName); Assert.IsNotNull(window.LastRequestedIndex.StatementAnnotations); Assert.IsTrue(window.LastRequestedIndex.IsFireAndForget); EPAssertionUtil.AssertProps(result.Array[0], "col1".Split(','), new object[] { "key1" }); EPAssertionUtil.AssertEqualsExactOrder(new Object[0], window.LastAccessKeys); // test single-criteria FAF result = epService.EPRuntime.ExecuteQuery("select col1 from MyVDW vdw where col1='key1'"); AssertIndexSpec(window.LastRequestedIndex, "col1=(System.String)", ""); EPAssertionUtil.AssertProps(result.Array[0], "col1".Split(','), new object[] { "key1" }); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "key1" }, window.LastAccessKeys); // test multi-criteria subquery result = epService.EPRuntime.ExecuteQuery("select col1 from MyVDW vdw where col1='key1' and col2='key2' and col3 between 5 and 15"); AssertIndexSpec(window.LastRequestedIndex, "col1=(System.String)|col2=(System.String)", "col3[,](" + Name.Clean <double>(false) + ")"); EPAssertionUtil.AssertProps(result.Array[0], "col1".Split(','), new object[] { "key1" }); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { "key1", "key2", new VirtualDataWindowKeyRange(5d, 15d) }, window.LastAccessKeys); // test multi-criteria subquery result = epService.EPRuntime.ExecuteQuery("select col1 from MyVDW vdw where col1='key1' and col2>'key0' and col3 between 5 and 15"); AssertIndexSpec(window.LastRequestedIndex, "col1=(System.String)", "col3[,](" + Name.Clean <double>(false) + ")|col2>(System.String)"); EPAssertionUtil.AssertProps(result.Array[0], "col1".Split(','), new object[] { "key1" }); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { "key1", new VirtualDataWindowKeyRange(5d, 15d), "key0" }, window.LastAccessKeys); DestroyStmtsRemoveTypes(epService); }
private void RunAssertion( RegressionEnvironment env, RegressionPath path, string typePrefix, FunctionSendEventWType sender, object root, object type1, object type2, object type21) { var typeNames = new [] { "Type_Root","Type_1","Type_2","Type_2_1" }; var statements = new EPStatement[4]; var listeners = new SupportUpdateListener[4]; for (var i = 0; i < typeNames.Length; i++) { env.CompileDeploy("@Name('s" + i + "') select * from " + typePrefix + "_" + typeNames[i], path); statements[i] = env.Statement("s" + i); listeners[i] = new SupportUpdateListener(); statements[i].AddListener(listeners[i]); } sender.Invoke(env, root, typePrefix + "_" + typeNames[0]); EPAssertionUtil.AssertEqualsExactOrder( new[] {true, false, false, false}, GetInvokedFlagsAndReset(listeners)); sender.Invoke(env, type1, typePrefix + "_" + typeNames[1]); EPAssertionUtil.AssertEqualsExactOrder( new[] {true, true, false, false}, GetInvokedFlagsAndReset(listeners)); sender.Invoke(env, type2, typePrefix + "_" + typeNames[2]); EPAssertionUtil.AssertEqualsExactOrder( new[] {true, false, true, false}, GetInvokedFlagsAndReset(listeners)); sender.Invoke(env, type21, typePrefix + "_" + typeNames[3]); EPAssertionUtil.AssertEqualsExactOrder(new[] {true, false, true, true}, GetInvokedFlagsAndReset(listeners)); env.UndeployAll(); }
public void TestViewPush() { // Set up a feed for the view under test - it will have a depth of 3 trades SupportStreamImpl stream = new SupportStreamImpl(typeof(SupportBean_A), 3); stream.AddView(_myView); IDictionary <String, EventBean> events = EventFactoryHelper.MakeEventMap( new String[] { "a0", "a1", "b0", "c0", "c1", "c2", "d0", "e0" }); SupportViewDataChecker.CheckOldData(_childView, null); SupportViewDataChecker.CheckNewData(_childView, null); EPAssertionUtil.AssertEqualsExactOrder(null, _myView.GetEnumerator()); // View should keep the last element for iteration, should report new data as it arrives stream.Insert(new EventBean[] { events.Get("a0"), events.Get("a1") }); SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("a0") }); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("a0"), events.Get("a1") }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("a1") }, _myView.GetEnumerator()); stream.Insert(new EventBean[] { events.Get("b0") }); SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("a1") }); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("b0") }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("b0") }, _myView.GetEnumerator()); stream.Insert(new EventBean[] { events.Get("c0"), events.Get("c1"), events.Get("c2") }); SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("b0"), events.Get("c0"), events.Get("c1") }); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("c0"), events.Get("c1"), events.Get("c2") }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("c2") }, _myView.GetEnumerator()); stream.Insert(new EventBean[] { events.Get("d0") }); SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("c2") }); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("d0") }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("d0") }, _myView.GetEnumerator()); stream.Insert(new EventBean[] { events.Get("e0") }); SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { events.Get("d0") }); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { events.Get("e0") }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { events.Get("e0") }, _myView.GetEnumerator()); }
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(); }
public void Run(RegressionEnvironment env) { var epl = "@Name('context') create context CategoryContext\n" + "group TheString = 'A' as cat1,\n" + "group TheString = 'B' as cat2 \n" + "from SupportBean;\n" + "@Name('s0') context CategoryContext select count(*) as c0, context.label as c1 from SupportBean;\n"; env.CompileDeployAddListenerMileZero(epl, "s0"); var deploymentIdContext = env.DeploymentId("context"); var statementNames = env.Runtime.ContextPartitionService.GetContextStatementNames( deploymentIdContext, "CategoryContext"); EPAssertionUtil.AssertEqualsExactOrder(statementNames, new [] { "s0" }); Assert.AreEqual( 1, env.Runtime.ContextPartitionService.GetContextNestingLevel(deploymentIdContext, "CategoryContext")); var ids = env.Runtime.ContextPartitionService.GetContextPartitionIds( deploymentIdContext, "CategoryContext", new ContextPartitionSelectorAll()); EPAssertionUtil.AssertEqualsExactOrder(new[] {0, 1}, ids.ToArray()); SendAssert(env, "A", 1, "cat1", 1L); SendAssert(env, "C", 2, null, null); env.Milestone(1); SendAssert(env, "B", 3, "cat2", 1L); SendAssert(env, "A", 4, "cat1", 2L); env.Milestone(2); SendAssert(env, "A", 6, "cat1", 3L); SendAssert(env, "B", 5, "cat2", 2L); SendAssert(env, "C", 7, null, null); 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 AssertOneReceivedAndReset( EPStatement stmt, int expectedLenIStream, int expectedLenRStream, object[][] expectedIStream, object[][] expectedRStream) { var stmtCount = 2 + expectedLenIStream + expectedLenRStream; AssertStmtMultipleReceived(stmt, stmtCount); Assert.AreEqual(1, indicateStart.Count); var pairLength = indicateStart[0]; Assert.AreEqual(expectedLenIStream, (int) pairLength.First); Assert.AreEqual(expectedLenRStream, (int) pairLength.Second); EPAssertionUtil.AssertEqualsExactOrder(expectedIStream, indicateIStream); EPAssertionUtil.AssertEqualsExactOrder(expectedRStream, indicateRStream); Assert.AreEqual(1, indicateEnd.Count); Reset(); }
public void TestEmptyListFrontTail() { var testWindow = new LinkedList <TimeWindowPair>(); var list1 = new LinkedList <EventBean>(); AddToWindow(testWindow, 10L, list1); var list2 = new LinkedList <EventBean>(); list2.AddLast(_events.Get("c")); list2.AddLast(_events.Get("d")); AddToWindow(testWindow, 15L, list2); var list3 = new LinkedList <EventBean>(); AddToWindow(testWindow, 20L, list3); var it = new TimeWindowEnumerator(testWindow); EPAssertionUtil.AssertEqualsExactOrder(new[] { _events.Get("c"), _events.Get("d") }, it); }
private void Validate(String select, Object expected) { String epl = "select " + select + " as result from SupportBean"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.Events += _listener.Update; _epService.EPRuntime.SendEvent(new SupportBean("E1", 0)); Object result = _listener.AssertOneGetNewAndReset().Get("result"); if (expected is Object[]) { Object[] returned = ((IEnumerable)result).Cast <object>().ToArray(); EPAssertionUtil.AssertEqualsExactOrder((Object[])expected, returned); } else { Assert.AreEqual(expected, result); } stmt.Dispose(); }
private void RunAssertionLimitation(RegressionEnvironment env) { var path = new RegressionPath(); env.CompileDeploy("@Name('window') create window MyVDW.test:vdw() as SupportBean", path); var window = (SupportVirtualDW) GetFromContext(env, "/virtualdw/MyVDW"); var supportBean = new SupportBean("S1", 100); window.Data = Collections.SingletonSet<object>(supportBean); env.CompileDeploy("insert into MyVDW select * from SupportBean", path); // cannot iterate named window Assert.IsFalse(env.GetEnumerator("window").MoveNext()); // test data window aggregation (rows not included in aggregation) env.CompileDeploy("@Name('s0') select window(TheString) as val0 from MyVDW", path).AddListener("s0"); env.SendEventBean(new SupportBean("E1", 100)); EPAssertionUtil.AssertEqualsExactOrder( new object[] {"S1", "E1"}, (string[]) env.Listener("s0").AssertOneGetNewAndReset().Get("val0")); env.UndeployAll(); }
private static void RunAssertion( RegressionEnvironment env, string eventTypeName, RegressionPath path) { env.CompileDeploy("@Name('s0') select countTags, countTagsInt, idarray, tagArray, tagOne from " + eventTypeName, path); env.CompileDeploy("@Name('e0') insert into TagOneStream select tagOne.* from " + eventTypeName, path); env.CompileDeploy("@Name('e1') select ID from TagOneStream", path); env.CompileDeploy("@Name('e2') insert into TagArrayStream select tagArray as mytags from " + eventTypeName, path); env.CompileDeploy("@Name('e3') select mytags[1].ID from TagArrayStream", path); var doc = SupportXML.GetDocument(OBSERVATION_XML); env.SendEventXMLDOM(doc, eventTypeName); SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("s0").Advance()); SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("e0").Advance()); SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("e1").Advance()); SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("e2").Advance()); SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("e3").Advance()); var resultEnumerator = env.GetEnumerator("s0"); Assert.That(resultEnumerator, Is.Not.Null); Assert.That(resultEnumerator.MoveNext(), Is.True); Assert.That(resultEnumerator.Current, Is.Not.Null); var resultArray = resultEnumerator.Current.Get("idarray"); EPAssertionUtil.AssertEqualsExactOrder( (object[]) resultArray, new[] {"urn:epc:1:2.24.400", "urn:epc:1:2.24.401"}); EPAssertionUtil.AssertProps( env.GetEnumerator("s0").Advance(), new[] {"countTags", "countTagsInt"}, new object[] {2d, 2}); Assert.AreEqual("urn:epc:1:2.24.400", env.GetEnumerator("e1").Advance().Get("ID")); Assert.AreEqual("urn:epc:1:2.24.401", env.GetEnumerator("e3").Advance().Get("mytags[1].ID")); env.UndeployAll(); }
private void RunAssertion( EPServiceProvider epService, string typePrefix, FunctionSendEventWType sender, Object root, Object type_1, Object type_2, Object type_2_1) { string[] typeNames = "Type_Root,Type_1,Type_2,Type_2_1".Split(','); var statements = new EPStatement[4]; var listeners = new SupportUpdateListener[4]; for (int i = 0; i < typeNames.Length; i++) { statements[i] = epService.EPAdministrator.CreateEPL("select * from " + typePrefix + "_" + typeNames[i]); listeners[i] = new SupportUpdateListener(); statements[i].Events += listeners[i].Update; } sender.Invoke(epService, root, typePrefix + "_" + typeNames[0]); EPAssertionUtil.AssertEqualsExactOrder( new bool[] { true, false, false, false }, GetInvokedFlagsAndReset(listeners)); sender.Invoke(epService, type_1, typePrefix + "_" + typeNames[1]); EPAssertionUtil.AssertEqualsExactOrder( new bool[] { true, true, false, false }, GetInvokedFlagsAndReset(listeners)); sender.Invoke(epService, type_2, typePrefix + "_" + typeNames[2]); EPAssertionUtil.AssertEqualsExactOrder( new bool[] { true, false, true, false }, GetInvokedFlagsAndReset(listeners)); sender.Invoke(epService, type_2_1, typePrefix + "_" + typeNames[3]); EPAssertionUtil.AssertEqualsExactOrder( new bool[] { true, false, true, true }, GetInvokedFlagsAndReset(listeners)); for (int i = 0; i < statements.Length; i++) { statements[i].Dispose(); } }
private void RunAssertionSubscriberOnly(EPServiceProvider epService) { var subscriber = new SupportSubscriberMRD(); SendTimer(epService, 0); EPStatement stmt = epService.EPAdministrator.CreateEPL("select irstream TheString,IntPrimitive from SupportBean#time_batch(1) for discrete_delivery"); stmt.Subscriber = subscriber; epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); epService.EPRuntime.SendEvent(new SupportBean("E2", 2)); epService.EPRuntime.SendEvent(new SupportBean("E3", 1)); SendTimer(epService, 1000); Assert.AreEqual(3, subscriber.InsertStreamList.Count); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E1", 1 }, subscriber.InsertStreamList[0][0]); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E2", 2 }, subscriber.InsertStreamList[1][0]); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E3", 1 }, subscriber.InsertStreamList[2][0]); stmt.Dispose(); subscriber.Reset(); stmt = epService.EPAdministrator.CreateEPL("select irstream TheString,IntPrimitive from SupportBean#time_batch(1) for grouped_delivery(IntPrimitive)"); stmt.Subscriber = subscriber; epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); epService.EPRuntime.SendEvent(new SupportBean("E2", 2)); epService.EPRuntime.SendEvent(new SupportBean("E3", 1)); SendTimer(epService, 2000); Assert.AreEqual(2, subscriber.InsertStreamList.Count); Assert.AreEqual(2, subscriber.RemoveStreamList.Count); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E1", 1 }, subscriber.InsertStreamList[0][0]); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E3", 1 }, subscriber.InsertStreamList[0][1]); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E2", 2 }, subscriber.InsertStreamList[1][0]); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E1", 1 }, subscriber.RemoveStreamList[0][0]); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E3", 1 }, subscriber.RemoveStreamList[0][1]); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E2", 2 }, subscriber.RemoveStreamList[1][0]); stmt.Dispose(); }
public void TestSimpleSelectUpdateOnly() { MySubscriberRowByRowSpecific subscriber = new MySubscriberRowByRowSpecific(); EPStatement stmt = _epService.EPAdministrator.CreateEPL("select TheString, IntPrimitive from " + typeof(SupportBean).FullName + ".std:lastevent()"); stmt.Subscriber = subscriber; // get statement, attach listener SupportUpdateListener listener = new SupportUpdateListener(); stmt.Events += listener.Update; // send event _epService.EPRuntime.SendEvent(new SupportBean("E1", 100)); EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E1", 100 } }, subscriber.GetAndResetIndicate()); EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), _fields, new Object[][] { new Object[] { "E1", 100 } }); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), _fields, new Object[] { "E1", 100 }); // remove listener stmt.RemoveAllEventHandlers(); // send event _epService.EPRuntime.SendEvent(new SupportBean("E2", 200)); EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E2", 200 } }, subscriber.GetAndResetIndicate()); EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), _fields, new Object[][] { new Object[] { "E2", 200 } }); Assert.IsFalse(listener.IsInvoked); // add listener SupportStmtAwareUpdateListener stmtAwareListener = new SupportStmtAwareUpdateListener(); stmt.Events += stmtAwareListener.Update; // send event _epService.EPRuntime.SendEvent(new SupportBean("E3", 300)); EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E3", 300 } }, subscriber.GetAndResetIndicate()); EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), _fields, new Object[][] { new Object[] { "E3", 300 } }); EPAssertionUtil.AssertProps(stmtAwareListener.AssertOneGetNewAndReset(), _fields, new Object[] { "E3", 300 }); }
public void TestBeanType() { _epService.EPAdministrator.Configuration.AddImport(typeof(SupportBean)); _epService.EPAdministrator.CreateEPL("create schema SupportBean SupportBean"); _epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " + "DefaultSupportSourceOp -> outstream<SupportBean> {}" + "MySupportBeanOutputOp(outstream) {}" + "SupportGenericOutputOpWPort(outstream) {}"); var source = new DefaultSupportSourceOp(new Object[] { new SupportBean("E1", 1) }); var outputOne = new MySupportBeanOutputOp(); var outputTwo = new SupportGenericOutputOpWPort(); var options = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(source, outputOne, outputTwo)); var dfOne = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options); dfOne.Run(); EPAssertionUtil.AssertPropsPerRow(outputOne.GetAndReset().ToArray(), "TheString,IntPrimitive".Split(','), new Object[][] { new Object[] { "E1", 1 } }); var received = outputTwo.GetAndReset(); EPAssertionUtil.AssertPropsPerRow(received.First.ToArray(), "TheString,IntPrimitive".Split(','), new Object[][] { new Object[] { "E1", 1 } }); EPAssertionUtil.AssertEqualsExactOrder(new int[] { 0 }, received.Second.ToArray()); }
public void TestStreamWildcardJoin() { var subscriber = new MySubscriberRowByRowSpecific(); EPStatement stmt = _epService.EPAdministrator.CreateEPL( "select TheString || '<', s1.* as s1, s0.* as s0 from SupportBean.win:keepall() as s0, SupportMarketDataBean.win:keepall() as s1 where s0.TheString = s1.symbol"); stmt.Subscriber = subscriber; // send event var s0 = new SupportBean("E1", 100); var s1 = new SupportMarketDataBean("E1", 0, 0L, ""); _epService.EPRuntime.SendEvent(s0); _epService.EPRuntime.SendEvent(s1); EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E1<", s1, s0 } } , subscriber.GetAndResetIndicate()); }
private void RunAssertionCreateTableArray(EPServiceProvider epService) { epService.EPAdministrator.CreateEPL("create schema SecurityData (name string, roles string[])"); epService.EPAdministrator.CreateEPL("create window SecurityEvent#time(30 sec) (ipAddress string, userId string, secData SecurityData, historySecData SecurityData[])"); // create window string stmtTextCreate = "create window MyWindowCTA#keepall (myvalue string[])"; EPStatement stmtCreate = epService.EPAdministrator.CreateEPL(stmtTextCreate); var listenerWindow = new SupportUpdateListener(); stmtCreate.Events += listenerWindow.Update; // create insert into string stmtTextInsertOne = "insert into MyWindowCTA select {'a','b'} as myvalue from " + typeof(SupportBean).FullName; epService.EPAdministrator.CreateEPL(stmtTextInsertOne); SendSupportBean(epService, "E1", 1L, 10L); string[] values = (string[])listenerWindow.AssertOneGetNewAndReset().Get("myvalue"); EPAssertionUtil.AssertEqualsExactOrder(values, new string[] { "a", "b" }); epService.EPAdministrator.DestroyAllStatements(); }
public void Run(RegressionEnvironment env) { var epl = "@Name('s0') select {\"a\",\"b\"} as StringArray, " + "{} as EmptyArray, " + "{1} as OneEleArray, " + "{1,2,3} as IntArray " + "from SupportBean"; env.EplToModelCompileDeploy(epl).AddListener("s0").Milestone(0); var bean = new SupportBean("a", 10); env.SendEventBean(bean); var theEvent = env.Listener("s0").AssertOneGetNewAndReset(); EPAssertionUtil.AssertEqualsExactOrder(theEvent.Get("StringArray").Unwrap <string>(), new[] { "a", "b" }); EPAssertionUtil.AssertEqualsExactOrder(theEvent.Get("EmptyArray").Unwrap <object>(), new object[0]); EPAssertionUtil.AssertEqualsExactOrder(theEvent.Get("OneEleArray").Unwrap <int>(), new int[] { 1 }); EPAssertionUtil.AssertEqualsExactOrder(theEvent.Get("IntArray").Unwrap <int>(), new int[] { 1, 2, 3 }); env.UndeployAll(); }
private void RunAssertionLimitation(EPServiceProvider epService) { EPStatement stmtWindow = epService.EPAdministrator.CreateEPL("create window MyVDW.test:vdw() as SupportBean"); SupportVirtualDW window = (SupportVirtualDW)GetFromContext(epService, "/virtualdw/MyVDW"); var supportBean = new SupportBean("S1", 100); window.Data = Collections.SingletonList <object>(supportBean); epService.EPAdministrator.CreateEPL("insert into MyVDW select * from SupportBean"); // cannot iterate named window Assert.IsFalse(stmtWindow.HasFirst()); // test data window aggregation (rows not included in aggregation) EPStatement stmtAggregate = epService.EPAdministrator.CreateEPL("select window(TheString) as val0 from MyVDW"); var listener = new SupportUpdateListener(); stmtAggregate.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("E1", 100)); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "E1" }, (string[])listener.AssertOneGetNewAndReset().Get("val0")); DestroyStmtsRemoveTypes(epService); }
private void Validate(EPServiceProvider epService, string select, Object expected) { string epl = "select " + select + " as result from SupportBean"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("E1", 0)); Object result = listener.AssertOneGetNewAndReset().Get("result"); if (expected is object[]) { object[] returned = result.UnwrapIntoArray <object>(); EPAssertionUtil.AssertEqualsExactOrder((object[])expected, returned); } else { Assert.AreEqual(expected, result); } stmt.Dispose(); }
public void TestOneElement() { var list = new List <EventBean>(); list.Add(_events.Get("a")); var key = new MultiKeyUntyped( new Object[] { "akey" } ); _testMap.Put(key, list); IEnumerator <EventBean> it = new SortWindowEnumerator(_testMap); EPAssertionUtil.AssertEqualsExactOrder( new EventBean[] { _events.Get("a") } , it); }
private void RunAssertionArrayExpressions_OM(EPServiceProvider epService) { var stmtText = "select {\"a\",\"b\"} as stringArray, " + "{} as emptyArray, " + "{1} as oneEleArray, " + "{1,2,3} as intArray " + "from " + typeof(SupportBean).FullName; var model = new EPStatementObjectModel(); model.SelectClause = SelectClause.Create() .Add(Expressions.Array().Add(Expressions.Constant("a")).Add(Expressions.Constant("b")), "stringArray") .Add(Expressions.Array(), "emptyArray") .Add(Expressions.Array().Add(Expressions.Constant(1)), "oneEleArray") .Add(Expressions.Array().Add(Expressions.Constant(1)).Add(2).Add(3), "intArray"); model.FromClause = FromClause.Create(FilterStream.Create(typeof(SupportBean).FullName)); model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model); Assert.AreEqual(stmtText, model.ToEPL()); var stmt = epService.EPAdministrator.Create(model); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var bean = new SupportBean("a", 10); epService.EPRuntime.SendEvent(bean); var theEvent = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertEqualsExactOrder((string[])theEvent.Get("stringArray"), new string[] { "a", "b" }); EPAssertionUtil.AssertEqualsExactOrder((object[])theEvent.Get("emptyArray"), new object[0]); EPAssertionUtil.AssertEqualsExactOrder((int?[])theEvent.Get("oneEleArray"), new int?[] { 1 }); EPAssertionUtil.AssertEqualsExactOrder((int?[])theEvent.Get("intArray"), new int?[] { 1, 2, 3 }); 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(); }
private void RunAssertionNewSchema() { string epl = EventRepresentationChoice.AVRO.GetAnnotationText() + " select 1 as myInt," + "{1L, 2L} as myLongArray," + this.GetType().FullName + ".MakeByteArray() as myByteArray, " + this.GetType().FullName + ".MakeMapStringString() as myMap " + "from SupportBean"; EPStatement statement = _epService.EPAdministrator.CreateEPL(epl); SupportUpdateListener listener = new SupportUpdateListener(); statement.AddListener(listener); _epService.EPRuntime.SendEvent(new SupportBean()); EventBean @event = listener.AssertOneGetNewAndReset(); string json = SupportAvroUtil.AvroToJson(@event); Console.WriteLine(json); Assert.AreEqual(1, @event.Get("myInt")); EPAssertionUtil.AssertEqualsExactOrder(new long[] { 1L, 2L }, @event.Get("myLongArray").UnwrapIntoArray <long>()); Assert.IsTrue(CompatExtensions.IsEqual(new byte[] { 1, 2, 3 }, ((byte[])@event.Get("myByteArray")))); Assert.AreEqual("[k1=v1]", CompatExtensions.Render(@event.Get("myMap").AsStringDictionary())); var designSchema = SchemaBuilder.Record("name", TypeBuilder.RequiredInt("myInt"), TypeBuilder.Field("myLongArray", TypeBuilder.Array(TypeBuilder.Union(TypeBuilder.Null(), TypeBuilder.Long()))), TypeBuilder.Field("myByteArray", TypeBuilder.Bytes()), TypeBuilder.Field("myMap", TypeBuilder.Map( TypeBuilder.String(TypeBuilder.Property(AvroConstant.PROP_STRING_KEY, AvroConstant.PROP_STRING_VALUE))))); var assembledSchema = ((AvroEventType)@event.EventType).SchemaAvro; var compareMsg = SupportAvroUtil.CompareSchemas(designSchema, assembledSchema); Assert.IsNull(compareMsg, compareMsg); statement.Dispose(); }
public void TestEmptyListFrontTail() { var testWindow = new ArrayDeque <TimeWindowPair>(); var list1 = new ArrayDeque <EventBean>(); AddToWindow(testWindow, 10L, list1); var list2 = new ArrayDeque <EventBean>(); list2.Add(events.Get("c")); list2.Add(events.Get("d")); AddToWindow(testWindow, 15L, list2); var list3 = new ArrayDeque <EventBean>(); AddToWindow(testWindow, 20L, list3); IEnumerator <EventBean> enumerator = new TimeWindowEnumerator(testWindow); EPAssertionUtil.AssertEqualsExactOrder(new object[] { events.Get("c"), events.Get("d") }, enumerator); }