WebSocketNativeHandshakeHandler extends WebSocketHandlerAdapter { @Override public void processAuthorize(WebSocketChannel channel, String authorizeToken) { sendHandshakePayload(channel, authorizeToken); } WebSocketNativeHandshakeHandler(); @Override void processConnect(WebSocketChannel channel, WSURI uri, String[] protocols); @Override void processAuthorize(WebSocketChannel channel, String authorizeToken); @Override void setNextHandler(final WebSocketHandler handler);  }
@Test public void testProcessAuthorize() throws URISyntaxException, Exception { Mockery context = new Mockery(); final WebSocketHandler nextHandler = context.mock(WebSocketHandler.class); final WebSocketHandlerListener listener = context.mock(WebSocketHandlerListener.class); context.checking(new Expectations() { { oneOf(nextHandler).setListener(with(aNonNull(WebSocketHandlerListener.class))); will(saveParameter("listener", 0)); oneOf(nextHandler).processBinaryMessage(with(aNonNull(WebSocketChannel.class)),with(aNonNull(WrappedByteBuffer.class))); } }); WSURI uri = new WSURI("ws: WebSocketChannel channel = createNativeChannel(uri); WebSocketNativeHandshakeHandler handler = new WebSocketNativeHandshakeHandler(); handler.setNextHandler(nextHandler); handler.setListener(listener); handler.processAuthorize(channel, "Application Basic relam"); context.assertIsSatisfied(); }