@Override
    public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
        String token = invoker.getUrl().getParameter(TOKEN_KEY);
        if (ConfigUtils.isNotEmpty(token)) {
            Class<?> serviceType = invoker.getInterface();
            String remoteToken = (String) inv.getObjectAttachmentWithoutConvert(TOKEN_KEY);
            if (!token.equals(remoteToken)) {
                throw new RpcException("Invalid token! Forbid invoke remote service " + serviceType + " method "
                        + RpcUtils.getMethodName(inv) + "() from consumer "
                        + RpcContext.getServiceContext().getRemoteHost() + " to provider "
                        + RpcContext.getServiceContext().getLocalHost()
                        + ", consumer incorrect token is " + remoteToken);
            }
        }
        return invoker.invoke(inv);
    }
@Test
    void testInvokeWithWrongToken() throws Exception {
        Assertions.assertThrows(RpcException.class, () -> {
            String token = "token";

            Invoker invoker = Mockito.mock(Invoker.class);
            URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1&token=" + token);
            when(invoker.getUrl()).thenReturn(url);
            when(invoker.invoke(any(Invocation.class))).thenReturn(new AppResponse("result"));

            Map<String, Object> attachments = new HashMap<>();
            attachments.put(TOKEN_KEY, "wrongToken");
            Invocation invocation = Mockito.mock(Invocation.class);
            when(invocation.getObjectAttachments()).thenReturn(attachments);

            tokenFilter.invoke(invoker, invocation);
        });
    }