public bool? Call()
        {
            try {
                var listener = new SupportMTUpdateListener();
                targetStatement.AddListener(listener);

                for (var loop = 0; loop < numRepeats; loop++) {
                    var generalKey = "Key";
                    var valueExpected = threadNum * 1000000000 + loop + 1;

                    // send insert event with string-value NOT specific to thread
                    SendEvent(generalKey, valueExpected);

                    // send subquery trigger event
                    runtime.EventService.SendEventBean(new SupportBean(generalKey, -1), "SupportBean");

                    // assert trigger event received
                    var events = listener.GetNewDataListCopy();
                    var found = false;
                    foreach (var arr in events) {
                        foreach (var item in arr) {
                            var value = item.Get("val").UnwrapIntoList<int>();
                            foreach (var valueReceived in value) {
                                if (valueReceived == valueExpected) {
                                    found = true;
                                    break;
                                }
                            }

                            if (found) {
                                break;
                            }
                        }

                        if (found) {
                            break;
                        }
                    }

                    listener.Reset();

                    if (!found) {
                        return false;
                    }

                    // send delete event with string-value specific to thread
                    SendEvent(generalKey, valueExpected);
                }
            }
            catch (Exception ex) {
                log.Error("Error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return false;
            }

            return true;
        }
        public bool Call()
        {
            try
            {
                SupportMTUpdateListener listener = new SupportMTUpdateListener();
                _targetStatement.Events += listener.Update;

                for (int loop = 0; loop < _numRepeats; loop++)
                {
                    String threadKey     = "K" + loop + "_" + _threadNum;
                    int    valueExpected = _threadNum * 1000000000 + loop + 1;

                    // send insert event with string-value specific to thread
                    SendEvent(threadKey, valueExpected);

                    // send subquery trigger event with string-value specific to thread
                    _engine.EPRuntime.SendEvent(new SupportBean(threadKey, -1));

                    // assert trigger event received
                    IList <EventBean[]> events = listener.GetNewDataListCopy();
                    bool found = false;
                    foreach (EventBean[] arr in events)
                    {
                        foreach (EventBean item in arr)
                        {
                            var value = (int?)item.Get("val");
                            if (value == valueExpected)
                            {
                                found = true;
                                break;
                            }
                        }
                        if (found)
                        {
                            break;
                        }
                    }
                    listener.Reset();

                    if (!found)
                    {
                        return(false);
                    }

                    // send delete event with string-value specific to thread
                    SendEvent(threadKey, 0);
                }
            }
            catch (Exception ex)
            {
                Log.Fatal("Error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        public bool? Call()
        {
            try {
                var listener = new SupportMTUpdateListener();
                targetStatement.AddListener(listener);

                for (var loop = 0; loop < numRepeats; loop++) {
                    var threadKey = "K" + loop + "_" + threadNum;
                    var valueExpected = threadNum * 1000000000 + loop + 1;

                    // send insert event with string-value specific to thread
                    SendEvent(threadKey, valueExpected);

                    // send subquery trigger event with string-value specific to thread
                    runtime.EventService.SendEventBean(new SupportBean(threadKey, -1), "SupportBean");

                    // assert trigger event received
                    var events = listener.GetNewDataListCopy();
                    var found = false;
                    foreach (var arr in events) {
                        found = arr
                            .Select(item => item.Get("val").AsInt32())
                            .Any(value => value == valueExpected);
                        if (found) {
                            break;
                        }
                    }

                    listener.Reset();

                    if (!found) {
                        return false;
                    }

                    // send delete event with string-value specific to thread
                    SendEvent(threadKey, 0);
                }
            }
            catch (Exception ex) {
                log.Error("Error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return false;
            }

            return true;
        }
Ejemplo n.º 4
0
        private void FindEvent(SupportMTUpdateListener listener, int loop, Object theEvent)
        {
            var message = "Failed in loop " + loop + " threads " + Thread.CurrentThread;

            Assert.IsTrue(listener.IsInvoked(), message);
            var eventBeans = listener.GetNewDataListCopy();
            var found      = false;

            foreach (EventBean[] events in eventBeans)
            {
                Assert.AreEqual(1, events.Length, message);
                if (events[0].Underlying == theEvent)
                {
                    found = true;
                }
            }
            Assert.IsTrue(found, message);
            listener.Reset();
        }