@Test
    public void callbackTestForInvalidEventWithExceptionHandler() throws Exception {
        log.info("callback test with exception handler");
        SiddhiAppRuntime siddhiAppRuntime = createTestExecutionRuntime();
        InputHandler inputHandler = siddhiAppRuntime.getInputHandler("StockStream");
        siddhiAppRuntime.handleExceptionWith(new ExceptionHandler<Object>() {
            @Override
            public void handleEventException(Throwable throwable, long l, Object o) {
                failedCount.incrementAndGet();
                failedCaught = true;
                log.info(o + ": properly handle event exception for bad event [sequence: " + l + ", failed: " +
                        failedCount + "]", throwable);
            }

            @Override
            public void handleOnStartException(Throwable throwable) {
                failedCount.incrementAndGet();
                failedCaught = true;
            }

            @Override
            public void handleOnShutdownException(Throwable throwable) {
                log.info("Properly handle shutdown exception", throwable);
                failedCount.incrementAndGet();
                failedCaught = true;
            }
        });

        siddhiAppRuntime.start();
        sendTestInvalidEvents(inputHandler);
        Thread.sleep(3000);
        // No following events can be processed correctly
        AssertJUnit.assertTrue("Should properly process all the 4 valid events", eventArrived);
        AssertJUnit.assertEquals("Should properly process all the 4 valid events", 4, count.get());
        AssertJUnit.assertFalse("Exception is properly handled thrown by 2 invalid events", failedCaught);
        AssertJUnit.assertEquals("Exception is properly handled thrown by 2 invalid events", 0, failedCount.get());
        siddhiAppRuntime.shutdown();
    }
Send 6 test events (2 valid -> 2 invalid -> 2 valid)

@param inputHandler input handler
@throws Exception
modules/siddhi-core/src/test/java/io/siddhi/core/stream/ExceptionHandlerTestCase.java