@Test
    public void buildProviderChain() {
        ConsumerConfig config = new ConsumerConfig();
        config.setBootstrap("test");
        ArrayList<Router> list = new ArrayList<Router>();
        list.add(new TestChainRouter1());
        list.add(new TestChainRouter2());
        list.add(new TestChainRouter3());
        list.add(new TestChainRouter4());
        list.add(new ExcludeRouter("-testChainRouter5"));
        config.setRouterRef(list);

        ConsumerBootstrap consumerBootstrap = Bootstraps.from(config);
        RouterChain chain = RouterChain.buildConsumerChain(consumerBootstrap);

        // build test data
        SofaRequest request = new SofaRequest();
        request.setMethodArgs(new String[] { "xxx" });
        request.setInvokeType("sync");
        List<ProviderInfo> providerInfos = new ArrayList<ProviderInfo>();
        ProviderInfo providerInfo = new ProviderInfo();
        providerInfo.setHost("127.0.0.1");
        providerInfo.setPort(12200);
        providerInfos.add(providerInfo);

        chain.route(request, providerInfos);
        Assert.assertEquals("r0>r7>r2>r4",
            RpcInternalContext.getContext().getAttachment(RpcConstants.INTERNAL_KEY_ROUTER_RECORD));
    }
@author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a>
core/api/src/test/java/com/alipay/sofa/rpc/client/RouterChainTest.java