示例#1
0
        public void ShouldBeAbleToOverrideTheExceptionHandlerForAEventProcessor()
        {
            var testException = new Exception();
            var eventHandler  = new ExceptionThrowingEventHandler(testException);

            _disruptor.HandleEventsWith(eventHandler);

            var reference        = new AtomicReference <Exception>();
            var exceptionHandler = new StubExceptionHandler(reference);

            _disruptor.HandleExceptionsFor(eventHandler).With(exceptionHandler);

            PublishEvent();

            WaitFor(reference);
        }
示例#2
0
        public void ShouldApplyDefaultExceptionHandlerToExistingEventProcessors()
        {
            var eventHandled = new AtomicReference <Exception>();
            IExceptionHandler <object> exceptionHandler = new StubExceptionHandler(eventHandled);
            var testException = new Exception();
            var handler       = new ExceptionThrowingEventHandler(testException);

            _disruptor.HandleEventsWith(handler);
            _disruptor.SetDefaultExceptionHandler(exceptionHandler);

            PublishEvent();

            var actualException = WaitFor(eventHandled);

            Assert.AreSame(testException, actualException);
        }
示例#3
0
        public void ShouldSupportSpecifyingAExceptionHandlerForEventProcessors()
        {
            var eventHandled = new AtomicReference <Exception>();
            IExceptionHandler <object> exceptionHandler = new StubExceptionHandler(eventHandled);
            var testException = new Exception();
            var handler       = new ExceptionThrowingEventHandler(testException);

            _disruptor.HandleExceptionsWith(exceptionHandler);
            _disruptor.HandleEventsWith(handler);

            PublishEvent();

            var actualException = WaitFor(eventHandled);

            Assert.AreSame(testException, actualException);
        }
示例#4
0
        public void ShouldOnlyApplyExceptionsHandlersSpecifiedViaHandleExceptionsWithOnNewEventProcessors()
        {
            var eventHandled = new AtomicReference <Exception>();
            IExceptionHandler <object> exceptionHandler = new StubExceptionHandler(eventHandled);
            var testException = new Exception();
            var handler       = new ExceptionThrowingEventHandler(testException);

            _disruptor.HandleExceptionsWith(exceptionHandler);
            _disruptor.HandleEventsWith(handler);
            _disruptor.HandleExceptionsWith(new FatalExceptionHandler());

            PublishEvent();

            var actualException = WaitFor(eventHandled);

            Assert.AreSame(testException, actualException);
        }