Пример #1
0
        public void RunAssertionEventTypeColumnDef(EventRepresentationEnum eventRepresentationEnum)
        {
            var stmtSchema = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema SchemaOne(col1 int, col2 int)");

            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtSchema.EventType.UnderlyingType);

            var stmt = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window SchemaWindow.std:lastevent() as (s1 SchemaOne)");

            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmt.EventType.UnderlyingType);

            stmt.AddListener(_listenerWindow);
            _epService.EPAdministrator.CreateEPL("insert into SchemaWindow (s1) select sone from SchemaOne as sone");

            IDictionary <String, object> theEvent = new LinkedHashMap <string, object>();

            theEvent.Put("col1", 10);
            theEvent.Put("col2", 11);
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPRuntime.SendEvent(theEvent.Values.ToArray(), "SchemaOne");
            }
            else
            {
                _epService.EPRuntime.SendEvent(theEvent, "SchemaOne");
            }
            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);
        }
Пример #2
0
        public void RunAssertionNestableMapArray(EventRepresentationEnum eventRepresentationEnum)
        {
            EPStatement stmtInner = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyInnerType as (col1 string[], col2 int[])");
            EventType   inner     = stmtInner.EventType;

            Assert.AreEqual(typeof(string[]), inner.GetPropertyType("col1"));
            Assert.IsTrue(inner.GetPropertyDescriptor("col1").IsIndexed);
            Assert.AreEqual(typeof(int[]), inner.GetPropertyType("col2"));
            Assert.IsTrue(inner.GetPropertyDescriptor("col2").IsIndexed);
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), inner.UnderlyingType);

            EPStatement       stmtOuter = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyOuterType as (col1 MyInnerType, col2 MyInnerType[])");
            FragmentEventType type      = stmtOuter.EventType.GetFragmentType("col1");

            Assert.AreEqual("MyInnerType", type.FragmentType.Name);
            Assert.IsFalse(type.IsIndexed);
            Assert.IsFalse(type.IsNative);
            type = stmtOuter.EventType.GetFragmentType("col2");
            Assert.AreEqual("MyInnerType", type.FragmentType.Name);
            Assert.IsTrue(type.IsIndexed);
            Assert.IsFalse(type.IsNative);

            EPStatement stmtSelect = _epService.EPAdministrator.CreateEPL("select * from MyOuterType");

            stmtSelect.Events += _listener.Update;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtSelect.EventType.UnderlyingType);

            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                Object[] innerData = { "abc,def".Split(','), new int[] { 1, 2 } };
                Object[] outerData = { innerData, new Object[] { innerData, innerData } };
                _epService.EPRuntime.SendEvent(outerData, "MyOuterType");
            }
            else
            {
                IDictionary <String, Object> innerData = new Dictionary <String, Object>();
                innerData.Put("col1", "abc,def".Split(','));
                innerData.Put("col2", new int[] { 1, 2 });
                IDictionary <String, Object> outerData = new Dictionary <String, Object>();
                outerData.Put("col1", innerData);
                outerData.Put("col2", new DataMap[] { innerData, innerData });
                _epService.EPRuntime.SendEvent(outerData, "MyOuterType");
            }
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "col1.col1[1],col2[1].col2[1]".Split(','), new Object[] { "def", 2 });

            _epService.EPAdministrator.Configuration.RemoveEventType("MyInnerType", true);
            _epService.EPAdministrator.Configuration.RemoveEventType("MyOuterType", true);
            _epService.EPAdministrator.DestroyAllStatements();
        }
Пример #3
0
        private void RunAssertPopulateFromNamedWindow(EventRepresentationEnum type)
        {
            _epService.EPAdministrator.CreateEPL("create " + type.GetOutputTypeCreateSchemaName() + " schema Node(nid string)");
            _epService.EPAdministrator.CreateEPL("create window NodeWindow.std:unique(nid) as Node");
            _epService.EPAdministrator.CreateEPL("insert into NodeWindow select * from Node");
            _epService.EPAdministrator.CreateEPL("create " + type.GetOutputTypeCreateSchemaName() + " schema NodePlus(npid string, node Node)");

            var stmt = _epService.EPAdministrator.CreateEPL("insert into NodePlus select 'E1' as npid, n1 as node from NodeWindow n1");

            stmt.Events += _listener.Update;

            if (type.GetOutputClass() == typeof(object[]))
            {
                _epService.EPRuntime.SendEvent(new Object[] { "n1" }, "Node");
            }
            else
            {
                _epService.EPRuntime.SendEvent(Collections.SingletonDataMap("nid", "n1"), "Node");
            }
            var @event = _listener.AssertOneGetNewAndReset();

            Assert.AreEqual("E1", @event.Get("npid"));
            Assert.AreEqual("n1", @event.Get("node.nid"));
            var fragment = (EventBean)@event.GetFragment("node");

            Assert.AreEqual("Node", fragment.EventType.Name);

            _epService.EPAdministrator.DestroyAllStatements();
            _epService.EPAdministrator.Configuration.RemoveEventType("Node", true);
            _epService.EPAdministrator.Configuration.RemoveEventType("NodePlus", true);
            _epService.EPAdministrator.Configuration.RemoveEventType("NodeWindow", true);
        }
Пример #4
0
        private void RunAssertionObjectArrayDelivery(EventRepresentationEnum eventRepresentationEnum)
        {
            var         subscriber = new MySubscriberRowByRowObjectArr();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                eventRepresentationEnum.GetAnnotationText()
                + " select TheString, IntPrimitive from SupportBean.std:unique(TheString)");

            stmt.Subscriber = subscriber;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(),
                            stmt.EventType.UnderlyingType);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertEqualsAnyOrder(
                subscriber.GetAndResetIndicate()[0], new Object[]
            {
                "E1", 1
            }
                );

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 10));
            EPAssertionUtil.AssertEqualsAnyOrder(
                subscriber.GetAndResetIndicate()[0], new Object[]
            {
                "E2", 10
            }
                );

            _epService.EPAdministrator.DestroyAllStatements();
        }
Пример #5
0
        private void RunAssertionOutputLimitNoJoin(EventRepresentationEnum eventRepresentationEnum)
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                eventRepresentationEnum.GetAnnotationText()
                + " select TheString, IntPrimitive from SupportBean output every 2 events");

            stmt.Subscriber = subscriber;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(),
                            stmt.EventType.UnderlyingType);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.AreEqual(0, subscriber.GetAndResetIndicate().Count);
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][]
            {
                new Object[]
                {
                    "E1", 1
                }
                ,
                new Object[]
                {
                    "E2", 2
                }
            }
                                                   , subscriber.GetAndResetIndicate());

            _epService.EPAdministrator.DestroyAllStatements();
        }
Пример #6
0
        private void RunAssertionWidening(EventRepresentationEnum eventRepresentationEnum)
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                eventRepresentationEnum.GetAnnotationText()
                + " select BytePrimitive, IntPrimitive, LongPrimitive, FloatPrimitive from SupportBean(TheString='E1')");

            stmt.Subscriber = subscriber;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(),
                            stmt.EventType.UnderlyingType);

            var bean = new SupportBean();

            bean.TheString      = "E1";
            bean.BytePrimitive  = 1;
            bean.IntPrimitive   = 2;
            bean.LongPrimitive  = 3;
            bean.FloatPrimitive = 4;
            _epService.EPRuntime.SendEvent(bean);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[]
            {
                1, 2L, 3d, 4d
            }
                                                   , subscriber.GetAndResetIndicate()[0]);

            _epService.EPAdministrator.DestroyAllStatements();
        }
Пример #7
0
        private void RunAssertionPerformance(bool namedWindow, EventRepresentationEnum outputType)
        {
            string eplCreate = namedWindow ?
                               outputType.GetAnnotationText() + " create window MyWindow.win:keepall() as (c1 string, c2 int)" :
                               "create table MyWindow(c1 string primary key, c2 int)";
            EPStatement stmtNamedWindow = _epService.EPAdministrator.CreateEPL(eplCreate);

            Assert.AreEqual(outputType.GetOutputClass(), stmtNamedWindow.EventType.UnderlyingType);

            // preload events
            EPStatement stmt         = _epService.EPAdministrator.CreateEPL("insert into MyWindow select TheString as c1, IntPrimitive as c2 from SupportBean");
            int         totalUpdated = 5000;

            for (int i = 0; i < totalUpdated; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean("E" + i, 0));
            }
            stmt.Dispose();

            string epl = "on SupportBean sb merge MyWindow nw where nw.c1 = sb.TheString " +
                         "when matched then update set nw.c2=sb.IntPrimitive";

            stmt = _epService.EPAdministrator.CreateEPL(epl);
            stmt.AddListener(_mergeListener);

            // prime
            for (int i = 0; i < 100; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean("E" + i, 1));
            }
            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < totalUpdated; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean("E" + i, 1));
                }
            });

            // verify
            IEnumerator <EventBean> events = stmtNamedWindow.GetEnumerator();
            int count = 0;

            while (events.MoveNext())
            {
                EventBean next = events.Current;
                Assert.AreEqual(1, next.Get("c2"));
                count++;
            }
            Assert.AreEqual(totalUpdated, count);
            Assert.IsTrue(delta < 500, "Delta=" + delta);

            _epService.EPAdministrator.DestroyAllStatements();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyWindow", true);
        }
Пример #8
0
        private void RunAssertionCreateStreamTwo(EventRepresentationEnum eventRepresentationEnum)
        {
            _epService.EPAdministrator.CreateEPL(
                eventRepresentationEnum.GetAnnotationText()
                + " create schema MyEvent(myId int)");
            _epService.EPAdministrator.CreateEPL(
                eventRepresentationEnum.GetAnnotationText()
                + " create schema AllMyEvent as (myEvent MyEvent, class String, reverse boolean)");
            _epService.EPAdministrator.CreateEPL(
                eventRepresentationEnum.GetAnnotationText()
                + " create schema SuspectMyEvent as (myEvent MyEvent, class String)");

            var stmtOne = _epService.EPAdministrator.CreateEPL(
                "insert into AllMyEvent "
                + "select c as myEvent, 'test' as class, false as reverse "
                + "from MyEvent(myId=1) c");

            stmtOne.Events += _listener.Update;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(),
                            stmtOne.EventType.UnderlyingType);

            var stmtTwo = _epService.EPAdministrator.CreateEPL(
                "insert into SuspectMyEvent "
                + "select c.myEvent as myEvent, class "
                + "from AllMyEvent(not reverse) c");
            var listenerTwo = new SupportUpdateListener();

            stmtTwo.Events += listenerTwo.Update;

            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPRuntime.SendEvent(MakeEvent(1).Values.ToArray(), "MyEvent");
            }
            else
            {
                _epService.EPRuntime.SendEvent(MakeEvent(1), "MyEvent");
            }

            var resultOne = _listener.AssertOneGetNewAndReset();

            Assert.IsTrue(resultOne.Get("myEvent") is EventBean);
            Assert.AreEqual(1, ((EventBean)resultOne.Get("myEvent")).Get("myId"));
            Assert.NotNull(stmtOne.EventType.GetFragmentType("myEvent"));

            var resultTwo = listenerTwo.AssertOneGetNewAndReset();

            Assert.IsTrue(resultTwo.Get("myEvent") is EventBean);
            Assert.AreEqual(1, ((EventBean)resultTwo.Get("myEvent")).Get("myId"));
            Assert.NotNull(stmtTwo.EventType.GetFragmentType("myEvent"));

            _epService.Initialize();
        }
Пример #9
0
        private void RunAssertionInsertWhereOMStaggered(EventRepresentationEnum eventRepresentationEnum)
        {
            IDictionary <String, object> dataType = MakeMap(new object[][] { new object[] { "a", typeof(string) }, new object[] { "b", typeof(int) } });

            epService.EPAdministrator.Configuration.AddEventType("MyMap", dataType);

            string      stmtTextCreateOne = eventRepresentationEnum.GetAnnotationText() + " create window MyWindow.win:keepall() as select a, b from MyMap";
            EPStatement stmtCreateOne     = epService.EPAdministrator.CreateEPL(stmtTextCreateOne);

            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtCreateOne.EventType.UnderlyingType);
            stmtCreateOne.AddListener(listeners[0]);

            // create insert into
            string stmtTextInsertOne = "insert into MyWindow select a, b from MyMap";

            epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            // populate some data
            epService.EPRuntime.SendEvent(MakeMap(new object[][] { new object[] { "a", "E1" }, new object[] { "b", 2 } }), "MyMap");
            epService.EPRuntime.SendEvent(MakeMap(new object[][] { new object[] { "a", "E2" }, new object[] { "b", 10 } }), "MyMap");
            epService.EPRuntime.SendEvent(MakeMap(new object[][] { new object[] { "a", "E3" }, new object[] { "b", 10 } }), "MyMap");

            // create window with keep-all using OM
            EPStatementObjectModel model = new EPStatementObjectModel();

            eventRepresentationEnum.AddAnnotation(model);
            Expression where   = Expressions.Eq("b", 10);
            model.CreateWindow = CreateWindowClause.Create("MyWindowTwo", View.Create("win", "keepall")).SetInsert(true).SetInsertWhereClause(where);
            model.SelectClause = SelectClause.CreateWildcard();
            model.FromClause   = FromClause.Create(FilterStream.Create("MyWindow"));
            string text = eventRepresentationEnum.GetAnnotationText() + " create window MyWindowTwo.win:keepall() as select * from MyWindow insert where b=10";

            Assert.AreEqual(text.Trim(), model.ToEPL());

            EPStatementObjectModel modelTwo = epService.EPAdministrator.CompileEPL(text);

            Assert.AreEqual(text.Trim(), modelTwo.ToEPL());

            EPStatement stmt = epService.EPAdministrator.Create(modelTwo);

            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), "a,b".Split(','), new object[][] { new object[] { "E2", 10 }, new object[] { "E3", 10 } });

            // test select individual fields and from an insert-from named window
            stmt = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window MyWindowThree.win:keepall() as select a from MyWindowTwo insert where a = 'E2'");
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), "a".Split(','), new object[][] { new object[] { "E2" } });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("MyWindow", true);
            epService.EPAdministrator.Configuration.RemoveEventType("MyWindowTwo", true);
            epService.EPAdministrator.Configuration.RemoveEventType("MyWindowThree", true);
        }
Пример #10
0
        private void RunAssertionMapTranspose(EventRepresentationEnum eventRepresentationEnum)
        {
            IDictionary <String, object> innerTypeOne = new Dictionary <string, object>();

            innerTypeOne.Put("i1", typeof(int));
            IDictionary <String, object> innerTypeTwo = new Dictionary <string, object>();

            innerTypeTwo.Put("i2", typeof(int));
            IDictionary <String, object> outerType = new Dictionary <string, object>();

            outerType.Put("one", "T1");
            outerType.Put("two", "T2");
            _epService.EPAdministrator.Configuration.AddEventType("T1", innerTypeOne);
            _epService.EPAdministrator.Configuration.AddEventType("T2", innerTypeTwo);
            _epService.EPAdministrator.Configuration.AddEventType("OuterType", outerType);

            // create window
            var stmtTextCreate = eventRepresentationEnum.GetAnnotationText() + " create window MyWindow.win:keepall() as select one, two from OuterType";
            var stmtCreate     = _epService.EPAdministrator.CreateEPL(stmtTextCreate);

            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtCreate.EventType.UnderlyingType);
            stmtCreate.AddListener(_listenerWindow);
            EPAssertionUtil.AssertEqualsAnyOrder(stmtCreate.EventType.PropertyNames, new string[] { "one", "two" });
            var eventType = stmtCreate.EventType;

            Assert.AreEqual("T1", eventType.GetFragmentType("one").FragmentType.Name);
            Assert.AreEqual("T2", eventType.GetFragmentType("two").FragmentType.Name);

            // create insert into
            var stmtTextInsertOne = "insert into MyWindow select one, two from OuterType";

            _epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            IDictionary <String, object> innerDataOne = new Dictionary <string, object>();

            innerDataOne.Put("i1", 1);
            IDictionary <String, object> innerDataTwo = new Dictionary <string, object>();

            innerDataTwo.Put("i2", 2);
            IDictionary <String, object> outerData = new Dictionary <string, object>();

            outerData.Put("one", innerDataOne);
            outerData.Put("two", innerDataTwo);

            _epService.EPRuntime.SendEvent(outerData, "OuterType");
            EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), "one.i1,two.i2".Split(','), new object[] { 1, 2 });

            _epService.EPAdministrator.DestroyAllStatements();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyWindow", true);
        }
Пример #11
0
        private void RunAssertionObjectArrayDelivery(EventRepresentationEnum eventRepresentationEnum, SupportSubscriberRowByRowObjectArrayBase subscriber)
        {
            var stmt = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select TheString, IntPrimitive from SupportBean.std:unique(TheString)");

            stmt.Subscriber = subscriber;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmt.EventType.UnderlyingType);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            subscriber.AssertOneAndReset(stmt, new object[] { "E1", 1 });

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 10));
            subscriber.AssertOneAndReset(stmt, new object[] { "E2", 10 });

            stmt.Dispose();
        }
Пример #12
0
        private void RunAssertionOutputLimitNoJoin(EventRepresentationEnum eventRepresentationEnum, SupportSubscriberRowByRowSpecificBase subscriber)
        {
            var stmt = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select TheString, IntPrimitive from SupportBean output every 2 events");

            stmt.Subscriber = subscriber;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmt.EventType.UnderlyingType);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            subscriber.AssertNoneReceived();

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            subscriber.AssertMultipleReceivedAndReset(stmt, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } });

            stmt.Dispose();
        }
Пример #13
0
        private void RunAssertionInnerJoinLateStart(EventRepresentationEnum eventRepresentationEnum)
        {
            var stmtOne = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema Product (product string, size int)");

            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtOne.EventType.UnderlyingType);
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema Portfolio (portfolio string, product string)");
            var stmtTwo = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window ProductWin.win:keepall() as Product");

            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtTwo.EventType.UnderlyingType);

            _epService.EPAdministrator.CreateEPL("insert into ProductWin select * from Product");
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window PortfolioWin.win:keepall() as Portfolio");
            _epService.EPAdministrator.CreateEPL("insert into PortfolioWin select * from Portfolio");

            SendProduct(eventRepresentationEnum, "productA", 1);
            SendProduct(eventRepresentationEnum, "productB", 2);
            SendPortfolio(eventRepresentationEnum, "Portfolio", "productA");

            var stmtText = "@Name(\"Query2\") select portfolio, ProductWin.product, size " +
                           "from PortfolioWin unidirectional inner join ProductWin on PortfolioWin.product=ProductWin.product";
            var stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.AddListener(_listenerStmtOne);

            SendPortfolio(eventRepresentationEnum, "Portfolio", "productB");
            EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), new string[] { "portfolio", "ProductWin.product", "size" }, new object[] { "Portfolio", "productB", 2 });

            SendPortfolio(eventRepresentationEnum, "Portfolio", "productC");
            _listenerStmtOne.Reset();

            SendProduct(eventRepresentationEnum, "productC", 3);
            SendPortfolio(eventRepresentationEnum, "Portfolio", "productC");
            EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), new string[] { "portfolio", "ProductWin.product", "size" }, new object[] { "Portfolio", "productC", 3 });

            _epService.Initialize();
        }
Пример #14
0
        private void RunAssertionWidening(EventRepresentationEnum eventRepresentationEnum, SupportSubscriberRowByRowSpecificBase subscriber)
        {
            var stmt = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select BytePrimitive, IntPrimitive, LongPrimitive, FloatPrimitive from SupportBean(TheString='E1')");

            stmt.Subscriber = subscriber;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmt.EventType.UnderlyingType);

            var bean = new SupportBean();

            bean.TheString      = "E1";
            bean.BytePrimitive  = (byte)1;
            bean.IntPrimitive   = 2;
            bean.LongPrimitive  = 3;
            bean.FloatPrimitive = 4;
            _epService.EPRuntime.SendEvent(bean);
            subscriber.AssertOneReceivedAndReset(stmt, new object[] { 1, 2L, 3d, 4d });

            stmt.Dispose();
        }
Пример #15
0
        private void RunAssertionBindMap(EventRepresentationEnum eventRepresentationEnum, SupportSubscriberMultirowMapBase subscriber)
        {
            var stmtText = eventRepresentationEnum.GetAnnotationText() + " select irstream TheString, IntPrimitive from " + typeof(SupportBean).FullName + ".win:length_batch(2)";
            var stmt     = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.Subscriber = subscriber;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmt.EventType.UnderlyingType);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            subscriber.AssertNoneReceived();

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            subscriber.AssertOneReceivedAndReset(stmt, _fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } }, null);

            _epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            subscriber.AssertNoneReceived();

            _epService.EPRuntime.SendEvent(new SupportBean("E4", 4));
            subscriber.AssertOneReceivedAndReset(stmt, _fields, new object[][] { new object[] { "E3", 3 }, new object[] { "E4", 4 } }, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } });

            stmt.Dispose();
        }
Пример #16
0
        private void RunAssertionColDefPlain(EventRepresentationEnum eventRepresentationEnum)
        {
            EPStatement stmtCreate = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col1 string, col2 int, sbean " + typeof(SupportBean).FullName + ", col3.col4 int)");

            AssertTypeColDef(stmtCreate.EventType);
            EPStatement stmtSelect = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select * from MyEventType");

            AssertTypeColDef(stmtSelect.EventType);

            stmtSelect.Dispose();
            stmtCreate.Dispose();

            // destroy and create differently
            stmtCreate = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col3 string, col4 int)");
            Assert.AreEqual(typeof(int), stmtCreate.EventType.GetPropertyType("col4"));
            Assert.AreEqual(2, stmtCreate.EventType.PropertyDescriptors.Count);

            stmtCreate.Stop();

            // destroy and create differently
            stmtCreate = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col5 string, col6 int)");
            Assert.AreEqual(stmtCreate.EventType.UnderlyingType, eventRepresentationEnum.GetOutputClass());
            Assert.AreEqual(typeof(int), stmtCreate.EventType.GetPropertyType("col6"));
            Assert.AreEqual(2, stmtCreate.EventType.PropertyDescriptors.Count);
            stmtSelect         = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select * from MyEventType");
            stmtSelect.Events += _listener.Update;
            Assert.AreEqual(stmtSelect.EventType.UnderlyingType, eventRepresentationEnum.GetOutputClass());

            // send event
            IDictionary <String, Object> data = new LinkedHashMap <String, Object>();

            data.Put("col5", "abc");
            data.Put("col6", 1);
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPRuntime.SendEvent(data.Values.ToArray(), "MyEventType");
            }
            else
            {
                _epService.EPRuntime.SendEvent(data, "MyEventType");
            }
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "col5,col6".Split(','), new Object[] { "abc", 1 });

            // assert type information
            EventTypeSPI typeSPI = (EventTypeSPI)stmtSelect.EventType;

            Assert.AreEqual(TypeClass.APPLICATION, typeSPI.Metadata.TypeClass);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PublicName);
            Assert.IsTrue(typeSPI.Metadata.IsApplicationConfigured);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfigured);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfiguredStatic);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PrimaryName);

            // test non-enum create-schema
            String      epl           = "create" + eventRepresentationEnum.GetOutputTypeCreateSchemaName() + " schema MyEventTypeTwo as (col1 string, col2 int, sbean " + typeof(SupportBean).FullName + ", col3.col4 int)";
            EPStatement stmtCreateTwo = _epService.EPAdministrator.CreateEPL(epl);

            AssertTypeColDef(stmtCreateTwo.EventType);
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtCreateTwo.EventType.UnderlyingType);
            stmtCreateTwo.Dispose();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyEventTypeTwo", true);

            EPStatementObjectModel model = _epService.EPAdministrator.CompileEPL(epl);

            Assert.AreEqual(model.ToEPL(), epl);
            stmtCreateTwo = _epService.EPAdministrator.Create(model);
            AssertTypeColDef(stmtCreateTwo.EventType);
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtCreateTwo.EventType.UnderlyingType);

            _epService.Initialize();
        }
Пример #17
0
        private void RunAssertionBindObjectArr(EventRepresentationEnum eventRepresentationEnum)
        {
            var    subscriber = new MySubscriberMultirowObjectArr();
            String stmtText   = eventRepresentationEnum.GetAnnotationText()
                                + " select irstream TheString, IntPrimitive from "
                                + typeof(SupportBean).FullName + ".win:length_batch(2)";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.Subscriber = subscriber;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(),
                            stmt.EventType.UnderlyingType);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.AreEqual(0, subscriber.IndicateArr.Count);
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            Assert.AreEqual(1, subscriber.IndicateArr.Count);
            UniformPair <Object[][]> result = subscriber.GetAndResetIndicateArr()[0];

            Assert.IsNull(result.Second);
            Assert.AreEqual(2, result.First.Length);
            EPAssertionUtil.AssertEqualsExactOrder(
                result.First, _fields,
                new Object[][]
            {
                new Object[]
                {
                    "E1", 1
                }
                ,
                new Object[]
                {
                    "E2", 2
                }
            }
                );

            _epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            Assert.AreEqual(0, subscriber.IndicateArr.Count);
            _epService.EPRuntime.SendEvent(new SupportBean("E4", 4));
            Assert.AreEqual(1, subscriber.IndicateArr.Count);
            result = subscriber.GetAndResetIndicateArr()[0];
            Assert.AreEqual(2, result.First.Length);
            Assert.AreEqual(2, result.Second.Length);
            EPAssertionUtil.AssertEqualsExactOrder(
                result.First, _fields,
                new Object[][]
            {
                new Object[]
                {
                    "E3", 3
                }
                ,
                new Object[]
                {
                    "E4", 4
                }
            }
                );
            EPAssertionUtil.AssertEqualsExactOrder(
                result.Second, _fields,
                new Object[][]
            {
                new Object[]
                {
                    "E1", 1
                }
                ,
                new Object[]
                {
                    "E2", 2
                }
            }
                );

            _epService.EPAdministrator.DestroyAllStatements();
        }
Пример #18
0
        private void RunAssertionStaggered(EventRepresentationEnum outputType)
        {
            string[] fieldsOne = new string[] { "a1", "b1" };
            string[] fieldsTwo = new string[] { "a2", "b2" };

            // create window one
            string      stmtTextCreateOne = outputType.GetAnnotationText() + " create window MyWindowOne.win:keepall() as select TheString as a1, IntPrimitive as b1 from " + typeof(SupportBean).FullName;
            EPStatement stmtCreateOne     = _epService.EPAdministrator.CreateEPL(stmtTextCreateOne);

            stmtCreateOne.AddListener(_listenerWindow);
            Assert.AreEqual(0, GetCount("MyWindowOne"));
            Assert.AreEqual(outputType.GetOutputClass(), stmtCreateOne.EventType.UnderlyingType);

            // create window two
            string      stmtTextCreateTwo = outputType.GetAnnotationText() + " create window MyWindowTwo.win:keepall() as select TheString as a2, IntPrimitive as b2 from " + typeof(SupportBean).FullName;
            EPStatement stmtCreateTwo     = _epService.EPAdministrator.CreateEPL(stmtTextCreateTwo);

            stmtCreateTwo.AddListener(_listenerWindowTwo);
            Assert.AreEqual(0, GetCount("MyWindowTwo"));
            Assert.AreEqual(outputType.GetOutputClass(), stmtCreateTwo.EventType.UnderlyingType);

            // create delete stmt
            string      stmtTextDelete = "on MyWindowOne delete from MyWindowTwo where a1 = a2";
            EPStatement stmtDelete     = _epService.EPAdministrator.CreateEPL(stmtTextDelete);

            stmtDelete.AddListener(_listenerDelete);
            Assert.AreEqual(StatementType.ON_DELETE, ((EPStatementSPI)stmtDelete).StatementMetadata.StatementType);

            // create insert into
            string stmtTextInsert = "insert into MyWindowOne select TheString as a1, IntPrimitive as b1 from " + typeof(SupportBean).FullName + "(IntPrimitive > 0)";

            _epService.EPAdministrator.CreateEPL(stmtTextInsert);
            stmtTextInsert = "insert into MyWindowTwo select TheString as a2, IntPrimitive as b2 from " + typeof(SupportBean).FullName + "(IntPrimitive < 0)";
            _epService.EPAdministrator.CreateEPL(stmtTextInsert);

            SendSupportBean("E1", -10);
            EPAssertionUtil.AssertProps(_listenerWindowTwo.AssertOneGetNewAndReset(), fieldsTwo, new object[] { "E1", -10 });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateTwo.GetEnumerator(), fieldsTwo, new object[][] { new object[] { "E1", -10 } });
            Assert.IsFalse(_listenerWindow.IsInvoked);
            Assert.AreEqual(1, GetCount("MyWindowTwo"));

            SendSupportBean("E2", 5);
            EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), fieldsOne, new object[] { "E2", 5 });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateOne.GetEnumerator(), fieldsOne, new object[][] { new object[] { "E2", 5 } });
            Assert.IsFalse(_listenerWindowTwo.IsInvoked);
            Assert.AreEqual(1, GetCount("MyWindowOne"));

            SendSupportBean("E3", -1);
            EPAssertionUtil.AssertProps(_listenerWindowTwo.AssertOneGetNewAndReset(), fieldsTwo, new object[] { "E3", -1 });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateTwo.GetEnumerator(), fieldsTwo, new object[][] { new object[] { "E1", -10 }, new object[] { "E3", -1 } });
            Assert.IsFalse(_listenerWindow.IsInvoked);
            Assert.AreEqual(2, GetCount("MyWindowTwo"));

            SendSupportBean("E3", 1);
            EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), fieldsOne, new object[] { "E3", 1 });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateOne.GetEnumerator(), fieldsOne, new object[][] { new object[] { "E2", 5 }, new object[] { "E3", 1 } });
            EPAssertionUtil.AssertProps(_listenerWindowTwo.AssertOneGetOldAndReset(), fieldsTwo, new object[] { "E3", -1 });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateTwo.GetEnumerator(), fieldsTwo, new object[][] { new object[] { "E1", -10 } });
            Assert.AreEqual(2, GetCount("MyWindowOne"));
            Assert.AreEqual(1, GetCount("MyWindowTwo"));

            stmtDelete.Dispose();
            stmtCreateOne.Dispose();
            stmtCreateTwo.Dispose();
            _listenerDelete.Reset();
            _listenerSelect.Reset();
            _listenerWindow.Reset();
            _listenerWindowTwo.Reset();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyWindowOne", true);
            _epService.EPAdministrator.Configuration.RemoveEventType("MyWindowTwo", true);
        }
Пример #19
0
        private void RunAssertionSchemaCopyProperties(EventRepresentationEnum eventRepresentationEnum)
        {
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema BaseOne (prop1 String, prop2 int)");
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema BaseTwo (prop3 long)");

            // test define and send
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema E1 () copyfrom BaseOne");
            EPStatement stmtOne = _epService.EPAdministrator.CreateEPL("select * from E1");

            stmtOne.Events += _listener.Update;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtOne.EventType.UnderlyingType);
            Assert.AreEqual(typeof(string), stmtOne.EventType.GetPropertyType("prop1"));
            Assert.AreEqual(typeof(int), stmtOne.EventType.GetPropertyType("prop2"));

            IDictionary <String, Object> eventE1 = new LinkedHashMap <String, Object>();

            eventE1.Put("prop1", "v1");
            eventE1.Put("prop2", 2);
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPRuntime.SendEvent(eventE1.Values.ToArray(), "E1");
            }
            else
            {
                _epService.EPRuntime.SendEvent(eventE1, "E1");
            }
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "prop1,prop2".Split(','), new Object[] { "v1", 2 });

            // test two copy-from types
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema E2 () copyfrom BaseOne, BaseTwo");
            EPStatement stmtTwo = _epService.EPAdministrator.CreateEPL("select * from E2");

            Assert.AreEqual(typeof(string), stmtTwo.EventType.GetPropertyType("prop1"));
            Assert.AreEqual(typeof(int), stmtTwo.EventType.GetPropertyType("prop2"));
            Assert.AreEqual(typeof(long), stmtTwo.EventType.GetPropertyType("prop3"));

            // test API-defined type
            IDictionary <String, Object> def = new Dictionary <String, Object>();

            def.Put("a", "string");
            def.Put("b", typeof(String));
            def.Put("c", "BaseOne");
            def.Put("d", "BaseTwo[]");
            _epService.EPAdministrator.Configuration.AddEventType("MyType", def);

            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema E3(e long, f BaseOne) copyfrom MyType");
            EPStatement stmtThree = _epService.EPAdministrator.CreateEPL("select * from E3");

            Assert.AreEqual(typeof(String), stmtThree.EventType.GetPropertyType("a"));
            Assert.AreEqual(typeof(String), stmtThree.EventType.GetPropertyType("b"));
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                Assert.AreEqual(typeof(Object[]), stmtThree.EventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(Object[][]), stmtThree.EventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(Object[]), stmtThree.EventType.GetPropertyType("f"));
            }
            else
            {
                Assert.AreEqual(typeof(DataMap), stmtThree.EventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(DataMap[]), stmtThree.EventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(DataMap), stmtThree.EventType.GetPropertyType("f"));
            }
            Assert.AreEqual(typeof(long), stmtThree.EventType.GetPropertyType("e"));

            // invalid tests
            TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create schema E4(a long) copyFrom MyType",
                       "Error starting statement: Type by name 'MyType' contributes property 'a' defined as 'System.String' which overides the same property of type '" + typeof(long).FullName + "' [");
            TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create schema E4(c BaseTwo) copyFrom MyType",
                       "Error starting statement: Property by name 'c' is defined twice by adding type 'MyType' [");
            TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create schema E4(c BaseTwo) copyFrom XYZ",
                       "Error starting statement: Type by name 'XYZ' could not be located [");
            TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create schema E4 as " + typeof(SupportBean).FullName + " copyFrom XYZ",
                       "Error starting statement: Copy-from types are not allowed with class-provided types [");
            TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create variant schema E4(c BaseTwo) copyFrom XYZ",
                       "Error starting statement: Copy-from types are not allowed with variant types [");

            // test SODA
            String createEPL             = eventRepresentationEnum.GetAnnotationText() + " create schema EX as () copyFrom BaseOne, BaseTwo";
            EPStatementObjectModel model = _epService.EPAdministrator.CompileEPL(createEPL);

            Assert.AreEqual(createEPL.Trim(), model.ToEPL());
            EPStatement stmt = _epService.EPAdministrator.Create(model);

            Assert.AreEqual(createEPL.Trim(), stmt.Text);

            _epService.Initialize();
        }
Пример #20
0
        private void RunAssertionSingleRowSplitAndType(EventRepresentationEnum eventRepresentationEnum)
        {
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitSentence", GetType().FullName, "SplitSentenceMethodReturnObjectArray");
                _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitSentenceBean", GetType().FullName, "SplitSentenceBeanMethodReturnObjectArray");
                _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitWord", GetType().FullName, "SplitWordMethodReturnObjectArray");
            }
            else
            {
                _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitSentence", GetType().FullName, "SplitSentenceMethodReturnMap");
                _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitSentenceBean", GetType().FullName, "SplitSentenceBeanMethodReturnMap");
                _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitWord", GetType().FullName, "SplitWordMethodReturnMap");
            }
            _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("invalidSentence", GetType().FullName, "InvalidSentenceMethod");

            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema SentenceEvent(sentence String)");
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema WordEvent(word String)");
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema CharacterEvent(char String)");

            string      stmtText;
            EPStatement stmt;
            var         fields = "word".Split(',');

            // test single-row method
            stmtText = "select * from SentenceEvent[splitSentence(sentence)@type(WordEvent)]";
            stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
            stmt.AddListener(_listener);
            Assert.AreEqual("WordEvent", stmt.EventType.Name);
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmt.EventType.UnderlyingType);

            SendSentenceEvent(eventRepresentationEnum, "I am testing this code");
            EPAssertionUtil.AssertPropsPerRow(
                _listener.GetAndResetLastNewData(), fields,
                new object[][]
            {
                new object[] { "I" },
                new object[] { "am" },
                new object[] { "testing" },
                new object[] { "this" },
                new object[] { "code" }
            });

            SendSentenceEvent(eventRepresentationEnum, "the second event");
            EPAssertionUtil.AssertPropsPerRow(
                _listener.GetAndResetLastNewData(), fields,
                new object[][]
            {
                new object[] { "the" },
                new object[] { "second" },
                new object[] { "event" }
            });

            stmt.Dispose();

            // test SODA
            var model = _epService.EPAdministrator.CompileEPL(stmtText);

            Assert.AreEqual(stmtText, model.ToEPL());
            stmt = _epService.EPAdministrator.Create(model);
            Assert.AreEqual(stmtText, stmt.Text);
            stmt.AddListener(_listener);

            SendSentenceEvent(eventRepresentationEnum, "the third event");
            EPAssertionUtil.AssertPropsPerRow(
                _listener.GetAndResetLastNewData(), fields,
                new object[][]
            {
                new object[] { "the" },
                new object[] { "third" },
                new object[] { "event" }
            });

            stmt.Dispose();

            // test script
            if (!eventRepresentationEnum.IsObjectArrayEvent())
            {
                stmtText = "expression com.espertech.esper.support.collections.ISupportDataMapCollection js:splitSentenceJS(sentence) [" +
                           "  var words = clr.New('com.espertech.esper.support.collections.SupportDataMapList',[]);" +
                           "  var factory = clr.New('com.espertech.esper.support.collections.SupportDataMapFactory',[]);" +
                           "  words.Add(factory.Create('word', 'wordOne'));" +
                           "  words.Add(factory.Create('word', 'wordTwo'));" +
                           "  words;" +
                           "]" +
                           "select * from SentenceEvent[splitSentenceJS(sentence)@type(WordEvent)]";
                stmt = _epService.EPAdministrator.CreateEPL(stmtText).AddListener(_listener);
                Assert.AreEqual("WordEvent", stmt.EventType.Name);

                _epService.EPRuntime.SendEvent(Collections.EmptyDataMap, "SentenceEvent");
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    _listener.GetAndResetLastNewData(), fields,
                    new object[][]
                {
                    new object[] { "wordOne" },
                    new object[] { "wordTwo" }
                });

                stmt.Dispose();
            }

            // test multiple splitters
            stmtText = "select * from SentenceEvent[splitSentence(sentence)@type(WordEvent)][splitWord(word)@type(CharacterEvent)]";
            stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
            stmt.AddListener(_listener);
            Assert.AreEqual("CharacterEvent", stmt.EventType.Name);

            SendSentenceEvent(eventRepresentationEnum, "I am");
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                _listener.GetAndResetLastNewData(), "char".Split(','),
                new object[][]
            {
                new object[] { "I" },
                new object[] { "a" },
                new object[] { "m" }
            });

            stmt.Dispose();

            // test wildcard parameter
            stmtText = "select * from SentenceEvent[splitSentenceBean(*)@type(WordEvent)]";
            stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
            stmt.AddListener(_listener);
            Assert.AreEqual("WordEvent", stmt.EventType.Name);

            SendSentenceEvent(eventRepresentationEnum, "another test sentence");
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                _listener.GetAndResetLastNewData(), fields,
                new object[][]
            {
                new object[] { "another" },
                new object[] { "test" },
                new object[] { "sentence" }
            });

            stmt.Dispose();

            // test property returning untyped collection
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPAdministrator.Configuration.AddEventType(typeof(ObjectArrayEvent));
                stmtText = eventRepresentationEnum.GetAnnotationText() + " select * from ObjectArrayEvent[someObjectArray@type(WordEvent)]";
                stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
                stmt.AddListener(_listener);
                Assert.AreEqual("WordEvent", stmt.EventType.Name);

                var rows = new object[][] { new object[] { "this" }, new object[] { "is" }, new object[] { "collection" } };
                _epService.EPRuntime.SendEvent(new ObjectArrayEvent(rows));
                EPAssertionUtil.AssertPropsPerRow(
                    _listener.GetAndResetLastNewData(), fields,
                    new object[][]
                {
                    new object[] { "this" },
                    new object[] { "is" },
                    new object[] { "collection" }
                });
            }
            else
            {
                _epService.EPAdministrator.Configuration.AddEventType <CollectionEvent <IDictionary <string, object> > >("CollectionEvent");
                stmtText = eventRepresentationEnum.GetAnnotationText() + " select * from CollectionEvent[someCollection@type(WordEvent)]";
                stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
                stmt.AddListener(_listener);
                Assert.AreEqual("WordEvent", stmt.EventType.Name);

                var coll = new List <IDictionary <string, object> >();
                coll.Add(Collections.SingletonDataMap("word", "this"));
                coll.Add(Collections.SingletonDataMap("word", "is"));
                coll.Add(Collections.SingletonDataMap("word", "collection"));

                _epService.EPRuntime.SendEvent(new CollectionEvent <IDictionary <string, object> >(coll));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    _listener.GetAndResetLastNewData(), fields,
                    new object[][]
                {
                    new object[] { "this" },
                    new object[] { "is" },
                    new object[] { "collection" }
                });
            }

            // invalid: event type not found
            TryInvalid("select * from SentenceEvent[splitSentence(sentence)@type(XYZ)]",
                       "Event type by name 'XYZ' could not be found [select * from SentenceEvent[splitSentence(sentence)@type(XYZ)]]");

            // invalid lib-function annotation
            TryInvalid("select * from SentenceEvent[splitSentence(sentence)@dummy(WordEvent)]",
                       "Invalid annotation for property selection, expected 'type' but found 'dummy' in text '[splitSentence(sentence)@dummy(WordEvent)]' [select * from SentenceEvent[splitSentence(sentence)@dummy(WordEvent)]]");

            // invalid type assignment to event type
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                TryInvalid("select * from SentenceEvent[invalidSentence(sentence)@type(WordEvent)]",
                           "Event type 'WordEvent' underlying type System.Object[] cannot be assigned a value of type");
            }
            else
            {
                TryInvalid("select * from SentenceEvent[invalidSentence(sentence)@type(WordEvent)]",
                           "Event type 'WordEvent' underlying type " + Name.Of <IDictionary <string, object> >() + " cannot be assigned a value of type");
            }

            // invalid subquery
            TryInvalid("select * from SentenceEvent[splitSentence((select * from SupportBean.win:keepall()))@type(WordEvent)]",
                       "Invalid contained-event expression 'splitSentence(subselect_0)': Aggregation, sub-select, previous or prior functions are not supported in this context [select * from SentenceEvent[splitSentence((select * from SupportBean.win:keepall()))@type(WordEvent)]]");

            _epService.Initialize();
        }