예제 #1
0
        public void TestOutputLimitJoin()
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                "select TheString, IntPrimitive from SupportBean.win:keepall(), SupportMarketDataBean.win:keepall() where symbol = TheString output every 2 events");

            stmt.Subscriber = subscriber;

            _epService.EPRuntime.SendEvent(
                new SupportMarketDataBean("E1", 0, 1L, ""));
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.AreEqual(0, subscriber.GetAndResetIndicate().Count);
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 2));
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][]
            {
                new Object[]
                {
                    "E1", 1
                }
                ,
                new Object[]
                {
                    "E1", 2
                }
            }
                                                   , subscriber.GetAndResetIndicate());
        }
예제 #2
0
        public void TestRStreamSelect()
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                "select rstream s0 from SupportBean.std:unique(TheString) as s0");

            stmt.Subscriber = subscriber;

            // send event
            var s0 = new SupportBean("E1", 100);

            _epService.EPRuntime.SendEvent(s0);
            Assert.AreEqual(0, subscriber.GetAndResetIndicate().Count);

            var s1 = new SupportBean("E2", 200);

            _epService.EPRuntime.SendEvent(s1);
            Assert.AreEqual(0, subscriber.GetAndResetIndicate().Count);

            var s2 = new SupportBean("E1", 300);

            _epService.EPRuntime.SendEvent(s2);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][]
            {
                new Object[]
                {
                    s0
                }
            }
                                                   , subscriber.GetAndResetIndicate());
        }
예제 #3
0
        public void TestNullType()
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                "select null, LongBoxed from SupportBean");

            stmt.Subscriber = subscriber;

            _epService.EPRuntime.SendEvent(new SupportBean());
            EPAssertionUtil.AssertEqualsExactOrder(
                new Object[]
            {
                null, null
            }
                , subscriber.GetAndResetIndicate()[0]);
            stmt.Dispose();

            // test null-delivery for no-parameter subscriber
            var subscriberNoParams = new LocalSubscriberNoParams();

            stmt = _epService.EPAdministrator.CreateEPL(
                "select null from SupportBean");
            stmt.Subscriber = subscriberNoParams;

            _epService.EPRuntime.SendEvent(new SupportBean());
            Assert.IsTrue(subscriberNoParams.IsCalled);
        }
예제 #4
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();
        }
예제 #5
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();
        }
예제 #6
0
        public void TestWildcard()
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                "select * from SupportBean(TheString='E2')");

            stmt.Subscriber = subscriber;

            var theEvent = new SupportBean("E2", 1);

            _epService.EPRuntime.SendEvent(theEvent);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[]
            {
                theEvent
            }
                                                   , subscriber.GetAndResetIndicate()[0]);
        }
예제 #7
0
        public void TestNested()
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                "select nested, nested.nestedNested from SupportBeanComplexProps");

            stmt.Subscriber = subscriber;

            SupportBeanComplexProps theEvent = SupportBeanComplexProps.MakeDefaultBean();

            _epService.EPRuntime.SendEvent(theEvent);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[]
            {
                theEvent.Nested, theEvent.Nested.NestedNested
            }
                                                   , subscriber.GetAndResetIndicate()[0]);
        }
예제 #8
0
        public void TestEnum()
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                "select TheString, supportEnum from SupportBeanWithEnum");

            stmt.Subscriber = subscriber;

            var theEvent = new SupportBeanWithEnum("abc",
                                                   SupportEnum.ENUM_VALUE_1);

            _epService.EPRuntime.SendEvent(theEvent);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[]
            {
                theEvent.TheString, theEvent.SupportEnum
            }
                                                   , subscriber.GetAndResetIndicate()[0]);
        }
예제 #9
0
        public void TestBindWildcardPlusProperties()
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                "select *, IntPrimitive + 2, 'x'||TheString||'x' from "
                + typeof(SupportBean).FullName);

            stmt.Subscriber = subscriber;

            var s0 = new SupportBean("E1", 100);

            _epService.EPRuntime.SendEvent(s0);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[]
            {
                s0, 102, "xE1x"
            }
                                                   , subscriber.GetAndResetIndicate()[0]);
        }
예제 #10
0
        public void TestSimpleSelectUpdateOnly()
        {
            MySubscriberRowByRowSpecific subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt = _epService.EPAdministrator.CreateEPL("select TheString, IntPrimitive from " + typeof(SupportBean).FullName + ".std:lastevent()");

            stmt.Subscriber = subscriber;

            // get statement, attach listener
            SupportUpdateListener listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            // send event
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 100));
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E1", 100 } }, subscriber.GetAndResetIndicate());
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), _fields, new Object[][] { new Object[] { "E1", 100 } });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), _fields, new Object[] { "E1", 100 });

            // remove listener
            stmt.RemoveAllEventHandlers();

            // send event
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 200));
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E2", 200 } }, subscriber.GetAndResetIndicate());
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), _fields, new Object[][] { new Object[] { "E2", 200 } });
            Assert.IsFalse(listener.IsInvoked);

            // add listener
            SupportStmtAwareUpdateListener stmtAwareListener = new SupportStmtAwareUpdateListener();

            stmt.Events += stmtAwareListener.Update;

            // send event
            _epService.EPRuntime.SendEvent(new SupportBean("E3", 300));
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E3", 300 } }, subscriber.GetAndResetIndicate());
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), _fields, new Object[][] { new Object[] { "E3", 300 } });
            EPAssertionUtil.AssertProps(stmtAwareListener.AssertOneGetNewAndReset(), _fields, new Object[] { "E3", 300 });
        }
예제 #11
0
        public void TestStreamWildcardJoin()
        {
            var         subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                "select TheString || '<', s1.* as s1, s0.* as s0 from SupportBean.win:keepall() as s0, SupportMarketDataBean.win:keepall() as s1 where s0.TheString = s1.symbol");

            stmt.Subscriber = subscriber;

            // send event
            var s0 = new SupportBean("E1", 100);
            var s1 = new SupportMarketDataBean("E1", 0, 0L, "");

            _epService.EPRuntime.SendEvent(s0);
            _epService.EPRuntime.SendEvent(s1);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][]
            {
                new Object[]
                {
                    "E1<", s1, s0
                }
            }
                                                   , subscriber.GetAndResetIndicate());
        }