private void RunAssertionFollowedByTimer(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType("CallEvent", typeof(SupportCallEvent));

            string expression = "select * from pattern " +
                                "[every A=CallEvent -> every B=CallEvent(dest=A.dest, startTime in [A.startTime:A.endTime]) where timer:within (7200000)]" +
                                "where B.source != A.source";
            EPStatement statement = epService.EPAdministrator.CreateEPL(expression);
            var         listener  = new SupportUpdateListener();

            statement.Events += listener.Update;

            SupportCallEvent eventOne = SendEvent(epService.EPRuntime, 2000002601, "18", "123456789014795", DateToLong("2005-09-26 13:02:53.200"), DateToLong("2005-09-26 13:03:34.400"));
            SupportCallEvent eventTwo = SendEvent(epService.EPRuntime, 2000002607, "20", "123456789014795", DateToLong("2005-09-26 13:03:17.300"), DateToLong("2005-09-26 13:03:58.600"));

            EventBean theEvent = listener.AssertOneGetNewAndReset();

            Assert.AreSame(eventOne, theEvent.Get("A"));
            Assert.AreSame(eventTwo, theEvent.Get("B"));

            SupportCallEvent eventThree = SendEvent(epService.EPRuntime, 2000002610, "22", "123456789014795", DateToLong("2005-09-26 13:03:31.300"), DateToLong("2005-09-26 13:04:12.100"));

            Assert.AreEqual(1, listener.NewDataList.Count);
            Assert.AreEqual(2, listener.LastNewData.Length);
            theEvent = listener.LastNewData[0];
            Assert.AreSame(eventOne, theEvent.Get("A"));
            Assert.AreSame(eventThree, theEvent.Get("B"));
            theEvent = listener.LastNewData[1];
            Assert.AreSame(eventTwo, theEvent.Get("A"));
            Assert.AreSame(eventThree, theEvent.Get("B"));

            statement.Dispose();
        }
        private SupportCallEvent SendEvent(EPRuntime runtime, long callId, string source, string destination, long startTime, long endTime)
        {
            var theEvent = new SupportCallEvent(callId, source, destination, startTime, endTime);

            runtime.SendEvent(theEvent);
            return(theEvent);
        }
Exemple #3
0
 private static SupportCallEvent SendEvent(
     EPEventService runtime,
     long callId,
     string source,
     string destination,
     long startTime,
     long endTime)
 {
     var theEvent = new SupportCallEvent(callId, source, destination, startTime, endTime);
     runtime.SendEventBean(theEvent, typeof(SupportCallEvent).Name);
     return theEvent;
 }
Exemple #4
0
        public void TestFollowedByTimer()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.AddEventType("CallEvent", typeof(SupportCallEvent).FullName);
            EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(config);

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

            const string expression = "select * from pattern " +
                                      "[every A=CallEvent -> every B=CallEvent(dest=A.dest, startTime in [A.startTime:A.endTime]) where timer:within (7200000)]" +
                                      "where B.source != A.source";
            EPStatement statement = epService.EPAdministrator.CreateEPL(expression);
            var         listener  = new SupportUpdateListener();

            statement.Events += listener.Update;

            SupportCallEvent eventOne = SendEvent(epService.EPRuntime, 2000002601, "18", "123456789014795",
                                                  DateToLong("2005-09-26 13:02:53.200"),
                                                  DateToLong("2005-09-26 13:03:34.400"));
            SupportCallEvent eventTwo = SendEvent(epService.EPRuntime, 2000002607, "20", "123456789014795",
                                                  DateToLong("2005-09-26 13:03:17.300"),
                                                  DateToLong("2005-09-26 13:03:58.600"));

            EventBean theEvent = listener.AssertOneGetNewAndReset();

            Assert.AreSame(eventOne, theEvent.Get("A"));
            Assert.AreSame(eventTwo, theEvent.Get("B"));

            SupportCallEvent eventThree = SendEvent(epService.EPRuntime, 2000002610, "22", "123456789014795",
                                                    DateToLong("2005-09-26 13:03:31.300"),
                                                    DateToLong("2005-09-26 13:04:12.100"));

            Assert.AreEqual(1, listener.NewDataList.Count);
            Assert.AreEqual(2, listener.LastNewData.Length);
            theEvent = listener.LastNewData[0];
            Assert.AreSame(eventOne, theEvent.Get("A"));
            Assert.AreSame(eventThree, theEvent.Get("B"));
            theEvent = listener.LastNewData[1];
            Assert.AreSame(eventTwo, theEvent.Get("A"));
            Assert.AreSame(eventThree, theEvent.Get("B"));

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }