@Test
    public void shouldEndChainImmediatelyWhenSkipCalled() {
        IPolicy skipPolicy = spy(new IPolicy() {

            @Override
            public Object parseConfiguration(String jsonConfiguration) throws ConfigurationParseException {
                return null;
            }

            @Override
            public void apply(ApiRequest request, IPolicyContext context, Object config,
                    IPolicyChain<ApiRequest> chain) {
                chain.doSkip(request);
            }

            @Override
            public void apply(ApiResponse response, IPolicyContext context, Object config,
                    IPolicyChain<ApiResponse> chain) {
               chain.doSkip(response);
            }
        });

        PolicyWithConfiguration pwcSkip = new PolicyWithConfiguration(skipPolicy, null);
        policies.add(pwcSkip);
        policies.add(pwcTwo);

        requestChain = new RequestChain(policies, mockContext);

        requestChain.bodyHandler(mockBodyHandler);
        requestChain.endHandler(mockEndHandler);

        requestChain.doApply(mockRequest);
        requestChain.end();

        verify(mockEndHandler, times(1)).handle((Void) null);

        // Should only be called once, as the second is skipped
        verify(skipPolicy, times(1)).apply(mockRequest, mockContext, null, requestChain);
        verify(policyOne, never()).apply(mockRequest, mockContext, null, requestChain);
    }
Test {@link RequestChain} and {@link ResponseChain} functionality.

@author Marc Savy <msavy@redhat.com>
gateway/engine/core/src/test/java/io/apiman/gateway/engine/impl/PolicyChainTest.java