public static FilterChain buildProviderChain(ProviderConfig<?> providerConfig, FilterInvoker lastFilter) {
        return new FilterChain(selectActualFilters(providerConfig, PROVIDER_AUTO_ACTIVES), lastFilter, providerConfig);
    }
@Test
    public void buildProviderChain() {

        ProviderConfig providerConfig = new ProviderConfig();
        providerConfig.setInterfaceId(Serializer.class.getName());

        ConsumerConfig consumerConfig = new ConsumerConfig();
        ArrayList<Filter> list = new ArrayList<Filter>();
        list.add(new TestChainFilter1());
        list.add(new TestChainFilter2());
        list.add(new TestChainFilter3());
        list.add(new TestChainFilter4());
        list.add(new ExcludeFilter("-testChainFilter5"));
        consumerConfig.setFilterRef(list);
        consumerConfig.setInterfaceId(Serializer.class.getName());

        // mock provider chain (0,6,7）
        FilterChain providerChain = FilterChain.buildProviderChain(providerConfig,
            new TestProviderFilterInvoker(providerConfig));
        // mock consumer chain（0,7,2,4)
        FilterChain consumerChain = FilterChain.buildConsumerChain(consumerConfig,
            new TestConsumerFilterInvoker(consumerConfig, providerChain));
        Assert.assertNotNull(consumerChain.getChain());

        SofaRequest request = new SofaRequest();
        request.setMethodArgs(new String[] { "xxx" });
        request.setInvokeType("sync");
        String result = (String) consumerChain.invoke(request).getAppResponse();
        Assert.assertEquals("xxx_q0_q7_q2_q4_q0_q6_q7_s7_s6_s0_s4_s2_s7_s0", result);

        request = new SofaRequest();
        request.setMethodArgs(new String[] { "xxx" });
        request.setInvokeType("callback");
        SofaResponse response = consumerChain.invoke(request);
        consumerChain.onAsyncResponse(consumerConfig, request, response, null);
        result = (String) response.getAppResponse();
        Assert.assertEquals("xxx_q0_q7_q2_q4_q0_q6_q7_a4_a2_a7_a0", result);
    }