public void ShouldApplyDefaultExceptionHandlerToExistingEventProcessors()
        {
            var eventHandled     = new AtomicReference <Exception>();
            var 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);
        }
        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);
        }
Example #3
0
        public void ShouldSupportSpecifyingADefaultExceptionHandlerForEventProcessors()
        {
            var eventHandled = new AtomicReference <Exception>();
            IExceptionHandler <object> exceptionHandler = new StubExceptionHandler(eventHandled);
            var testException = new Exception();
            var handler       = new ExceptionThrowingEventHandler(testException);

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

            PublishEvent();

            var actualException = WaitFor(eventHandled);

            Assert.AreSame(testException, actualException);
        }
Example #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);
        }