@Test
    @Configuration("{" +
            "  \"ttl\" : 2," +
            "  \"cachingResourcesSettingsEntries\" : [{\"statusCode\": \"*\", \"pathPattern\": \"*\", \"httpMethod\": \"*\"}]" +
            "}")
    public void testCaching() throws Throwable {
        PolicyTestRequest request = PolicyTestRequest.build(PolicyTestRequestType.GET, "/some/cached-resource");
        assertRequestIsCached(request);

        Long counterValue = doRequest(request);
        // Now wait for 3s and make sure the cache entry expired
        Thread.sleep(3000);

        Long counterValue2 = doRequest(request);
        //result should not cached
        assertNotEquals(counterValue, counterValue2);

        // And again - should be re-cached
        Long counterValue3 = doRequest(request);
        assertEquals(counterValue2, counterValue3);
    }
Basic test for caching a request and time to live
@throws Throwable
gateway/engine/policies/src/test/java/io/apiman/gateway/engine/policies/CachingResourcesPolicyTest.java