use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project deltaspike by apache.
the class DefaultSecurityStrategy method handleAccessDeniedException.
/**
* <p>Fires a {@link org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent} for the given
* {@link org.apache.deltaspike.security.api.authorization.AccessDeniedException}.</p>
* It also allows to change the default handling.
*
* @param originalException exception thrown by an authorizer
* @return the original exception if the default behavior was changed and the exception is unhandled
*/
protected RuntimeException handleAccessDeniedException(AccessDeniedException originalException) {
ExceptionToCatchEvent exceptionToCatchEvent = new ExceptionToCatchEvent(originalException);
this.beanManager.fireEvent(exceptionToCatchEvent);
return originalException;
}
use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project deltaspike by apache.
the class BreadthFirstAbortControlTest method assertNoOtherHandlersCalledAfterAbort.
@Test
public void assertNoOtherHandlersCalledAfterAbort() {
bm.fireEvent(new ExceptionToCatchEvent(new NullPointerException()));
assertTrue(abortingBreadthFirstHandler.isAbortCalled());
assertFalse(abortingBreadthFirstHandler.isProceedCalled());
}
use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project deltaspike by apache.
the class DepthAbortControlTest method assertNoOtherHandlersCalledAfterAbort.
@Test
public void assertNoOtherHandlersCalledAfterAbort() {
bm.fireEvent(new ExceptionToCatchEvent(new NullPointerException()));
assertTrue(abortingDepthHandler.isAbortCalled());
assertFalse(abortingDepthHandler.isProceedCalled());
}
use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project deltaspike by apache.
the class HandledExceptionHandlerTest method assertNoHandlersAfterHandledAreCalled.
@Test
public void assertNoHandlersAfterHandledAreCalled() {
final ExceptionToCatchEvent entryEvent = new ExceptionToCatchEvent(new Exception(new NullPointerException()));
bm.fireEvent(entryEvent);
assertTrue(exceptionHandledHandler.isNpeDescCalled());
assertFalse(exceptionHandledHandler.isExAscCalled());
assertTrue(entryEvent.isHandled());
}
use of org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent in project deltaspike by apache.
the class ProceedCauseHandlerTest method assertCorrectNumberOfHandlerCallsForProceedCause.
@Test
public void assertCorrectNumberOfHandlerCallsForProceedCause() {
bm.fireEvent(new ExceptionToCatchEvent(new Exception(new IllegalArgumentException(new NullPointerException()))));
assertEquals(0, proceedCauseHandler.getBreadthFirstNpeLowerPrecedenceCalled());
assertEquals(1, proceedCauseHandler.getBreadthFirstNpeCalled());
assertEquals(0, proceedCauseHandler.getDepthFirstNpeHigherPrecedenceCalled());
assertEquals(0, proceedCauseHandler.getDepthFirstNpeCalled());
}
Aggregations