@Test public void testPreHandleIncorrectHandler() throws Exception { boolean result = interceptor.preHandle(request, response, null); assertThat(result, is(true)); }
@Override public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } logger.trace("preHandle"); HandlerMethod handlerMethod = (HandlerMethod) handler; TransactionTokenInfo tokenInfo = tokenInfoStore.getTransactionTokenInfo( handlerMethod); TransactionToken receivedToken = INVALID_TOKEN; if (tokenInfo.needValidate()) { receivedToken = createReceivedToken(request); if (!validateToken(receivedToken, tokenStore, tokenInfo)) { processTransactionTokenError(receivedToken); } } if (tokenInfo.getTransactionTokenType() == TransactionTokenType.BEGIN) { String tokenStr = request.getParameter(TOKEN_REQUEST_PARAMETER); if (null != tokenStr) { removeToken(new TransactionToken(tokenStr)); } } TransactionTokenContextImpl tokenContext = new TransactionTokenContextImpl(tokenInfo, receivedToken); request.setAttribute(TOKEN_CONTEXT_REQUEST_ATTRIBUTE_NAME, tokenContext); return true; }
TransactionTokenInterceptor implements HandlerInterceptor { @Override public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } logger.trace("preHandle"); HandlerMethod handlerMethod = (HandlerMethod) handler; TransactionTokenInfo tokenInfo = tokenInfoStore.getTransactionTokenInfo( handlerMethod); TransactionToken receivedToken = INVALID_TOKEN; if (tokenInfo.needValidate()) { receivedToken = createReceivedToken(request); if (!validateToken(receivedToken, tokenStore, tokenInfo)) { processTransactionTokenError(receivedToken); } } if (tokenInfo.getTransactionTokenType() == TransactionTokenType.BEGIN) { String tokenStr = request.getParameter(TOKEN_REQUEST_PARAMETER); if (null != tokenStr) { removeToken(new TransactionToken(tokenStr)); } } TransactionTokenContextImpl tokenContext = new TransactionTokenContextImpl(tokenInfo, receivedToken); request.setAttribute(TOKEN_CONTEXT_REQUEST_ATTRIBUTE_NAME, tokenContext); return true; } }
TransactionTokenInterceptor implements HandlerInterceptor { @Override public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } logger.trace("preHandle"); HandlerMethod handlerMethod = (HandlerMethod) handler; TransactionTokenInfo tokenInfo = tokenInfoStore.getTransactionTokenInfo( handlerMethod); TransactionToken receivedToken = INVALID_TOKEN; if (tokenInfo.needValidate()) { receivedToken = createReceivedToken(request); if (!validateToken(receivedToken, tokenStore, tokenInfo)) { processTransactionTokenError(receivedToken); } } if (tokenInfo.getTransactionTokenType() == TransactionTokenType.BEGIN) { String tokenStr = request.getParameter(TOKEN_REQUEST_PARAMETER); if (null != tokenStr) { removeToken(new TransactionToken(tokenStr)); } } TransactionTokenContextImpl tokenContext = new TransactionTokenContextImpl(tokenInfo, receivedToken); request.setAttribute(TOKEN_CONTEXT_REQUEST_ATTRIBUTE_NAME, tokenContext); return true; } TransactionTokenInterceptor();  TransactionTokenInterceptor(int sizePerTokenName);  TransactionTokenInterceptor(TokenStringGenerator generator,
            TransactionTokenInfoStore tokenInfoStore,
            TransactionTokenStore tokenStore); }
TransactionTokenInterceptor implements HandlerInterceptor { @Override public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } logger.trace("preHandle"); HandlerMethod handlerMethod = (HandlerMethod) handler; TransactionTokenInfo tokenInfo = tokenInfoStore.getTransactionTokenInfo( handlerMethod); TransactionToken receivedToken = INVALID_TOKEN; if (tokenInfo.needValidate()) { receivedToken = createReceivedToken(request); if (!validateToken(receivedToken, tokenStore, tokenInfo)) { processTransactionTokenError(receivedToken); } } if (tokenInfo.getTransactionTokenType() == TransactionTokenType.BEGIN) { String tokenStr = request.getParameter(TOKEN_REQUEST_PARAMETER); if (null != tokenStr) { removeToken(new TransactionToken(tokenStr)); } } TransactionTokenContextImpl tokenContext = new TransactionTokenContextImpl(tokenInfo, receivedToken); request.setAttribute(TOKEN_CONTEXT_REQUEST_ATTRIBUTE_NAME, tokenContext); return true; } TransactionTokenInterceptor();  TransactionTokenInterceptor(int sizePerTokenName);  TransactionTokenInterceptor(TokenStringGenerator generator,
            TransactionTokenInfoStore tokenInfoStore,
            TransactionTokenStore tokenStore); @Override boolean preHandle(final HttpServletRequest request,
            final HttpServletResponse response, final Object handler); @Override void postHandle(final HttpServletRequest request,
            final HttpServletResponse response, final Object handler,
            final ModelAndView modelAndView); @Override void afterCompletion(final HttpServletRequest request,
            final HttpServletResponse response, final Object handler,
            final Exception ex); }
TransactionTokenInterceptor implements HandlerInterceptor { @Override public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } logger.trace("preHandle"); HandlerMethod handlerMethod = (HandlerMethod) handler; TransactionTokenInfo tokenInfo = tokenInfoStore.getTransactionTokenInfo( handlerMethod); TransactionToken receivedToken = INVALID_TOKEN; if (tokenInfo.needValidate()) { receivedToken = createReceivedToken(request); if (!validateToken(receivedToken, tokenStore, tokenInfo)) { processTransactionTokenError(receivedToken); } } if (tokenInfo.getTransactionTokenType() == TransactionTokenType.BEGIN) { String tokenStr = request.getParameter(TOKEN_REQUEST_PARAMETER); if (null != tokenStr) { removeToken(new TransactionToken(tokenStr)); } } TransactionTokenContextImpl tokenContext = new TransactionTokenContextImpl(tokenInfo, receivedToken); request.setAttribute(TOKEN_CONTEXT_REQUEST_ATTRIBUTE_NAME, tokenContext); return true; } TransactionTokenInterceptor();  TransactionTokenInterceptor(int sizePerTokenName);  TransactionTokenInterceptor(TokenStringGenerator generator,
            TransactionTokenInfoStore tokenInfoStore,
            TransactionTokenStore tokenStore); @Override boolean preHandle(final HttpServletRequest request,
            final HttpServletResponse response, final Object handler); @Override void postHandle(final HttpServletRequest request,
            final HttpServletResponse response, final Object handler,
            final ModelAndView modelAndView); @Override void afterCompletion(final HttpServletRequest request,
            final HttpServletResponse response, final Object handler,
            final Exception ex); static final String TOKEN_CONTEXT_REQUEST_ATTRIBUTE_NAME; static final String NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME; static final String TOKEN_REQUEST_PARAMETER; }