@Test
    @Configuration("{" +
            "  \"ttl\" : 5," +
            "  \"cachingResourcesSettingsEntries\" : [{\"statusCode\": \"200\", \"pathPattern\": \".*\", \"httpMethod\": \"GET\"}]" +
            "}")
    public void testCachingWithStatusCodeAndHttpMethod() throws Throwable {
        final String originalUri = "/foo/test/bar";
        PolicyTestRequest request = PolicyTestRequest.build(PolicyTestRequestType.GET, originalUri);
        //Do first request which should be cached
        Long firstRequestResult = doRequest(request);
        // Now send the request again - we should get the *same* counter value!
        Long secondRequestResult = doRequest(request);
        assertEquals(firstRequestResult, secondRequestResult);

        final String notFoundUri = "/not/found";
        PolicyTestRequest requestNoCache = PolicyTestRequest.build(PolicyTestRequestType.GET, notFoundUri);
        requestNoCache.headers().put("X-Echo-ErrorCode", "404");
        requestNoCache.headers().put("X-Echo-ErrorMessage", "Not found.");
        Long noCachedRequestResult = doRequest(requestNoCache);
        assertTrue(noCachedRequestResult > secondRequestResult);
        //send again /not/found request
        assertRequestNotCached(requestNoCache);

        //Do post request which should not be cached
        PolicyTestRequest requestPost = PolicyTestRequest.build(PolicyTestRequestType.POST, originalUri);
        assertRequestNotCached(requestPost);
    }
Verify that requests with specific status code or http method are cached and others not.
@throws Throwable
gateway/engine/policies/src/test/java/io/apiman/gateway/engine/policies/CachingResourcesPolicyTest.java