Ejemplo n.º 1
0
        public void TestWithDate()
        {
            _epService.EPAdministrator.CreateEPL("create variable int varyear");
            _epService.EPAdministrator.CreateEPL("create variable int varmonth");
            _epService.EPAdministrator.CreateEPL("create variable int varday");

            String startTime = "2002-05-30 09:00:00.000";

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            String[] fields      = "val0,val1,val2".Split(',');
            String   eplFragment = "select " +
                                   "current_timestamp.withDate(varyear, varmonth, varday) as val0," +
                                   "utildate.withDate(varyear, varmonth, varday) as val1," +
                                   "msecdate.withDate(varyear, varmonth, varday) as val2" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(long?), typeof(DateTimeOffset?), typeof(long?) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { SupportDateTime.GetValueCoerced(startTime, "msec"), null, null });

            String expectedTime = "2004-09-03 09:00:00.000";

            _epService.EPRuntime.SetVariableValue("varyear", 2004);
            _epService.EPRuntime.SetVariableValue("varmonth", 9);
            _epService.EPRuntime.SetVariableValue("varday", 3);
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "msec", "util", "msec"));

            expectedTime = "2002-09-30 09:00:00.000";
            _epService.EPRuntime.SetVariableValue("varyear", null);
            _epService.EPRuntime.SetVariableValue("varmonth", 9);
            _epService.EPRuntime.SetVariableValue("varday", null);
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "msec", "util", "msec"));
        }
Ejemplo n.º 2
0
        private static void RunAssertion(
            RegressionEnvironment env,
            AtomicLong milestone)
        {
            var fields = new [] { "val" };

            env.SendEventBean(new SupportBean("E1", 1));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {false});

            env.MilestoneInc(milestone);

            env.SendEventBean(new SupportBean("E2", 2));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {false});

            env.SendEventBean(new SupportBean("E3", 3));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {false});

            env.MilestoneInc(milestone);

            env.SendEventBean(new SupportBean("E4", 4));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {true});

            env.MilestoneInc(milestone);

            env.SendEventBean(new SupportBean("E5", 5));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {true});
        }
        public void RunAssertionDispatchBackQueue(EventRepresentationEnum eventRepresentationEnum)
        {
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema StartValueEvent as (dummy string)");
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema TestForwardEvent as (prop1 string)");
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema TestInputEvent as (dummy string)");
            _epService.EPAdministrator.CreateEPL("insert into TestForwardEvent select'V1' as prop1 from TestInputEvent");

            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window NamedWin.std:unique(prop1) (prop1 string, prop2 string)");

            _epService.EPAdministrator.CreateEPL("insert into NamedWin select 'V1' as prop1, 'O1' as prop2 from StartValueEvent");

            _epService.EPAdministrator.CreateEPL("on TestForwardEvent update NamedWin as work set prop2 = 'U1' where work.prop1 = 'V1'");

            string[] fields    = "prop1,prop2".Split(',');
            string   eplSelect = "select irstream prop1, prop2 from NamedWin";

            _epService.EPAdministrator.CreateEPL(eplSelect).AddListener(_listener);

            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPRuntime.SendEvent(new object[] { "dummyValue" }, "StartValueEvent");
            }
            else
            {
                _epService.EPRuntime.SendEvent(new Dictionary <string, object>(), "StartValueEvent");
            }

            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "V1", "O1" });

            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPRuntime.SendEvent(new object[] { "dummyValue" }, "TestInputEvent");
            }
            else
            {
                _epService.EPRuntime.SendEvent(new Dictionary <string, object>(), "TestInputEvent");
            }
            EPAssertionUtil.AssertProps(_listener.LastOldData[0], fields, new object[] { "V1", "O1" });
            EPAssertionUtil.AssertProps(_listener.GetAndResetLastNewData()[0], fields, new object[] { "V1", "U1" });

            _epService.Initialize();
        }
Ejemplo n.º 4
0
        private void RunAssertionArrayPropertySizeAndGet(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType(
                "SupportBeanComplexProps", typeof(SupportBeanComplexProps));

            var epl = "select " +
                      "(arrayProperty).size() as size, " +
                      "(arrayProperty).get(0) as get0, " +
                      "(arrayProperty).get(1) as get1, " +
                      "(arrayProperty).get(2) as get2, " +
                      "(arrayProperty).get(3) as get3 " +
                      "from SupportBeanComplexProps";
            var stmt = epService.EPAdministrator.CreateEPL(epl);
            var listener = new SupportUpdateListener();
            stmt.Events += listener.Update;

            var bean = SupportBeanComplexProps.MakeDefaultBean();
            var rows = new[]
            {
                new object[] {"size", typeof(int?)},
                new object[] {"get0", typeof(int)},
                new object[] {"get1", typeof(int)},
                new object[] {"get2", typeof(int)},
                new object[] {"get3", typeof(int)}
            };
            for (var i = 0; i < rows.Length; i++)
            {
                var prop = stmt.EventType.PropertyDescriptors[i];
                Assert.AreEqual(rows[i][0], prop.PropertyName, "failed for " + rows[i][0]);
                Assert.AreEqual(rows[i][1], prop.PropertyType, "failed for " + rows[i][0]);
            }

            epService.EPRuntime.SendEvent(bean);
            EPAssertionUtil.AssertProps(
                listener.AssertOneGetNew(), "size,get0,get1,get2,get3".Split(','),
                new object[]
                {
                    bean.ArrayProperty.Length, bean.ArrayProperty[0], bean.ArrayProperty[1], bean.ArrayProperty[2], null
                });

            stmt.Dispose();
        }
Ejemplo n.º 5
0
        private void RunAssertionUngroupedRowRemove()
        {
            var cols = "TheString,IntPrimitive,c0,c1".Split(',');
            var epl  = "create window MyWindow#keepall as SupportBean;\n" +
                       "insert into MyWindow select * from SupportBean;\n" +
                       "on SupportBean_S0 delete from MyWindow where p00 = TheString and id = IntPrimitive;\n" +
                       "on SupportBean_S1 delete from MyWindow;\n" +
                       "@Name('out') select TheString, IntPrimitive, sum(LongPrimitive) as c0, " +
                       "  sum(LongPrimitive, group_by:TheString) as c1 from MyWindow;\n";
            var result = _epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl);

            _epService.EPAdministrator.GetStatement("out").AddListener(_listener);

            MakeSendEvent("E1", 10, 101);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { "E1", 10, 101L, 101L });

            _epService.EPRuntime.SendEvent(new SupportBean_S0(10, "E1"));     // delete event {"E1", 10}
            Assert.IsFalse(_listener.IsInvoked);

            MakeSendEvent("E1", 20, 102);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { "E1", 20, 102L, 102L });

            MakeSendEvent("E2", 30, 103);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { "E2", 30, 102 + 103L, 103L });

            MakeSendEvent("E1", 40, 104);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { "E1", 40, 102 + 103 + 104L, 102 + 104L });

            _epService.EPRuntime.SendEvent(new SupportBean_S0(40, "E1"));     // delete event {"E1", 40}
            Assert.IsFalse(_listener.IsInvoked);

            MakeSendEvent("E1", 50, 105);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { "E1", 50, 102 + 103 + 105L, 102 + 105L });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(-1));     // delete all
            Assert.IsFalse(_listener.IsInvoked);

            MakeSendEvent("E1", 60, 106);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { "E1", 60, 106L, 106L });

            _epService.EPAdministrator.DeploymentAdmin.Undeploy(result.DeploymentId);
        }
Ejemplo n.º 6
0
        private void RunAssertionGroupLength(EPServiceProvider epService)
        {
            EPStatement stmtCreateWin = epService.EPAdministrator.CreateEPL
                                            ("create window RevQuote#groupwin(P1)#length(2) as select * from RevisableQuote");

            epService.EPAdministrator.CreateEPL
                ("insert into RevQuote select * from FullEvent");
            epService.EPAdministrator.CreateEPL
                ("insert into RevQuote select * from D1");
            epService.EPAdministrator.CreateEPL
                ("insert into RevQuote select * from D5");

            EPStatement consumerOne = epService.EPAdministrator.CreateEPL
                                          ("select irstream * from RevQuote order by K0 asc");
            var listenerOne = new SupportUpdateListener();

            consumerOne.Events += listenerOne.Update;

            epService.EPRuntime.SendEvent(new SupportRevisionFull("a", "P1", "a50"));
            epService.EPRuntime.SendEvent(new SupportDeltaFive("a", "P1", "a51"));
            epService.EPRuntime.SendEvent(new SupportRevisionFull("b", "P2", "b50"));
            epService.EPRuntime.SendEvent(new SupportRevisionFull("c", "P3", "c50"));
            epService.EPRuntime.SendEvent(new SupportDeltaFive("d", "P3", "d50"));

            listenerOne.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmtCreateWin.GetEnumerator(), _fields, new object[][] { new object[] { "a", "P1", "a51" }, new object[] { "b", "P2", "b50" }, new object[] { "c", "P3", "c50" } });

            epService.EPRuntime.SendEvent(new SupportDeltaFive("b", "P1", "b51"));
            EPAssertionUtil.AssertProps(listenerOne.LastNewData[0], _fields, new object[] { "b", "P1", "b51" });
            EPAssertionUtil.AssertProps(listenerOne.LastOldData[0], _fields, new object[] { "b", "P2", "b50" });
            listenerOne.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmtCreateWin.GetEnumerator(), _fields, new object[][] { new object[] { "a", "P1", "a51" }, new object[] { "b", "P1", "b51" }, new object[] { "c", "P3", "c50" } });

            epService.EPRuntime.SendEvent(new SupportDeltaFive("c", "P1", "c51"));
            EPAssertionUtil.AssertProps(listenerOne.LastNewData[0], _fields, new object[] { "c", "P1", "c51" });
            EPAssertionUtil.AssertProps(listenerOne.LastOldData[1], _fields, new object[] { "c", "P3", "c50" });
            EPAssertionUtil.AssertProps(listenerOne.LastOldData[0], _fields, new object[] { "a", "P1", "a51" });
            listenerOne.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmtCreateWin.GetEnumerator(), _fields, new object[][] { new object[] { "b", "P1", "b51" }, new object[] { "c", "P1", "c51" } });

            epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunRangeAssertion(EPServiceProvider epService, bool indexShare, bool buildIndex)
        {
            string createEpl = "create window MyWindow#keepall as select * from SupportBean";

            if (indexShare)
            {
                createEpl = "@Hint('enable_window_subquery_indexshare') " + createEpl;
            }
            epService.EPAdministrator.CreateEPL(createEpl);

            if (buildIndex)
            {
                epService.EPAdministrator.CreateEPL("create index idx1 on MyWindow(IntPrimitive btree)");
            }
            epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean");

            // preload
            for (int i = 0; i < 10000; i++)
            {
                epService.EPRuntime.SendEvent(new SupportBean("E1", i));
            }

            string[]    fields   = "cols.mini,cols.maxi".Split(',');
            string      queryEpl = "select (select min(IntPrimitive) as mini, max(IntPrimitive) as maxi from MyWindow where IntPrimitive between sbr.rangeStart and sbr.rangeEnd) as cols from SupportBeanRange sbr";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(queryEpl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            long startTime = DateTimeHelper.CurrentTimeMillis;

            for (int i = 0; i < 1000; i++)
            {
                epService.EPRuntime.SendEvent(new SupportBeanRange("R1", "K", 300, 312));
                EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 300, 312 });
            }
            long delta = DateTimeHelper.CurrentTimeMillis - startTime;

            Assert.IsTrue(delta < 500, "delta=" + delta);

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 8
0
        private void RunAssertionEventTypeColumnDef(EPServiceProvider epService, EventRepresentationChoice eventRepresentationEnum)
        {
            EPStatement stmtSchema = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema SchemaOne(col1 int, col2 int)");

            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmtSchema.EventType.UnderlyingType));

            EPStatement stmt = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window SchemaWindow#lastevent as (s1 SchemaOne)");

            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmt.EventType.UnderlyingType));
            var listenerWindow = new SupportUpdateListener();

            stmt.Events += listenerWindow.Update;
            epService.EPAdministrator.CreateEPL("insert into SchemaWindow (s1) select sone from SchemaOne as sone");

            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                epService.EPRuntime.SendEvent(new object[] { 10, 11 }, "SchemaOne");
            }
            else if (eventRepresentationEnum.IsMapEvent())
            {
                var theEvent = new LinkedHashMap <string, object>();
                theEvent.Put("col1", 10);
                theEvent.Put("col2", 11);
                epService.EPRuntime.SendEvent(theEvent, "SchemaOne");
            }
            else if (eventRepresentationEnum.IsAvroEvent())
            {
                var theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(epService, "SchemaOne").AsRecordSchema());
                theEvent.Put("col1", 10);
                theEvent.Put("col2", 11);
                epService.EPRuntime.SendEventAvro(theEvent, "SchemaOne");
            }
            else
            {
                Assert.Fail();
            }
            EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), "s1.col1,s1.col2".Split(','), new object[] { 10, 11 });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("SchemaOne", true);
            epService.EPAdministrator.Configuration.RemoveEventType("SchemaWindow", true);
        }
Ejemplo n.º 9
0
        private void RunAssertionHash(String ctx, EPStatementSPI statement, HashCodeFunc codeFunc)
        {
            var fields = "c0,c1,c2".Split(',');

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 5));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { ctx, "E1", 5 });
            AssertIterator(statement, fields, new Object[][] { new Object[] { ctx, "E1", 5 } });

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 6));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { ctx, "E2", 6 });
            AssertIterator(statement, fields, new Object[][] { new Object[] { ctx, "E1", 5 }, new Object[] { ctx, "E2", 6 } });

            _epService.EPRuntime.SendEvent(new SupportBean("E3", 7));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { ctx, "E3", 7 });
            AssertIterator(statement, fields, new Object[][] { new Object[] { ctx, "E1", 5 }, new Object[] { ctx, "E3", 7 }, new Object[] { ctx, "E2", 6 } });

            _epService.EPRuntime.SendEvent(new SupportBean("E4", 8));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { ctx, "E4", 8 });
            AssertIterator(statement, fields, new Object[][] { new Object[] { ctx, "E1", 5 }, new Object[] { ctx, "E3", 7 }, new Object[] { ctx, "E4", 8 }, new Object[] { ctx, "E2", 6 } });

            _epService.EPRuntime.SendEvent(new SupportBean("E5", 9));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { ctx, "E5", 9 });
            AssertIterator(statement, fields, new Object[][] { new Object[] { ctx, "E5", 9 }, new Object[] { ctx, "E1", 5 }, new Object[] { ctx, "E3", 7 }, new Object[] { ctx, "E4", 8 }, new Object[] { ctx, "E2", 6 } });

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 10));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { ctx, "E1", 15 });
            AssertIterator(statement, fields, new Object[][] { new Object[] { ctx, "E5", 9 }, new Object[] { ctx, "E1", 15 }, new Object[] { ctx, "E3", 7 }, new Object[] { ctx, "E4", 8 }, new Object[] { ctx, "E2", 6 } });

            _epService.EPRuntime.SendEvent(new SupportBean("E4", 11));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { ctx, "E4", 19 });
            AssertIterator(statement, fields, new Object[][] { new Object[] { ctx, "E5", 9 }, new Object[] { ctx, "E1", 15 }, new Object[] { ctx, "E3", 7 }, new Object[] { ctx, "E4", 19 }, new Object[] { ctx, "E2", 6 } });

            statement.Stop();
            AgentInstanceAssertionUtil.AssertInstanceCounts(statement.StatementContext, 0, 0, 0, 0);

            Assert.AreEqual(1, _spi.ContextManagementService.ContextCount);
            _epService.EPAdministrator.GetStatement("context").Dispose();
            Assert.AreEqual(1, _spi.ContextManagementService.ContextCount);

            statement.Dispose();
            Assert.AreEqual(0, _spi.ContextManagementService.ContextCount);
        }
Ejemplo n.º 10
0
        public void TestEngineMetrics()
        {
            _epService = EPServiceProviderManager.GetProvider("MyURI", GetConfig(10000, -1, true));
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            String[] engineFields = "engineURI,timestamp,inputCount,inputCountDelta,scheduleDepth".Split(',');
            SendTimer(1000);

            String      text = "select * from " + typeof(EngineMetric).FullName;
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(text);

            stmt.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean());

            SendTimer(10999);
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPAdministrator.CreateEPL("select * from pattern[timer:interval(5 sec)]");

            SendTimer(11000);
            EventBean theEvent = _listener.AssertOneGetNewAndReset();

            EPAssertionUtil.AssertProps(theEvent, engineFields, new Object[] { "MyURI", 11000L, 1L, 1L, 1L });

            _epService.EPRuntime.SendEvent(new SupportBean());
            _epService.EPRuntime.SendEvent(new SupportBean());

            SendTimer(20000);
            SendTimer(21000);
            theEvent = _listener.AssertOneGetNewAndReset();
            EPAssertionUtil.AssertProps(theEvent, engineFields, new Object[] { "MyURI", 21000L, 4L, 3L, 0L });

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
Ejemplo n.º 11
0
        public void TestOuterJoin1Access()
        {
            _epService.EPAdministrator.Configuration.AddEventType("S0", typeof(SupportBean_S0));
            _epService.EPAdministrator.Configuration.AddEventType("S1", typeof(SupportBean_S1));
            string epl = "select " +
                         "sa.id as aid, " +
                         "sb.id as bid, " +
                         "first(sb.p10) as fb, " +
                         "window(sb.p10) as wb, " +
                         "last(sb.p10) as lb " +
                         "from S0#keepall as sa " +
                         "left outer join " +
                         "S1#keepall as sb " +
                         "on sa.id = sb.id";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

            stmt.AddListener(_listener);

            string[] fields = "aid,bid,fb,wb,lb".Split(',');

            _epService.EPRuntime.SendEvent(new SupportBean_S0(1));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { 1, null, null, null, null });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(1, "A"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { 1, 1, "A", Split("A"), "A" });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(2, "B"));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean_S0(2, "A"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { 2, 2, "A", Split("A,B"), "B" });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(3, "C"));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean_S0(3, "C"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { 3, 3, "A", Split("A,B,C"), "C" });
        }
Ejemplo n.º 12
0
        public void TestIntersectSorted()
        {
            Init(false);
            var fields = new String[] { "TheString" };

            var stmt = _epService.EPAdministrator.CreateEPL("select irstream TheString from SupportBean#sort(2, IntPrimitive)#sort(2, IntBoxed) retain-intersection");

            stmt.Events += _listener.Update;

            SendEvent("E1", 1, 10);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E1"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1" });

            SendEvent("E2", 2, 9);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E1", "E2"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E2" });

            SendEvent("E3", 0, 0);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E3"));
            Object[] result = { _listener.LastOldData[0].Get("TheString"), _listener.LastOldData[1].Get("TheString") };
            EPAssertionUtil.AssertEqualsAnyOrder(result, new String[] { "E1", "E2" });
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNew(), fields, new Object[] { "E3" });
            _listener.Reset();

            SendEvent("E4", -1, -1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E3", "E4"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E4" });

            SendEvent("E5", 1, 1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E3", "E4"));
            Assert.AreEqual(1, _listener.LastOldData.Length);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetOld(), fields, new Object[] { "E5" });
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNew(), fields, new Object[] { "E5" });
            _listener.Reset();

            SendEvent("E6", 0, 0);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E4", "E6"));
            Assert.AreEqual(1, _listener.LastOldData.Length);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetOld(), fields, new Object[] { "E3" });
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNew(), fields, new Object[] { "E6" });
            _listener.Reset();
        }
Ejemplo n.º 13
0
        private void TryAssertionFromClauseOutputFirstWhere(EPServiceProvider epService, bool soda)
        {
            var fieldsOrderId = "oe.orderdetail.OrderId".Split(',');
            var epl           = "on OrderEvent as oe " +
                                "insert into HeaderEvent select orderdetail.OrderId as OrderId where 1=2 " +
                                "insert into StreamOne select * from [select oe, * from orderdetail.Items] where productId=\"10020\" " +
                                "insert into StreamTwo select * from [select oe, * from orderdetail.Items] where productId=\"10022\" " +
                                "insert into StreamThree select * from [select oe, * from orderdetail.Items] where productId in (\"10020\",\"10025\",\"10022\")";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, epl);

            var listeners   = GetListeners();
            var listenerEPL = new[] { "select * from StreamOne", "select * from StreamTwo", "select * from StreamThree" };

            for (var i = 0; i < listenerEPL.Length; i++)
            {
                epService.EPAdministrator.CreateEPL(listenerEPL[i]).Events += listeners[i].Update;
                listeners[i].Reset();
            }

            epService.EPRuntime.SendEvent(OrderBeanFactory.MakeEventOne());
            EPAssertionUtil.AssertProps(listeners[0].AssertOneGetNewAndReset(), fieldsOrderId, new object[] { "PO200901" });
            Assert.IsFalse(listeners[1].IsInvoked);
            Assert.IsFalse(listeners[2].IsInvoked);

            epService.EPRuntime.SendEvent(OrderBeanFactory.MakeEventTwo());
            Assert.IsFalse(listeners[0].IsInvoked);
            EPAssertionUtil.AssertProps(listeners[1].AssertOneGetNewAndReset(), fieldsOrderId, new object[] { "PO200902" });
            Assert.IsFalse(listeners[2].IsInvoked);

            epService.EPRuntime.SendEvent(OrderBeanFactory.MakeEventThree());
            Assert.IsFalse(listeners[0].IsInvoked);
            Assert.IsFalse(listeners[1].IsInvoked);
            EPAssertionUtil.AssertProps(listeners[2].AssertOneGetNewAndReset(), fieldsOrderId, new object[] { "PO200903" });

            epService.EPRuntime.SendEvent(OrderBeanFactory.MakeEventFour());
            Assert.IsFalse(listeners[0].IsInvoked);
            Assert.IsFalse(listeners[1].IsInvoked);
            Assert.IsFalse(listeners[2].IsInvoked);

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 14
0
        public void TestGroupByEventPerGroupUnidirectionalJoin()
        {
            _epService.EPAdministrator.CreateEPL("@Name('context') create context SegmentedByString partition by TheString from SupportBean");

            var fieldsOne = "IntPrimitive,col1".Split(',');
            var stmtOne   = _epService.EPAdministrator.CreateEPL("@Name('A') context SegmentedByString " +
                                                                 "select IntPrimitive, Count(*) as col1 " +
                                                                 "from SupportBean unidirectional, SupportBean_S0.win:keepall() " +
                                                                 "group by IntPrimitive order by IntPrimitive asc");

            stmtOne.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("G1", 10));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(1));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(2));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("G1", 10));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { 10, 2L });

            _epService.EPRuntime.SendEvent(new SupportBean_S0(3));

            _epService.EPRuntime.SendEvent(new SupportBean("G1", 10));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { 10, 3L });

            _epService.EPRuntime.SendEvent(new SupportBean("G2", 20));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(4));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("G2", 20));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { 20, 1L });

            _epService.EPRuntime.SendEvent(new SupportBean_S0(5));

            _epService.EPRuntime.SendEvent(new SupportBean("G2", 20));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { 20, 2L });

            _epService.EPRuntime.SendEvent(new SupportBean("G1", 10));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsOne, new Object[] { 10, 5L });

            stmtOne.Dispose();
        }
Ejemplo n.º 15
0
        public void TestJoin()
        {
            SendTimeEvent("2002-05-01T08:00:00.000");
            _epService.EPAdministrator.CreateEPL("create context NineToFive as start (0, 9, *, *, *) end (0, 17, *, *, *)");

            var fields    = "col1,col2,col3,col4".Split(',');
            var listener  = new SupportUpdateListener();
            var statement = _epService.EPAdministrator.CreateEPL("context NineToFive " +
                                                                 "select sb.theString as col1, sb.intPrimitive as col2, s0.id as col3, s0.p00 as col4 " +
                                                                 "from SupportBean#keepall as sb full outer join SupportBean_S0#keepall as s0 on p00 = theString", listener);

            statement.AddListener(listener);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(1, "E1"));
            Assert.IsFalse(listener.IsInvoked);

            // now started
            SendTimeEvent("2002-05-01T09:00:00.000");
            _epService.EPRuntime.SendEvent(new SupportBean_S0(1, "E1"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { null, null, 1, "E1" });

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 5));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 5, 1, "E1" });

            // now gone
            SendTimeEvent("2002-05-01T17:00:00.000");

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(1, "E1"));
            Assert.IsFalse(listener.IsInvoked);

            // now started
            SendTimeEvent("2002-05-02T09:00:00.000");

            SendTimeEvent("2002-05-01T09:00:00.000");
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 4));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 4, null, null });

            _epService.EPRuntime.SendEvent(new SupportBean_S0(2, "E1"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 4, 2, "E1" });
        }
Ejemplo n.º 16
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "cb","cnb","c","pct" };
                var epl =
                    "@Name('s0') select count(*,BoolPrimitive) as cb, count(*,not BoolPrimitive) as cnb, count(*) as c, count(*,BoolPrimitive)/count(*) as pct from SupportBean#length(3)";
                env.CompileDeploy(epl).AddListener("s0");
                AssertStatelessStmt(env, "s0", false);

                env.SendEventBean(MakeSB(true));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {1L, 0L, 1L, 1d});

                env.Milestone(0);

                env.SendEventBean(MakeSB(false));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {1L, 1L, 2L, 0.5d});

                env.SendEventBean(MakeSB(false));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {1L, 2L, 3L, 1 / 3d});

                env.Milestone(1);

                env.SendEventBean(MakeSB(false));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {0L, 3L, 3L, 0d});

                env.UndeployAll();

                env.EplToModelCompileDeploy(epl);

                env.UndeployAll();
            }
Ejemplo n.º 17
0
        private void TryAssertionHaving(EPServiceProvider epService, SupportUpdateListener listener)
        {
            SendEvent(epService, "SYM1", 10d);
            SendEvent(epService, "SYM1", 11d);
            SendEvent(epService, "SYM1", 9);

            SendTimer(epService, 1000);
            string[] fields = "symbol,avgPrice".Split(',');
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "SYM1", 10.5 });

            SendEvent(epService, "SYM1", 13d);
            SendEvent(epService, "SYM1", 10d);
            SendEvent(epService, "SYM1", 9);
            SendTimer(epService, 2000);

            Assert.AreEqual(3, listener.LastNewData.Length);
            Assert.IsNull(listener.LastOldData);
            EPAssertionUtil.AssertPropsPerRow(listener.LastNewData, fields,
                                              new object[][] { new object[] { "SYM1", 43 / 4.0 }, new object[] { "SYM1", 53.0 / 5.0 }, new object[] { "SYM1", 62 / 6.0 } });
        }
Ejemplo n.º 18
0
     public void TestUpdateNonPropertySet() {
         _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("increaseIntCopyDouble", this.GetType().FullName, "IncreaseIntCopyDouble");
         _epService.EPAdministrator.CreateEPL("create window MyWindow.win:keepall() as SupportBean");
         _epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean");
         EPStatement stmt = _epService.EPAdministrator.CreateEPL("on SupportBean_S0 as sb " +
                 "merge MyWindow as mywin when matched then " +
                 "update set mywin.set_DoublePrimitive(id), increaseIntCopyDouble(initial, mywin)");
         stmt.AddListener(_mergeListener);
         string[] fields = "IntPrimitive,DoublePrimitive,DoubleBoxed".Split(',');
 
         _epService.EPRuntime.SendEvent(MakeSupportBean("E1", 10, 2));
         _epService.EPRuntime.SendEvent(new SupportBean_S0(5, "E1"));
         EPAssertionUtil.AssertProps(_mergeListener.GetAndResetLastNewData()[0], fields, new object[]{11, 5d, 5d});
 
         // try a case-statement
         string eplCase = "on SupportBean_S0 merge MyWindow " +
                 "when matched then update set TheString = " +
                 "case IntPrimitive when 1 then 'a' else 'b' end";
         _epService.EPAdministrator.CreateEPL(eplCase);
     }
Ejemplo n.º 19
0
            public void Run(RegressionEnvironment env)
            {
                var fields = "resOne, resTwo".SplitCsv();
                var epl    = "@Name('s0') select 1 in (IntCol, LongCol) as resOne, 1 not in (LongCol, IntCol) as resTwo from SupportBeanArrayCollMap";

                env.CompileDeploy(epl).AddListener("s0");

                SendArrayCollMap(env, new SupportBeanArrayCollMap(true, new[] { 10, 20, 30 }, null));
                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, false, true);
                SendArrayCollMap(env, new SupportBeanArrayCollMap(true, new[] { 10, 20, 1 }, null));
                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, true, false);
                SendArrayCollMap(env, new SupportBeanArrayCollMap(true, new[] { 30 }, new long?[] { 20L, 1L }));
                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, false, true);
                SendArrayCollMap(env, new SupportBeanArrayCollMap(true, new int[] { }, new long?[] { null, 1L }));
                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, false, true);
                SendArrayCollMap(env, new SupportBeanArrayCollMap(true, null, new long?[] { 1L, 100L }));
                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, false, true);

                env.UndeployAll();
            }
Ejemplo n.º 20
0
        public void TestModelAfterMap()
        {
            // create window
            var stmtTextCreate = "create window MyWindow#keepall select * from MyMap";
            var stmtCreate     = _epService.EPAdministrator.CreateEPL(stmtTextCreate);

            Assert.IsTrue(stmtCreate.EventType is MapEventType);

            // create insert into
            var stmtTextInsertOne = "insert into MyWindow select * from MyMap";
            var stmt = _epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            stmt.AddListener(_listenerWindow);

            SendMap("k1", 100L, 200L);
            var theEvent = _listenerWindow.AssertOneGetNewAndReset();

            Assert.IsTrue(theEvent is MappedEventBean);
            EPAssertionUtil.AssertProps(theEvent, "key,primitive".Split(','), new object[] { "k1", 100L });
        }
Ejemplo n.º 21
0
        private static void TryReturnObject(
            RegressionEnvironment env,
            string dialect)
        {
            var expression =
                $"@Name('s0') expression {typeof(SupportBean).FullName} {dialect}" +
                $":callIt() [ var beanType = host.resolveType('{typeof(SupportBean).FullName}'); return host.newObj(beanType, 'E1', 10); ]";
            env.CompileDeploy(
                    expression + " select callIt() as val0, callIt().GetTheString() as val1 from SupportBean as sb")
                .AddListener("s0");
            Assert.AreEqual(typeof(SupportBean), env.Statement("s0").EventType.GetPropertyType("val0"));

            env.SendEventBean(new SupportBean());
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                new[] {"val0.TheString", "val0.IntPrimitive", "val1"},
                new object[] {"E1", 10, "E1"});

            env.UndeployAll();
        }
Ejemplo n.º 22
0
        public void TestObjectWithArg()
        {
            var joinStatement = "select id, theString from " +
                                typeof(SupportBean).Name + "().win:length(3) as s1, " +
                                " method:com.espertech.esper.support.epl.SupportStaticMethodLib.FetchObject(theString)";

            var stmt = _epService.EPAdministrator.CreateEPL(joinStatement);

            stmt.AddListener(_listener);
            var fields = new string[] { "id", "theString" };

            SendBeanEvent("E1");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "|E1|", "E1" });

            SendBeanEvent(null);
            Assert.IsFalse(_listener.IsInvoked);

            SendBeanEvent("E2");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "|E2|", "E2" });
        }
Ejemplo n.º 23
0
        public void TestWhereClauseNoIndexNoCache()
        {
            String stmtText = "select id, mycol3, mycol2 from " +
                              typeof(SupportBean_S0).FullName + "#keepall as s0," +
                              " sql:MyDB ['select mycol3, mycol2 from mytesttable_large'] as s1 where s0.id = s1.mycol3";

            EPStatement statement = _epServiceRetained.EPAdministrator.CreateEPL(stmtText);

            _listener         = new SupportUpdateListener();
            statement.Events += _listener.Update;

            for (int i = 0; i < 20; i++)
            {
                var num  = i + 1;
                var col2 = Convert.ToString(Math.Round((float)num / 10, MidpointRounding.AwayFromZero));
                var bean = new SupportBean_S0(num);
                _epServiceRetained.EPRuntime.SendEvent(bean);
                EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), new String[] { "id", "mycol3", "mycol2" }, new Object[] { num, num, col2 });
            }
        }
Ejemplo n.º 24
0
        public void TestNoJoinNoAliasWithProperties()
        {
            var viewExpr       = "select IntPrimitive as a, string.*, IntPrimitive as b from " + typeof(SupportBean).FullName + ".win:length(3) as string";
            var selectTestView = _epService.EPAdministrator.CreateEPL(viewExpr);

            selectTestView.AddListener(_testListener);

            var type = selectTestView.EventType;

            Assert.AreEqual(22, type.PropertyNames.Length);
            Assert.AreEqual(typeof(Pair <object, DataMap>), type.UnderlyingType);
            Assert.AreEqual(typeof(int?), type.GetPropertyType("a"));
            Assert.AreEqual(typeof(int?), type.GetPropertyType("b"));
            Assert.AreEqual(typeof(string), type.GetPropertyType("TheString"));

            SendBeanEvent("E1", 10);
            var fields = new string[] { "a", "TheString", "IntPrimitive", "b" };

            EPAssertionUtil.AssertProps(_testListener.AssertOneGetNewAndReset(), fields, new object[] { 10, "E1", 10, 10 });
        }
Ejemplo n.º 25
0
        public void TestArrayParameter()
        {
            _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration());
            _epService.EPAdministrator.Configuration.AddImport(typeof(SupportStaticMethodLib));

            var text = "select " +
                       "SupportStaticMethodLib.ArraySumIntBoxed({1,2,null,3,4}) as v1, " +
                       "SupportStaticMethodLib.ArraySumDouble({1,2,3,4.0}) as v2, " +
                       "SupportStaticMethodLib.ArraySumString({'1','2','3','4'}) as v3, " +
                       "SupportStaticMethodLib.ArraySumObject({'1',2,3.0,'4.0'}) as v4 " +
                       " from " + typeof(SupportBean).FullName;

            _listener = new SupportUpdateListener();
            var stmt = _epService.EPAdministrator.CreateEPL(text);

            stmt.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "v1,v2,v3,v4".Split(','), new Object[] { 10, 10d, 10d, 10d });
        }
Ejemplo n.º 26
0
        private void RunAssertionJoinWInnerKeywordWOOnClause(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType<SupportBean>();

            var fields = "a.TheString,b.TheString".Split(',');
            var epl =
                "select * from SupportBean(TheString like 'A%')#length(3) as a inner join SupportBean(TheString like 'B%')#length(3) as b " +
                "where a.IntPrimitive = b.IntPrimitive";
            var stmt = epService.EPAdministrator.CreateEPL(epl);
            var listener = new SupportUpdateListener();
            stmt.Events += listener.Update;

            SendEvent(epService, "A1", 1);
            SendEvent(epService, "A2", 2);
            SendEvent(epService, "A3", 3);
            SendEvent(epService, "B2", 2);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {"A2", "B2"});

            stmt.Dispose();
        }
Ejemplo n.º 27
0
        private static void TryOverloaded(
            RegressionEnvironment env,
            string dialect)
        {
            var epl =
                "@Name('s0') " +
                $"expression int {dialect}:abc() [return 10;]\n" +
                $"expression int {dialect}:abc(p1) [return p1*10;]\n" +
                $"expression int {dialect}:abc(p1, p2) [return p1*p2*10]\n" +
                "select abc() as c0, abc(2) as c1, abc(2,3) as c2 from SupportBean";
            env.CompileDeploy(epl).AddListener("s0");

            env.SendEventBean(new SupportBean());
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                new[] {"c0", "c1", "c2"},
                new object[] {10, 20, 60});

            env.UndeployAll();
        }
Ejemplo n.º 28
0
        public void TestPropertyInsertBean()
        {
            EPStatement stmtWindow = _epService.EPAdministrator.CreateEPL("create window MergeWindow.std:unique(TheString) as SupportBean");

            string      epl       = "on SupportBean as up merge MergeWindow as mv where mv.TheString=up.TheString when not matched then insert select IntPrimitive";
            EPStatement stmtMerge = _epService.EPAdministrator.CreateEPL(epl);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 10));

            EventBean theEvent = stmtWindow.First();

            EPAssertionUtil.AssertProps(theEvent, "TheString,IntPrimitive".Split(','), new object[] { null, 10 });
            stmtMerge.Dispose();

            epl = "on SupportBean as up merge MergeWindow as mv where mv.TheString=up.TheString when not matched then insert select TheString, IntPrimitive";
            _epService.EPAdministrator.CreateEPL(epl);
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 20));

            EPAssertionUtil.AssertPropsPerRow(stmtWindow.GetEnumerator(), "TheString,IntPrimitive".Split(','), new object[][] { new object[] { null, 10 }, new object[] { "E2", 20 } });
        }
Ejemplo n.º 29
0
        public void TestObjectArrayWithMap()
        {
            _epService.EPAdministrator.Configuration.AddEventType("MapType", Collections.SingletonDataMap("im", typeof(String)));
            _epService.EPAdministrator.Configuration.AddEventType("OAType", "p0,p1,p2,p3".Split(','), new Object[] { typeof(String), "MapType", "MapType[]", Collections.SingletonDataMap("om", typeof(String)) });

            EPStatement stmt = _epService.EPAdministrator.CreateEPL("select p0 as c0, p1.im as c1, p2[0].im as c2, p3.om as c3 from OAType");

            stmt.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new Object[] { "E1", Collections.SingletonDataMap("im", "IM1"), new Map[] { Collections.SingletonDataMap("im", "IM2") }, Collections.SingletonDataMap("om", "OM1") }, "OAType");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "c0,c1,c2,c3".Split(','), new Object[] { "E1", "IM1", "IM2", "OM1" });

            _epService.EPAdministrator.DestroyAllStatements();

            // test inserting from array to map
            _epService.EPAdministrator.CreateEPL("insert into MapType(im) select p0 from OAType").Events += _listener.Update;
            _epService.EPRuntime.SendEvent(new Object[] { "E1", null, null, null }, "OAType");
            Assert.That(_listener.AssertOneGetNew(), Is.InstanceOf <MappedEventBean>());
            Assert.AreEqual("E1", _listener.AssertOneGetNew().Get("im"));
        }
Ejemplo n.º 30
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select " +
                          "LevelOne.GetCustomLevelOne(10) as val0, " +
                          "LevelOne.LevelTwo.GetCustomLevelTwo(20) as val1, " +
                          "LevelOne.LevelTwo.LevelThree.GetCustomLevelThree(30) as val2 " +
                          "from SupportLevelZero";

                env.CompileDeploy(epl).AddListener("s0");

                env.SendEventBean(new SupportLevelZero(new SupportLevelOne(new SupportLevelTwo(new SupportLevelThree()))));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    "val0,val1,val2".SplitCsv(),
                    "level1:10",
                    "level2:20",
                    "level3:30");

                env.UndeployAll();
            }