Esempio n. 1
0
        public override void Run(EPServiceProvider epService)
        {
            string epl = "@Name('ABCName') select Myinvalidagg() from SupportBean";

            epService.EPAdministrator.CreateEPL(epl);

            IList <ExceptionHandlerFactoryContext> contexts = SupportExceptionHandlerFactory.FactoryContexts;

            Assert.AreEqual(2, contexts.Count);
            Assert.AreEqual(epService.URI, contexts[0].EngineURI);
            Assert.AreEqual(epService.URI, contexts[1].EngineURI);

            SupportExceptionHandlerFactory.SupportExceptionHandler handlerOne = SupportExceptionHandlerFactory.Handlers[0];
            SupportExceptionHandlerFactory.SupportExceptionHandler handlerTwo = SupportExceptionHandlerFactory.Handlers[1];
            epService.EPRuntime.SendEvent(new SupportBean());

            Assert.AreEqual(1, handlerOne.Contexts.Count);
            Assert.AreEqual(1, handlerTwo.Contexts.Count);
            ExceptionHandlerContext ehc = handlerOne.Contexts[0];

            Assert.AreEqual(epService.URI, ehc.EngineURI);
            Assert.AreEqual(epl, ehc.Epl);
            Assert.AreEqual("ABCName", ehc.StatementName);
            Assert.AreEqual("Sample exception", ehc.Exception.Message);
            Assert.IsNotNull(ehc.CurrentEvent);
        }
        private void RunAssertionExceptionHandler(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(
                "throwException", GetType(), "ThrowException", ValueCacheEnum.DISABLED, FilterOptimizableEnum.ENABLED, true);
            string epl = "@Name('ABCName') select * from SupportBean(ThrowException())";

            epService.EPAdministrator.CreateEPL(epl);

            SupportExceptionHandlerFactory.SupportExceptionHandler handler = SupportExceptionHandlerFactory.Handlers[SupportExceptionHandlerFactory.Handlers.Count - 1];
            epService.EPRuntime.SendEvent(new SupportBean());

            int count = 0;

            while (true)
            {
                if (handler.InboundPoolContexts.Count == 1)
                {
                    break;
                }
                if (count++ < 100)
                {
                    Thread.Sleep(100);
                }
            }

            if (count >= 100)
            {
                Assert.Fail();
            }
        }
Esempio n. 3
0
        public void TestHandler()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            // add same factory twice
            config.EngineDefaults.ExceptionHandling.HandlerFactories.Clear();
            config.EngineDefaults.ExceptionHandling.AddClass(typeof(SupportExceptionHandlerFactory));
            config.EngineDefaults.ExceptionHandling.AddClass(typeof(SupportExceptionHandlerFactory));
            config.AddEventType <SupportBean>();
            config.AddPlugInAggregationFunctionFactory("myinvalidagg", typeof(InvalidAggTestFactory).FullName);

            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            SupportExceptionHandlerFactory.FactoryContexts.Clear();
            SupportExceptionHandlerFactory.Handlers.Clear();
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            const string epl = "@Name('ABCName') select Myinvalidagg() from SupportBean";

            _epService.EPAdministrator.CreateEPL(epl);

            IList <ExceptionHandlerFactoryContext> contexts = SupportExceptionHandlerFactory.FactoryContexts;

            Assert.AreEqual(2, contexts.Count);
            Assert.AreEqual(_epService.URI, contexts[0].EngineURI);
            Assert.AreEqual(_epService.URI, contexts[1].EngineURI);

            SupportExceptionHandlerFactory.SupportExceptionHandler handlerOne = SupportExceptionHandlerFactory.Handlers[0];
            SupportExceptionHandlerFactory.SupportExceptionHandler handlerTwo = SupportExceptionHandlerFactory.Handlers[1];
            _epService.EPRuntime.SendEvent(new SupportBean());

            Assert.AreEqual(1, handlerOne.Contexts.Count);
            Assert.AreEqual(1, handlerTwo.Contexts.Count);
            ExceptionHandlerContext ehc = handlerOne.Contexts[0];

            Assert.AreEqual(_epService.URI, ehc.EngineURI);
            Assert.AreEqual(epl, ehc.Epl);
            Assert.AreEqual("ABCName", ehc.StatementName);
            Assert.AreEqual("Sample exception", ehc.Exception.Message);
            Assert.NotNull(ehc.CurrentEvent);

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