Java 类javax.enterprise.context.NonexistentConversationException 实例源码

项目:oscm    文件:NonexistentConversationFilterTest.java   
@Test
public void testDoFilter() throws Exception {
    // given
    FilterChain chain = mock(FilterChain.class);
    HttpServletResponse res = mock(HttpServletResponse.class);
    HttpServletRequest req = mock(HttpServletRequest.class);
    when(req.getContextPath()).thenReturn("");
    when(req.getRequestURI()).thenReturn(
            "/marketplace/subscriptions/upgrade/confirmUpgrade.jsf");

    ServletException exc = new ServletException("msg",
            mock(NonexistentConversationException.class));
    doThrow(exc).when(chain).doFilter(req, res);
    // when
    try {
        classUnderTests.doFilter(req, res, chain);
    } catch (Exception e) {
        fail();
    }

    // then
    verify(res).sendRedirect("/marketplace/account/subscriptionDetails.jsf");
}
项目:oscm    文件:NonexistentConversationFilter.java   
@Override
public void doFilter(ServletRequest servletRequest,
           ServletResponse servletResponse, FilterChain filterChain)
           throws IOException, ServletException {
       HttpServletRequest request = (HttpServletRequest) servletRequest;
       HttpServletResponse response = (HttpServletResponse) servletResponse;

       try {
           filterChain.doFilter(servletRequest, servletResponse);
       } catch (Exception t) {
           Throwable exc = t;
           while(exc != null && !(exc instanceof NonexistentConversationException)) {
               exc = exc.getCause();
           }
           if (exc != null) {
               //Refresh from subscription creation and upgrade
               String requestURI = request.getRequestURI();
               if (requestURI.contains("/marketplace/subscriptions/upgrade/confirmUpgrade.jsf") ||
                       requestURI.contains("/marketplace/subscriptions/creation/confirmAdd.jsf")){
                   sendRedirectStatic(request, response,
                           "/marketplace/account/subscriptionDetails.jsf");
               } else {
                   request.setAttribute(Constants.REQ_ATTR_ERROR_KEY,
                           SubscriptionDetailsCtrlConstants.ERROR_SUBSCRIPTION_REPEATSTEPS);
                   sendRedirectStatic(request, response, "/marketplace/index.jsf");
               }
           } else {
            throw t;
        }
       }
   }
项目:parco    文件:ExceptionHandlers.java   
public void onNonexistentConversation(@Handles CaughtException<NonexistentConversationException> evt)
  {
      log.debug("--------- NonexistentConversationException! ------------\n" 
            + evt.getException().getMessage(), evt.getException());

      evt.handled();

      try {
    viewChain.goTo( "/private/home.xhtml" );
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
  }
项目:oxTrust    文件:GlobalExceptionHandler.java   
private boolean isConversationException(Throwable t) {
    return ExceptionUtils.getRootCause(t) instanceof NonexistentConversationException;
}