Exemplo n.º 1
0
        private static void RunJoinUniquePerId(RegressionEnvironment env)
        {
            var eventsA = new SupportBean_A[10];
            var eventsB = new SupportBean_B[10];
            var eventsC = new SupportBean_C[10];
            for (var i = 0; i < eventsA.Length; i++) {
                eventsA[i] = new SupportBean_A(Convert.ToString(i));
                eventsB[i] = new SupportBean_B(Convert.ToString(i));
                eventsC[i] = new SupportBean_C(Convert.ToString(i));
            }

            // Test sending a C event
            SendEvent(env, eventsA[0]);
            SendEvent(env, eventsB[0]);
            Assert.IsNull(env.Listener("s0").LastNewData);
            SendEvent(env, eventsC[0]);
            AssertEventsReceived(env, eventsA[0], eventsB[0], eventsC[0]);

            // Test sending a B event
            SendEvent(
                env,
                new object[] {eventsA[1], eventsB[2], eventsC[3]});
            SendEvent(env, eventsC[1]);
            Assert.IsNull(env.Listener("s0").LastNewData);
            SendEvent(env, eventsB[1]);
            AssertEventsReceived(env, eventsA[1], eventsB[1], eventsC[1]);

            // Test sending a C event
            SendEvent(
                env,
                new object[] {eventsA[4], eventsA[5], eventsB[4], eventsB[3]});
            Assert.IsNull(env.Listener("s0").LastNewData);
            SendEvent(env, eventsC[4]);
            AssertEventsReceived(env, eventsA[4], eventsB[4], eventsC[4]);
        }
Exemplo n.º 2
0
        public void TestStartStopStatement()
        {
            SubscriberInterface subscriber = new SubscriberInterface();
            EPStatement         stmt       = _epService.EPAdministrator.CreateEPL("select * from SupportMarkerInterface");

            stmt.Subscriber = subscriber;

            SupportBean_A a1 = new SupportBean_A("A1");

            _epService.EPRuntime.SendEvent(a1);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[] { a1 }, subscriber.GetAndResetIndicate().ToArray());

            SupportBean_B b1 = new SupportBean_B("B1");

            _epService.EPRuntime.SendEvent(b1);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[] { b1 }, subscriber.GetAndResetIndicate().ToArray());

            stmt.Stop();

            SupportBean_C c1 = new SupportBean_C("C1");

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

            stmt.Start();

            SupportBean_D d1 = new SupportBean_D("D1");

            _epService.EPRuntime.SendEvent(d1);
            EPAssertionUtil.AssertEqualsExactOrder(new Object[] { d1 }, subscriber.GetAndResetIndicate().ToArray());
        }
Exemplo n.º 3
0
        private void RunJoinUniquePerId(EPServiceProvider epService, SupportUpdateListener listener)
        {
            var eventsA = new SupportBean_A[10];
            var eventsB = new SupportBean_B[10];
            var eventsC = new SupportBean_C[10];

            for (int i = 0; i < eventsA.Length; i++)
            {
                eventsA[i] = new SupportBean_A(Convert.ToString(i));
                eventsB[i] = new SupportBean_B(Convert.ToString(i));
                eventsC[i] = new SupportBean_C(Convert.ToString(i));
            }

            // Test sending a C event
            SendEvent(epService, eventsA[0]);
            SendEvent(epService, eventsB[0]);
            Assert.IsNull(listener.LastNewData);
            SendEvent(epService, eventsC[0]);
            AssertEventsReceived(listener, eventsA[0], eventsB[0], eventsC[0]);

            // Test sending a B event
            SendEvent(epService, new object[] { eventsA[1], eventsB[2], eventsC[3] });
            SendEvent(epService, eventsC[1]);
            Assert.IsNull(listener.LastNewData);
            SendEvent(epService, eventsB[1]);
            AssertEventsReceived(listener, eventsA[1], eventsB[1], eventsC[1]);

            // Test sending a C event
            SendEvent(epService, new object[] { eventsA[4], eventsA[5], eventsB[4], eventsB[3] });
            Assert.IsNull(listener.LastNewData);
            SendEvent(epService, eventsC[4]);
            AssertEventsReceived(listener, eventsA[4], eventsB[4], eventsC[4]);
            Assert.IsNull(listener.LastNewData);
        }
Exemplo n.º 4
0
        private static SupportBean_A SendA(String id, EPServiceProvider epService)
        {
            var a = new SupportBean_A(id);

            epService.EPRuntime.SendEvent(a);
            return(a);
        }
Exemplo n.º 5
0
        private SupportBean_A SendSupportBean_A(string id)
        {
            var bean = new SupportBean_A(id);

            _epService.EPRuntime.SendEvent(bean);
            return(bean);
        }
Exemplo n.º 6
0
        private SupportBean_A SendSupportBean_A(String id)
        {
            SupportBean_A bean = new SupportBean_A(id);

            _engine.EPRuntime.SendEvent(bean);
            return(bean);
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration());
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _updateListener = new SupportUpdateListener();

            String eventA = typeof(SupportBean_A).FullName;
            String eventB = typeof(SupportBean_B).FullName;

            String joinStatement = "select irstream * from " +
                                   eventA + "()#length(3) as streamA," +
                                   eventB + "()#length(3) as streamB" +
                                   " where streamA.id = streamB.id";

            EPStatement joinView = _epService.EPAdministrator.CreateEPL(joinStatement);

            joinView.Events += _updateListener.Update;

            Assert.AreEqual(typeof(SupportBean_A), joinView.EventType.GetPropertyType("streamA"));
            Assert.AreEqual(typeof(SupportBean_B), joinView.EventType.GetPropertyType("streamB"));
            Assert.AreEqual(2, joinView.EventType.PropertyNames.Length);

            for (int i = 0; i < _eventsA.Length; i++)
            {
                _eventsA[i]       = new SupportBean_A(Convert.ToString(i));
                _eventsASetTwo[i] = new SupportBean_A(Convert.ToString(i));
                _eventsB[i]       = new SupportBean_B(Convert.ToString(i));
                _eventsBSetTwo[i] = new SupportBean_B(Convert.ToString(i));
            }
        }
Exemplo n.º 8
0
        private SupportBean_A SendSupportBean_A(EPServiceProvider epService, string id)
        {
            var bean = new SupportBean_A(id);

            epService.EPRuntime.SendEvent(bean);
            return(bean);
        }
Exemplo n.º 9
0
        private void TryOrAndNot(EPServiceProvider epService, String pattern)
        {
            String expression = "select * " + "from pattern [" + pattern + "]";

            EPStatement           statement = epService.EPAdministrator.CreateEPL(expression);
            SupportUpdateListener listener  = new SupportUpdateListener();

            statement.Events += listener.Update;

            Object eventA1 = new SupportBean_A("A1");

            epService.EPRuntime.SendEvent(eventA1);
            EventBean theEvent = listener.AssertOneGetNewAndReset();

            Assert.AreEqual(eventA1, theEvent.Get("a"));
            Assert.IsNull(theEvent.Get("b"));

            Object eventB1 = new SupportBean_B("B1");

            epService.EPRuntime.SendEvent(eventB1);
            theEvent = listener.AssertOneGetNewAndReset();
            Assert.AreEqual(eventA1, theEvent.Get("a"));
            Assert.AreEqual(eventB1, theEvent.Get("b"));

            statement.Dispose();
        }
Exemplo n.º 10
0
        private void RunAssertionStartStopStatement(EPServiceProvider epService)
        {
            var subscriber = new SubscriberInterface();
            var stmt       = epService.EPAdministrator.CreateEPL("select * from SupportMarkerInterface");

            stmt.Subscriber = subscriber;

            var a1 = new SupportBean_A("A1");

            epService.EPRuntime.SendEvent(a1);
            EPAssertionUtil.AssertEqualsExactOrder(new object[] { a1 }, subscriber.GetAndResetIndicate().ToArray());

            var b1 = new SupportBean_B("B1");

            epService.EPRuntime.SendEvent(b1);
            EPAssertionUtil.AssertEqualsExactOrder(new object[] { b1 }, subscriber.GetAndResetIndicate().ToArray());

            stmt.Stop();

            var c1 = new SupportBean_C("C1");

            epService.EPRuntime.SendEvent(c1);
            Assert.AreEqual(0, subscriber.GetAndResetIndicate().Count);

            stmt.Start();

            var d1 = new SupportBean_D("D1");

            epService.EPRuntime.SendEvent(d1);
            EPAssertionUtil.AssertEqualsExactOrder(new object[] { d1 }, subscriber.GetAndResetIndicate().ToArray());

            stmt.Dispose();
        }
Exemplo n.º 11
0
        private IDictionary <String, Object> GetTestData()
        {
            IDictionary <String, Object> levelThree = new Dictionary <String, Object>();

            levelThree["simpleThree"] = 4000L;
            levelThree["objThree"]    = new SupportBean_D("D1");

            IDictionary <String, Object> levelTwo = new Dictionary <String, Object>();

            levelTwo["simpleTwo"] = 300f;
            levelTwo["objTwo"]    = new SupportBean_C("C1");
            levelTwo["mapTwo"]    = levelThree;

            IDictionary <String, Object> levelOne = new Dictionary <String, Object>();

            levelOne["simpleOne"] = 20;
            levelOne["objOne"]    = new SupportBean_B("B1");
            levelOne["mapOne"]    = levelTwo;

            IDictionary <String, Object> levelZero = new Dictionary <String, Object>();

            levelZero["simple"] = 1d;
            levelZero["obj"]    = new SupportBean_A("A1");
            levelZero["map"]    = levelOne;
            IDictionary <String, Object> noDefZero = new Dictionary <String, Object>();

            noDefZero["item"]     = "|nodefmap.item|";
            levelZero["nodefmap"] = noDefZero;

            return(levelZero);
        }
Exemplo n.º 12
0
        public void TestAnyType()
        {
            Assert.IsTrue(_epService.EPAdministrator.Configuration.IsVariantStreamExists("MyVariantStream"));
            _epService.EPAdministrator.CreateEPL("insert into MyVariantStream select * from " + typeof(SupportBean).FullName);
            _epService.EPAdministrator.CreateEPL("insert into MyVariantStream select * from " + typeof(SupportBeanVariantStream).FullName);
            _epService.EPAdministrator.CreateEPL("insert into MyVariantStream select * from " + typeof(SupportBean_A).FullName);
            _epService.EPAdministrator.CreateEPL("insert into MyVariantStream select Symbol as TheString, Volume as IntPrimitive, Feed as Id from " + typeof(SupportMarketDataBean).FullName);

            EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from MyVariantStream");

            stmt.Events += _listener.Update;
            Assert.AreEqual(0, stmt.EventType.PropertyNames.Length);

            Object eventOne = new SupportBean("E0", -1);

            _epService.EPRuntime.SendEvent(eventOne);
            Assert.AreSame(eventOne, _listener.AssertOneGetNewAndReset().Underlying);

            Object eventTwo = new SupportBean_A("E1");

            _epService.EPRuntime.SendEvent(eventTwo);
            Assert.AreSame(eventTwo, _listener.AssertOneGetNewAndReset().Underlying);

            stmt.Dispose();
            stmt         = _epService.EPAdministrator.CreateEPL("select TheString,Id,IntPrimitive from MyVariantStream");
            stmt.Events += _listener.Update;
            Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("TheString"));
            Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Id"));
            Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("IntPrimitive"));

            String[] fields = "TheString,Id,IntPrimitive".Split(',');
            _epService.EPRuntime.SendEvent(new SupportBeanVariantStream("E1"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1", null, null });

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 10));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E2", null, 10 });

            _epService.EPRuntime.SendEvent(new SupportBean_A("E3"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { null, "E3", null });

            _epService.EPRuntime.SendEvent(new SupportMarketDataBean("s1", 100, 1000L, "f1"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "s1", "f1", 1000L });

            _epService.EPAdministrator.DestroyAllStatements();

            // Test inserting a wrapper of underlying plus properties
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            _epService.EPAdministrator.CreateEPL(
                "create variant schema TheVariantStream as *");
            _epService.EPAdministrator.CreateEPL(
                "insert into TheVariantStream select 'test' as eventConfigId, * from SupportBean");
            _epService.EPAdministrator.CreateEPL("select * from TheVariantStream").Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EventBean theEvent = _listener.AssertOneGetNewAndReset();

            Assert.AreEqual("test", theEvent.Get("eventConfigId"));
            Assert.AreEqual(1, theEvent.Get("IntPrimitive"));
        }
Exemplo n.º 13
0
        private void SendABEvents(EPServiceProvider epService, string id)
        {
            var beanOne = new SupportBean_A(id);
            var beanTwo = new SupportBean_B(id);

            epService.EPRuntime.SendEvent(beanOne);
            epService.EPRuntime.SendEvent(beanTwo);
        }
Exemplo n.º 14
0
 private void AssertEventsReceived(SupportUpdateListener updateListener, SupportBean_A eventA, SupportBean_B eventB, SupportBean_C eventC)
 {
     Assert.AreEqual(1, updateListener.LastNewData.Length);
     Assert.AreSame(eventA, updateListener.LastNewData[0].Get("streamA"));
     Assert.AreSame(eventB, updateListener.LastNewData[0].Get("streamB"));
     Assert.AreSame(eventC, updateListener.LastNewData[0].Get("streamC"));
     updateListener.Reset();
 }
Exemplo n.º 15
0
        private void SendABEvents(String id)
        {
            SupportBean_A beanOne = new SupportBean_A(id);
            SupportBean_B beanTwo = new SupportBean_B(id);

            _epService.EPRuntime.SendEvent(beanOne);
            _epService.EPRuntime.SendEvent(beanTwo);
        }
Exemplo n.º 16
0
 private void AssertEventsReceived(SupportBean_A event_A, SupportBean_B event_B, SupportBean_C event_C)
 {
     Assert.AreEqual(1, _updateListener.LastNewData.Length);
     Assert.AreSame(event_A, _updateListener.LastNewData[0].Get("streamA"));
     Assert.AreSame(event_B, _updateListener.LastNewData[0].Get("streamB"));
     Assert.AreSame(event_C, _updateListener.LastNewData[0].Get("streamC"));
     _updateListener.Reset();
 }
Exemplo n.º 17
0
 private static void SendABEvents(
     RegressionEnvironment env,
     string id)
 {
     var beanOne = new SupportBean_A(id);
     var beanTwo = new SupportBean_B(id);
     env.SendEventBean(beanOne);
     env.SendEventBean(beanTwo);
 }
Exemplo n.º 18
0
 private EventBean[] MakeBeans(String id, int numTrades)
 {
     EventBean[] trades = new EventBean[numTrades];
     for (int i = 0; i < numTrades; i++)
     {
         SupportBean_A bean = new SupportBean_A(id + i);
         trades[i] = SupportEventBeanFactory.CreateObject(bean);
     }
     return(trades);
 }
Exemplo n.º 19
0
 public static EventBean[] MakeEvents_A(String[] ids)
 {
     EventBean[] events = new EventBean[ids.Length];
     for (int i = 0; i < events.Length; i++)
     {
         SupportBean_A bean = new SupportBean_A(ids[i]);
         events[i] = CreateObject(bean);
     }
     return(events);
 }
Exemplo n.º 20
0
        private void RunAssertionSelectArray(EPServiceProvider epService)
        {
            string      stmt      = "select a, b, a[0] as a0, a[0].id as a0Id, a[1] as a1, a[1].id as a1Id, a[2] as a2, a[2].id as a2Id from pattern [a=A until b=B]";
            var         listener  = new SupportUpdateListener();
            EPStatement statement = epService.EPAdministrator.CreateEPL(stmt);

            statement.Events += listener.Update;

            var eventA1 = new SupportBean_A("A1");

            epService.EPRuntime.SendEvent(eventA1);

            var eventA2 = new SupportBean_A("A2");

            epService.EPRuntime.SendEvent(eventA2);
            Assert.IsFalse(listener.IsInvoked);

            var eventB1 = new SupportBean_B("B1");

            epService.EPRuntime.SendEvent(eventB1);

            EventBean theEvent = listener.AssertOneGetNewAndReset();

            EPAssertionUtil.AssertEqualsExactOrder((object[])theEvent.Get("a"), new object[] { eventA1, eventA2 });
            Assert.AreSame(eventA1, theEvent.Get("a0"));
            Assert.AreSame(eventA2, theEvent.Get("a1"));
            Assert.IsNull(theEvent.Get("a2"));
            Assert.AreEqual("A1", theEvent.Get("a0Id"));
            Assert.AreEqual("A2", theEvent.Get("a1Id"));
            Assert.IsNull(theEvent.Get("a2Id"));
            Assert.AreSame(eventB1, theEvent.Get("b"));

            // try wildcard
            stmt              = "select * from pattern [a=A until b=B]";
            statement         = epService.EPAdministrator.CreateEPL(stmt);
            statement.Events += listener.Update;

            epService.EPRuntime.SendEvent(eventA1);
            epService.EPRuntime.SendEvent(eventA2);
            Assert.IsFalse(listener.IsInvoked);
            epService.EPRuntime.SendEvent(eventB1);

            theEvent = listener.AssertOneGetNewAndReset();
            EPAssertionUtil.AssertEqualsExactOrder((object[])theEvent.Get("a"), new object[] { eventA1, eventA2 });
            Assert.AreSame(eventA1, theEvent.Get("a[0]"));
            Assert.AreSame(eventA2, theEvent.Get("a[1]"));
            Assert.IsNull(theEvent.Get("a[2]"));
            Assert.AreEqual("A1", theEvent.Get("a[0].id"));
            Assert.AreEqual("A2", theEvent.Get("a[1].id"));
            Assert.IsNull(theEvent.Get("a[2].id"));
            Assert.AreSame(eventB1, theEvent.Get("b"));

            statement.Dispose();
        }
Exemplo n.º 21
0
        public void TestFollowedEveryMultiple()
        {
            String expression = "select * from pattern [every a=" + typeof(SupportBean_A).FullName +
                                " -> b=" + typeof(SupportBean_B).FullName +
                                " -> c=" + typeof(SupportBean_C).FullName +
                                " -> d=" + typeof(SupportBean_D).FullName +
                                "]";

            Configuration     config    = SupportConfigFactory.GetConfiguration();
            EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(config);

            epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(epService, GetType(), GetType().FullName);
            }

            EPStatement statement = epService.EPAdministrator.CreateEPL(expression);
            var         listener  = new SupportUpdateListener();

            statement.Events += listener.Update;

            var events = new Object[10];

            events[0] = new SupportBean_A("A1");
            epService.EPRuntime.SendEvent(events[0]);

            events[1] = new SupportBean_A("A2");
            epService.EPRuntime.SendEvent(events[1]);

            events[2] = new SupportBean_B("B1");
            epService.EPRuntime.SendEvent(events[2]);

            events[3] = new SupportBean_C("C1");
            epService.EPRuntime.SendEvent(events[3]);
            Assert.IsFalse(listener.IsInvoked);

            events[4] = new SupportBean_D("D1");
            epService.EPRuntime.SendEvent(events[4]);
            Assert.AreEqual(2, listener.LastNewData.Length);
            var fields = new[] { "a", "b", "c", "d" };

            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields,
                                        new[] { events[0], events[2], events[3], events[4] });
            EPAssertionUtil.AssertProps(listener.LastNewData[1], fields,
                                        new[] { events[1], events[2], events[3], events[4] });

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
Exemplo n.º 22
0
 private static void AssertEventsReceived(
     RegressionEnvironment env,
     SupportBean_A eventA,
     SupportBean_B eventB,
     SupportBean_C eventC)
 {
     var updateListener = env.Listener("s0");
     Assert.AreEqual(1, updateListener.LastNewData.Length);
     Assert.AreSame(eventA, updateListener.LastNewData[0].Get("streamA"));
     Assert.AreSame(eventB, updateListener.LastNewData[0].Get("streamB"));
     Assert.AreSame(eventC, updateListener.LastNewData[0].Get("streamC"));
     updateListener.Reset();
 }
Exemplo n.º 23
0
        private static LinkedHashMap <String, Object> MakeTestDataUniform()
        {
            LinkedHashMap <String, Object> testData = new LinkedHashMap <String, Object>();

            testData["B1"] = new SupportBean_A("B1");
            testData["B2"] = new SupportBean_A("B2");
            testData["B3"] = new SupportBean_A("B3");
            testData["A4"] = new SupportBean_A("A4");
            testData["A5"] = new SupportBean_A("A5");
            testData["A6"] = new SupportBean_A("A6");

            return(testData);
        }
Exemplo n.º 24
0
        private EventBean[] MakeBeans(
            string id,
            int numTrades)
        {
            var trades = new EventBean[numTrades];

            for (var i = 0; i < numTrades; i++)
            {
                var bean = new SupportBean_A(id + i);
                trades[i] = SupportEventBeanFactory.CreateObject(supportEventTypeFactory, bean);
            }

            return(trades);
        }
Exemplo n.º 25
0
        private static LinkedHashMap <String, Object> MakeMixedSet()
        {
            LinkedHashMap <String, Object> testData = new LinkedHashMap <String, Object>();

            testData["A1"] = new SupportBean_A("A1");
            testData["B1"] = new SupportBean_B("B1");
            testData["C1"] = new SupportBean_C("C1");
            testData["B2"] = new SupportBean_B("B2");
            testData["A2"] = new SupportBean_A("A2");
            testData["D1"] = new SupportBean_D("D1");
            testData["E1"] = new SupportBean_E("E1");
            testData["F1"] = new SupportBean_F("F1");
            testData["D2"] = new SupportBean_D("D2");
            testData["B3"] = new SupportBean_B("B3");
            testData["G1"] = new SupportBean_G("G1");
            testData["D3"] = new SupportBean_D("D3");

            return(testData);
        }
Exemplo n.º 26
0
        public void SetUp()
        {
            _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration());
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _updateListener = new SupportUpdateListener();

            _eventsA = new SupportBean_A[10];
            _eventsB = new SupportBean_B[10];
            _eventsC = new SupportBean_C[10];
            for (int i = 0; i < _eventsA.Length; i++)
            {
                _eventsA[i] = new SupportBean_A(Convert.ToString(i));
                _eventsB[i] = new SupportBean_B(Convert.ToString(i));
                _eventsC[i] = new SupportBean_C(Convert.ToString(i));
            }
        }
Exemplo n.º 27
0
        public void TestVariantTwoJoinWildcard()
        {
            var textOne = "insert into event2 select * " +
                          "from " + typeof(SupportBean).FullName + ".win:length(100) as s0, " +
                          typeof(SupportBean_A).FullName + ".win:length(5) as s1 " +
                          "where s0.TheString = s1.id";
            var textTwo = "select * from event2.win:length(10)";

            // Attach listener to feed
            var stmtOne     = _epService.EPAdministrator.CreateEPL(textOne);
            var listenerOne = new SupportUpdateListener();

            stmtOne.Events += listenerOne.Update;
            var stmtTwo     = _epService.EPAdministrator.CreateEPL(textTwo);
            var listenerTwo = new SupportUpdateListener();

            stmtTwo.Events += listenerTwo.Update;

            // send event for joins to match on
            var eventA = new SupportBean_A("myId");

            _epService.EPRuntime.SendEvent(eventA);

            var eventOne = SendEvent(10, 11);

            Assert.IsTrue(listenerOne.GetAndClearIsInvoked());
            Assert.AreEqual(1, listenerOne.LastNewData.Length);
            Assert.AreEqual(2, listenerOne.LastNewData[0].EventType.PropertyNames.Length);
            Assert.IsTrue(listenerOne.LastNewData[0].EventType.IsProperty("s0"));
            Assert.IsTrue(listenerOne.LastNewData[0].EventType.IsProperty("s1"));
            Assert.AreSame(eventOne, listenerOne.LastNewData[0].Get("s0"));
            Assert.AreSame(eventA, listenerOne.LastNewData[0].Get("s1"));

            Assert.IsTrue(listenerTwo.GetAndClearIsInvoked());
            Assert.AreEqual(1, listenerTwo.LastNewData.Length);
            Assert.AreEqual(2, listenerTwo.LastNewData[0].EventType.PropertyNames.Length);
            Assert.IsTrue(listenerTwo.LastNewData[0].EventType.IsProperty("s0"));
            Assert.IsTrue(listenerTwo.LastNewData[0].EventType.IsProperty("s1"));
            Assert.AreSame(eventOne, listenerOne.LastNewData[0].Get("s0"));
            Assert.AreSame(eventA, listenerOne.LastNewData[0].Get("s1"));
        }
Exemplo n.º 28
0
        public void TestCreateUnderlying()
        {
            SupportBean   beanOne = new SupportBean();
            SupportBean_A beanTwo = new SupportBean_A("a");

            // Set up event type
            _testTypesMap.Clear();
            _testTypesMap["a"] = typeof(SupportBean);
            _testTypesMap["b"] = typeof(SupportBean_A);
            EventType eventType = SupportEventAdapterService.Service.CreateAnonymousMapType("test", _testTypesMap, true);

            IDictionary <String, Object> events = new Dictionary <String, Object>();

            events["a"] = beanOne;
            events["b"] = beanTwo;

            MapEventBean theEvent = new MapEventBean(events, eventType);

            Assert.AreSame(theEvent.Get("a"), beanOne);
            Assert.AreSame(theEvent.Get("b"), beanTwo);
        }
        private void RunAssertionFollowedEveryMultiple(EPServiceProvider epService)
        {
            string expression = "select * from pattern [every a=" + typeof(SupportBean_A).FullName +
                                " -> b=" + typeof(SupportBean_B).FullName +
                                " -> c=" + typeof(SupportBean_C).FullName +
                                " -> d=" + typeof(SupportBean_D).FullName +
                                "]";

            EPStatement statement = epService.EPAdministrator.CreateEPL(expression);
            var         listener  = new SupportUpdateListener();

            statement.Events += listener.Update;

            var events = new Object[10];

            events[0] = new SupportBean_A("A1");
            epService.EPRuntime.SendEvent(events[0]);

            events[1] = new SupportBean_A("A2");
            epService.EPRuntime.SendEvent(events[1]);

            events[2] = new SupportBean_B("B1");
            epService.EPRuntime.SendEvent(events[2]);

            events[3] = new SupportBean_C("C1");
            epService.EPRuntime.SendEvent(events[3]);
            Assert.IsFalse(listener.IsInvoked);

            events[4] = new SupportBean_D("D1");
            epService.EPRuntime.SendEvent(events[4]);
            Assert.AreEqual(2, listener.LastNewData.Length);
            var fields = new string[] { "a", "b", "c", "d" };

            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { events[0], events[2], events[3], events[4] });
            EPAssertionUtil.AssertProps(listener.LastNewData[1], fields, new object[] { events[1], events[2], events[3], events[4] });

            statement.Dispose();
        }
Exemplo n.º 30
0
        public void TestCreateUnderlying()
        {
            SupportBean   beanOne = new SupportBean();
            SupportBean_A beanTwo = new SupportBean_A("a");

            // Set up event type
            testTypesMap.Clear();
            testTypesMap.Put("a", typeof(SupportBean));
            testTypesMap.Put("b", typeof(SupportBean_A));
            EventTypeMetadata metadata  = new EventTypeMetadata("MyType", null, EventTypeTypeClass.STREAM, EventTypeApplicationType.MAP, NameAccessModifier.INTERNAL, EventTypeBusModifier.NONBUS, false, EventTypeIdPair.Unassigned());
            EventType         eventType = new MapEventType(metadata, testTypesMap, null, null, null, null,
                                                           SupportEventTypeFactory.GetInstance(container).BEAN_EVENT_TYPE_FACTORY);

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

            events.Put("a", beanOne);
            events.Put("b", beanTwo);

            MapEventBean theEvent = new MapEventBean(events, eventType);

            Assert.AreSame(theEvent.Get("a"), beanOne);
            Assert.AreSame(theEvent.Get("b"), beanTwo);
        }