Ejemplo n.º 1
0
        private void RunAssertionStopDestroy(EPServiceProvider epService)
        {
            SendTimer(epService, 5000);
            string      text = "select * from " + typeof(SupportBean).FullName;
            EPStatement stmt = epService.EPAdministrator.CreateEPL(text, "s1");

            Assert.AreEqual(false, stmt.IsDisposed);
            Assert.AreEqual(false, stmt.IsStopped);
            Assert.AreEqual(true, stmt.IsStarted);
            Assert.AreEqual(5000L, stmt.TimeLastStateChange);
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;
            SendEvent(epService);
            listener.AssertOneGetNewAndReset();

            SendTimer(epService, 6000);
            stmt.Stop();
            Assert.AreEqual(6000L, stmt.TimeLastStateChange);
            Assert.AreEqual(false, stmt.IsDisposed);
            Assert.AreEqual(true, stmt.IsStopped);
            Assert.AreEqual(false, stmt.IsStarted);

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

            SendTimer(epService, 7000);
            stmt.Dispose();
            Assert.AreEqual(true, stmt.IsDisposed);
            Assert.AreEqual(false, stmt.IsStopped);
            Assert.AreEqual(false, stmt.IsStarted);
            Assert.AreEqual(7000L, stmt.TimeLastStateChange);
            SendEvent(epService);
            Assert.IsFalse(listener.IsInvoked);

            AssertStmtDestroyed(epService, stmt, text);

            // test fire-stop service
            EPStatementSPI spiOne      = (EPStatementSPI)epService.EPAdministrator.CreateEPL("select * from System.Object");
            var            callbackOne = new StopCallbackImpl();

            spiOne.StatementContext.StatementStopService.StatementStopped += callbackOne.StatementStopped;
            spiOne.Dispose();
            Assert.IsTrue(callbackOne.IsStopped);

            EPStatementSPI spiTwo      = (EPStatementSPI)epService.EPAdministrator.CreateEPL("select * from System.Object");
            var            callbackTwo = new StopCallbackImpl();

            spiTwo.StatementContext.StatementStopService.StatementStopped += callbackTwo.StatementStopped;
            spiTwo.Stop();
            Assert.IsTrue(callbackTwo.IsStopped);

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 2
0
        public void TestStopDestroy()
        {
            SendTimer(5000);
            String      text = "select * from " + typeof(SupportBean).FullName;
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(text, "s1");

            Assert.AreEqual(false, stmt.IsDisposed);
            Assert.AreEqual(false, stmt.IsStopped);
            Assert.AreEqual(true, stmt.IsStarted);
            Assert.AreEqual(5000l, stmt.TimeLastStateChange);
            stmt.Events += _listener.Update;
            SendEvent();
            _listener.AssertOneGetNewAndReset();

            SendTimer(6000);
            stmt.Stop();
            Assert.AreEqual(6000l, stmt.TimeLastStateChange);
            Assert.AreEqual(false, stmt.IsDisposed);
            Assert.AreEqual(true, stmt.IsStopped);
            Assert.AreEqual(false, stmt.IsStarted);

            SendEvent();
            Assert.IsFalse(_listener.IsInvoked);

            SendTimer(7000);
            stmt.Dispose();
            Assert.AreEqual(true, stmt.IsDisposed);
            Assert.AreEqual(false, stmt.IsStopped);
            Assert.AreEqual(false, stmt.IsStarted);
            Assert.AreEqual(7000l, stmt.TimeLastStateChange);
            SendEvent();
            Assert.IsFalse(_listener.IsInvoked);

            AssertStmtDestroyed(stmt, text);

            // test fire-stop service
            EPStatementSPI   spiOne      = (EPStatementSPI)_epService.EPAdministrator.CreateEPL("select * from System.Object");
            StopCallbackImpl callbackOne = new StopCallbackImpl();

            spiOne.StatementContext.StatementStopService.StatementStopped += callbackOne.StatementStopped;
            spiOne.Dispose();
            Assert.IsTrue(callbackOne.IsStopped);

            EPStatementSPI   spiTwo      = (EPStatementSPI)_epService.EPAdministrator.CreateEPL("select * from System.Object");
            StopCallbackImpl callbackTwo = new StopCallbackImpl();

            spiTwo.StatementContext.StatementStopService.StatementStopped += callbackTwo.StatementStopped;
            spiTwo.Stop();
            Assert.IsTrue(callbackTwo.IsStopped);
        }