@Test public void testSecurityFilterNotAccept() throws Exception { TestSecurityNotificationListener securityNotificationListener = new TestSecurityNotificationListener(); muleContext.registerListener(securityNotificationListener); OutboundEndpoint endpoint = createOutboundEndpoint( null, new TestSecurityFilter(false), null, null, MessageExchangePattern.REQUEST_RESPONSE, null); testOutboundEvent = createTestOutboundEvent(); try { endpoint.process(testOutboundEvent); fail("Exception expected"); } catch (TestSecurityFilter.StaticMessageUnauthorisedException e) { testOutboundEvent .getFlowConstruct() .getExceptionListener() .handleException(e, testOutboundEvent); } assertNull(MyMessageDispatcherFactory.dispatcher); assertTrue(securityNotificationListener.latch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS)); assertEquals( SecurityNotification.SECURITY_AUTHENTICATION_FAILED, securityNotificationListener.securityNotification.getAction()); assertEquals( securityNotificationListener.securityNotification.getResourceIdentifier(), TestSecurityFilter.StaticMessageUnauthorisedException.class.getName()); }