Search in sources :

Example 1 with ExceptionToCatchEvent

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;
}
Also used : ExceptionToCatchEvent(org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent)

Example 2 with ExceptionToCatchEvent

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());
}
Also used : ExceptionToCatchEvent(org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent) Test(org.junit.Test)

Example 3 with ExceptionToCatchEvent

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());
}
Also used : ExceptionToCatchEvent(org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent) Test(org.junit.Test)

Example 4 with ExceptionToCatchEvent

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());
}
Also used : ExceptionToCatchEvent(org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent) Test(org.junit.Test)

Example 5 with ExceptionToCatchEvent

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());
}
Also used : ExceptionToCatchEvent(org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent) Test(org.junit.Test)

Aggregations

ExceptionToCatchEvent (org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent)17 Test (org.junit.Test)12 FacesContext (javax.faces.context.FacesContext)2 ExceptionQueuedEvent (javax.faces.event.ExceptionQueuedEvent)2 AccessDeniedException (org.apache.deltaspike.security.api.authorization.AccessDeniedException)2 ErrorViewAwareAccessDeniedException (org.apache.deltaspike.security.api.authorization.ErrorViewAwareAccessDeniedException)2 SQLException (java.sql.SQLException)1