HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, handler); HandshakeFailureException failure = null; if (!chain.applyBeforeHandshake(request, response, attributes)) { return; chain.applyAfterHandshake(request, response, null); chain.applyAfterHandshake(request, response, failure); throw failure;
@Test public void applyAfterHandshakeOnly() { HandshakeInterceptorChain chain = new HandshakeInterceptorChain(interceptors, wsHandler); chain.applyAfterHandshake(request, response, null); verifyNoMoreInteractions(i1, i2, i3); }
@Test public void applyBeforeHandshakeWithFalseReturnValue() throws Exception { given(i1.beforeHandshake(request, response, wsHandler, attributes)).willReturn(true); given(i2.beforeHandshake(request, response, wsHandler, attributes)).willReturn(false); HandshakeInterceptorChain chain = new HandshakeInterceptorChain(interceptors, wsHandler); chain.applyBeforeHandshake(request, response, attributes); verify(i1).beforeHandshake(request, response, wsHandler, attributes); verify(i1).afterHandshake(request, response, wsHandler, null); verify(i2).beforeHandshake(request, response, wsHandler, attributes); verifyNoMoreInteractions(i1, i2, i3); }
public boolean applyBeforeHandshake(ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> attributes) throws Exception { for (int i = 0; i < this.interceptors.size(); i++) { HandshakeInterceptor interceptor = this.interceptors.get(i); if (!interceptor.beforeHandshake(request, response, this.wsHandler, attributes)) { if (logger.isDebugEnabled()) { logger.debug(interceptor + " returns false from beforeHandshake - precluding handshake"); } applyAfterHandshake(request, response, null); return false; } this.interceptorIndex = i; } return true; }
@Test public void success() throws Exception { given(i1.beforeHandshake(request, response, wsHandler, attributes)).willReturn(true); given(i2.beforeHandshake(request, response, wsHandler, attributes)).willReturn(true); given(i3.beforeHandshake(request, response, wsHandler, attributes)).willReturn(true); HandshakeInterceptorChain chain = new HandshakeInterceptorChain(interceptors, wsHandler); chain.applyBeforeHandshake(request, response, attributes); verify(i1).beforeHandshake(request, response, wsHandler, attributes); verify(i2).beforeHandshake(request, response, wsHandler, attributes); verify(i3).beforeHandshake(request, response, wsHandler, attributes); verifyNoMoreInteractions(i1, i2, i3); }
public boolean applyBeforeHandshake(ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> attributes) throws Exception { for (int i = 0; i < this.interceptors.size(); i++) { HandshakeInterceptor interceptor = this.interceptors.get(i); if (!interceptor.beforeHandshake(request, response, this.wsHandler, attributes)) { if (logger.isDebugEnabled()) { logger.debug(interceptor + " returns false from beforeHandshake - precluding handshake"); } applyAfterHandshake(request, response, null); return false; } this.interceptorIndex = i; } return true; }
ServerHttpResponse response = new ServletServerHttpResponse(servletResponse); HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, this.wsHandler); HandshakeFailureException failure = null; if (!chain.applyBeforeHandshake(request, response, attributes)) { return; chain.applyAfterHandshake(request, response, null); response.close(); chain.applyAfterHandshake(request, response, failure); throw failure;
public boolean applyBeforeHandshake(ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> attributes) throws Exception { for (int i = 0; i < this.interceptors.size(); i++) { HandshakeInterceptor interceptor = this.interceptors.get(i); if (!interceptor.beforeHandshake(request, response, this.wsHandler, attributes)) { if (logger.isDebugEnabled()) { logger.debug(interceptor + " returns false from beforeHandshake - precluding handshake"); } applyAfterHandshake(request, response, null); return false; } this.interceptorIndex = i; } return true; }
HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, handler); if (transportHandler instanceof SockJsSessionFactory) { Map<String, Object> attributes = new HashMap<>(); if (!chain.applyBeforeHandshake(request, response, attributes)) { return; chain.applyAfterHandshake(request, response, null); chain.applyAfterHandshake(request, response, failure); throw failure;
HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, handler); HandshakeFailureException failure = null; if (!chain.applyBeforeHandshake(request, response, attributes)) { return; chain.applyAfterHandshake(request, response, null); chain.applyAfterHandshake(request, response, failure); throw failure;
HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, handler); HandshakeFailureException failure = null; if (!chain.applyBeforeHandshake(request, response, attributes)) { return; chain.applyAfterHandshake(request, response, null); chain.applyAfterHandshake(request, response, failure); throw failure;
ServerHttpResponse response = new ServletServerHttpResponse(servletResponse); HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, this.wsHandler); HandshakeFailureException failure = null; if (!chain.applyBeforeHandshake(request, response, attributes)) { return; chain.applyAfterHandshake(request, response, null); response.close(); chain.applyAfterHandshake(request, response, failure); throw failure;
ServerHttpResponse response = new ServletServerHttpResponse(servletResponse); HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, this.wsHandler); HandshakeFailureException failure = null; if (!chain.applyBeforeHandshake(request, response, attributes)) { return; chain.applyAfterHandshake(request, response, null); response.close(); chain.applyAfterHandshake(request, response, failure); throw failure;
HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, handler); if (transportHandler instanceof SockJsSessionFactory) { Map<String, Object> attributes = new HashMap<>(); if (!chain.applyBeforeHandshake(request, response, attributes)) { return; chain.applyAfterHandshake(request, response, null); chain.applyAfterHandshake(request, response, failure); throw failure;
HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, handler); if (transportHandler instanceof SockJsSessionFactory) { Map<String, Object> attributes = new HashMap<>(); if (!chain.applyBeforeHandshake(request, response, attributes)) { return; chain.applyAfterHandshake(request, response, null); chain.applyAfterHandshake(request, response, failure); throw failure;