@Test
    @Configuration("{" +
            "  \"ttl\" : 2," +
            "  \"includeQueryInKey\" : true" +
            "}")
    public void testCachingUsingQueryString() throws Throwable {
        final String originalUri = "/some/cached-resource?foo=bar";

        PolicyTestResponse response = send(PolicyTestRequest.build(PolicyTestRequestType.GET, originalUri));
        EchoResponse echo = response.entity(EchoResponse.class);
        assertNotNull(echo);
        Long counterValue = echo.getCounter();
        assertNotNull(counterValue);
        assertEquals("application/json", response.header("Content-Type"));
        assertEquals(200, response.code());

        // Request with a different query string - expect an uncached response
        response = send(PolicyTestRequest.build(PolicyTestRequestType.GET, "/some/cached-resource?foo=different"));
        echo = response.entity(EchoResponse.class);
        assertNotNull(echo);
        Long counterValue2 = echo.getCounter();
        assertNotNull(counterValue2);
        assertNotEquals(counterValue, counterValue2);
        assertEquals("application/json", response.header("Content-Type"));
        assertEquals(200, response.code());

        // Request the original URI (including query string) - expect a cached response
        response = send(PolicyTestRequest.build(PolicyTestRequestType.GET, originalUri));
        echo = response.entity(EchoResponse.class);
        assertNotNull(echo);
        Long counterValue3 = echo.getCounter();
        assertNotNull(counterValue3);
        assertEquals(counterValue, counterValue3);
        assertEquals("application/json", response.header("Content-Type"));
        assertEquals(200, response.code());
    }
Verify that the query string is used as part of the cache key - expect
that requests with different query strings are treated as different, from
a caching perspective.
gateway/engine/policies/src/test/java/io/apiman/gateway/engine/policies/CachingPolicyTest.java