@Test(expected = SofaRouteException.class)
    public void testRpcDirectInvokeFromContextNotAllowed() {

        boolean prev = RpcConfigs.getBooleanValue(RpcOptions.RPC_CREATE_CONN_WHEN_ABSENT);

        // disable create connection from context
        RpcConfigs.putValue(RpcOptions.RPC_CREATE_CONN_WHEN_ABSENT, false);

        try {
            ServerConfig serverConfig = new ServerConfig()
                .setProtocol("bolt")
                .setHost("0.0.0.0")
                .setPort(13900);

            ProviderConfig<HelloService> provider = new ProviderConfig();
            provider.setInterfaceId(HelloService.class.getName())
                .setRef(new HelloServiceImpl("x-demo-invoke"))
                .setApplication(new ApplicationConfig().setAppName("x-test-server"))
                .setProxy("javassist")
                .setSerialization("hessian2")
                .setServer(serverConfig)
                .setTimeout(3000);

            provider.export();

            ConsumerConfig<HelloService> consumer = new ConsumerConfig();
            consumer.setInterfaceId(HelloService.class.getName())
                .setApplication(new ApplicationConfig().setAppName("x-test-client"))
                .setProxy("javassist");

            HelloService proxy = consumer.refer();

            RpcInvokeContext.getContext().setTargetURL("127.0.0.1:13900");
            proxy.sayHello("x-demo-invoke", 1);

            provider.unExport();
            consumer.unRefer();
        } finally {
            RpcConfigs.putValue(RpcOptions.RPC_CREATE_CONN_WHEN_ABSENT, prev);
        }
    }
@author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a>
test/test-integration/src/test/java/com/alipay/sofa/rpc/test/client/FailoverClusterTest.java